0020982: EDF 1547 SMESH: Creation of non-conformal quadratic pyramids

Show elements whose medium nodes were not placed on geometry
This commit is contained in:
eap 2012-09-17 10:20:24 +00:00
parent 6adaa05a56
commit bf2593a237
3 changed files with 68 additions and 9 deletions

View File

@ -29,21 +29,26 @@
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_ConvToQuadDlg.h" #include "SMESHGUI_ConvToQuadDlg.h"
#include "SMESHGUI_MeshEditPreview.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMDSAbs_ElementType.hxx" #include "SMESH_ActorUtils.h"
#include "SMESH_TypeFilter.hxx" #include "SMESH_TypeFilter.hxx"
#include "SMDSAbs_ElementType.hxx"
// SALOME GUI includes // SALOME GUI includes
#include <LightApp_UpdateFlags.h> #include <LightApp_UpdateFlags.h>
#include <SUIT_MessageBox.h> #include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h> #include <SUIT_OverrideCursor.h>
#include <SalomeApp_Tools.h> #include <SalomeApp_Tools.h>
#include <SALOME_Actor.h>
// IDL includes // IDL includes
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_MeshEditor) #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
// VTK includes
#include <vtkProperty.h>
//================================================================================ //================================================================================
/*! /*!
* \brief Constructor * \brief Constructor
@ -53,7 +58,8 @@
//================================================================================ //================================================================================
SMESHGUI_ConvToQuadOp::SMESHGUI_ConvToQuadOp() SMESHGUI_ConvToQuadOp::SMESHGUI_ConvToQuadOp()
: SMESHGUI_SelectionOp(), : SMESHGUI_SelectionOp(),
myDlg( 0 ) myDlg( 0 ),
myBadElemsPreview(0)
{ {
} }
@ -64,8 +70,8 @@ SMESHGUI_ConvToQuadOp::SMESHGUI_ConvToQuadOp()
//================================================================================ //================================================================================
SMESHGUI_ConvToQuadOp::~SMESHGUI_ConvToQuadOp() SMESHGUI_ConvToQuadOp::~SMESHGUI_ConvToQuadOp()
{ {
if ( myDlg ) if ( myDlg ) delete myDlg;
delete myDlg; if ( myBadElemsPreview ) delete myBadElemsPreview;
} }
//================================================================================ //================================================================================
@ -237,14 +243,47 @@ bool SMESHGUI_ConvToQuadOp::onApply()
SMESH::SMESH_Mesh_var sourceMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pObj ); SMESH::SMESH_Mesh_var sourceMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pObj );
if( !myDlg->CurrentRB() ) if( !myDlg->CurrentRB() )
{ {
bool aParam = true; bool force3d = true;
if( myDlg->IsEnabledCheck() ) if( myDlg->IsEnabledCheck() )
aParam = myDlg->IsMediumNdsOnGeom(); force3d = myDlg->IsMediumNdsOnGeom();
if ( sourceMesh->_is_nil() ) if ( sourceMesh->_is_nil() )
aEditor->ConvertToQuadraticObject( aParam, idSource ); aEditor->ConvertToQuadraticObject( force3d, idSource );
else else
aEditor->ConvertToQuadratic( aParam ); aEditor->ConvertToQuadratic( force3d );
if ( !force3d )
{
SMESH::ComputeError_var error = aEditor->GetLastError();
if ( error->hasBadMesh )
{
if ( myBadElemsPreview ) delete myBadElemsPreview; // viewWindow may change
myBadElemsPreview = new SMESHGUI_MeshEditPreview( viewWindow() );
vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
vtkProperty* prop = vtkProperty::New();
prop->SetLineWidth( aLineWidth * 3 );
prop->SetPointSize( aPointSize * 3 );
prop->SetColor( 250, 0, 250 );
myBadElemsPreview->GetActor()->SetProperty( prop );
prop->Delete();
SMESH::MeshPreviewStruct_var previewData = aEditor->GetPreviewData();
myBadElemsPreview->SetData( & previewData.in() );
myBadElemsPreview->SetVisibility(true);
SUIT_MessageBox* mb = new SUIT_MessageBox(SUIT_MessageBox::Warning,
tr( "SMESH_WRN_WARNING" ),
tr("EDITERR_NO_MEDIUM_ON_GEOM"),
SUIT_MessageBox::Ok, myDlg);
mb->setWindowModality( Qt::NonModal );
mb->setAttribute( Qt::WA_DeleteOnClose );
mb->show();
connect ( mb, SIGNAL( finished(int) ), this, SLOT( onWarningWinFinished() ));
//connect ( mb, SIGNAL( rejected() ), this, SLOT( onWarningWinFinished() ));
}
}
} }
else else
{ {
@ -272,6 +311,18 @@ bool SMESHGUI_ConvToQuadOp::onApply()
return aResult; return aResult;
} }
//================================================================================
/*!
* \brief SLOT called when a warning window is closed
*/
//================================================================================
void SMESHGUI_ConvToQuadOp::onWarningWinFinished()
{
if ( myBadElemsPreview )
myBadElemsPreview->SetVisibility(false);
}
//================================================================================ //================================================================================
/*! ConsistMesh /*! ConsistMesh
* Determines, what elements this mesh contains. * Determines, what elements this mesh contains.

View File

@ -37,6 +37,7 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
class SMESHGUI_ConvToQuadDlg; class SMESHGUI_ConvToQuadDlg;
class SMESHGUI_MeshEditPreview;
class SMESHGUI_EXPORT SMESHGUI_ConvToQuadOp : public SMESHGUI_SelectionOp class SMESHGUI_EXPORT SMESHGUI_ConvToQuadOp : public SMESHGUI_SelectionOp
{ {
@ -60,9 +61,11 @@ protected:
protected slots: protected slots:
virtual bool onApply(); virtual bool onApply();
void ConnectRadioButtons( int ); void ConnectRadioButtons( int );
void onWarningWinFinished();
private: private:
SMESHGUI_ConvToQuadDlg* myDlg; SMESHGUI_ConvToQuadDlg* myDlg;
SMESHGUI_MeshEditPreview* myBadElemsPreview;
}; };
#endif // SMESHGUI_CONVTOQUADOP_H #endif // SMESHGUI_CONVTOQUADOP_H

View File

@ -131,6 +131,11 @@
<source>COMPERR_NO_MESH_ON_SHAPE</source> <source>COMPERR_NO_MESH_ON_SHAPE</source>
<translation>No mesh elements assigned to a Sub-shape</translation> <translation>No mesh elements assigned to a Sub-shape</translation>
</message> </message>
<message>
<source>EDITERR_NO_MEDIUM_ON_GEOM</source>
<translation>Some medium nodes not placed on geometry to avoid
distorting elements shown in magenta</translation>
</message>
<message> <message>
<source>SMESH_GEOM</source> <source>SMESH_GEOM</source>
<translation>Geometry</translation> <translation>Geometry</translation>