0020978: EDF 1475 SMESH: Convert linear to quadratic on a submesh

This commit is contained in:
eap 2011-03-16 15:41:27 +00:00
parent c774eacd4e
commit d992d85973
9 changed files with 135 additions and 58 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -2,12 +2,18 @@
\page convert_to_from_quadratic_mesh_page Convert to/from Quadratic Mesh \page convert_to_from_quadratic_mesh_page Convert to/from Quadratic Mesh
\n This functionality allows you to transtorm standard meshes to \n This functionality allows you to transtorm standard meshes (or
quadratic and vice versa. See \ref adding_quadratic_elements_page "Adding quadratic elements" sum-mesh) to quadratic and vice versa.
See \ref adding_quadratic_elements_page "Adding quadratic elements"
for more information about quadratic meshes. for more information about quadratic meshes.
Note that conversion of the sub-mesh most probably will
produce a non-conformal mesh. Elements on the boundary between
quadratic and linear sub-meshes become (or remain) quadratic.
<em>To produce a conversion:</em> <em>To produce a conversion:</em>
<ol> <ol>
<li>Select a mesh or a sub-mesh in the Object Browser or in the
Viewer.</li>
<li>From the Modification menu choose the Convert to/from Quadratic <li>From the Modification menu choose the Convert to/from Quadratic
Mesh item, or click <em>"Convert to/from quadratic"</em> button in the Mesh item, or click <em>"Convert to/from quadratic"</em> button in the
toolbar. toolbar.
@ -20,11 +26,18 @@ The following dialog box will appear:
\image html convert.png \image html convert.png
</li> </li>
<li>In this dialog box you should select: <li>In this dialog box you should specify:
<ul> <ul>
<li>if you wish to convert standard mesh to quadratic or quadratic to standard;</li> <li>if you wish to convert a standard mesh to quadratic or a quadratic
<li>if you wish to place medium nodes of the quadratic mesh on the geometry (meshed object).</li> mesh to standard. Note that the choice is available only if the selected mesh
(or sub-mesh) contains both quadratic and linear elements, else the
sole direction of convertion is automatically selected.</li>
<li>if you wish to place medium nodes of the quadratic mesh on the
geometry (meshed object). This option is active at convertion to
qudratic mesh only and provided that the mesh is based on some
geometry (not imported from the file).</li>
</ul> </ul>
\image html image156.gif \image html image156.gif

View File

@ -959,6 +959,13 @@ Mesh.ConvertFromQuadratic()
Mesh.ConvertToQuadratic( theForce3d=0 ) Mesh.ConvertToQuadratic( theForce3d=0 )
# to convert not the whole mesh but a sub-mesh, provide it as
# an additional argument to the functions:
# Mesh.ConvertToQuadratic( 0, subMesh )
# Mesh.ConvertFromQuadratic( subMesh )
#
# Note that the mesh becomes non-conformal at conversion of sub-mesh.
\endcode \endcode
*/ */

View File

@ -3778,7 +3778,7 @@ void SMESHGUI::initialize( CAM_Application* app )
popupMgr()->insert( separator(), -1, 0 ); popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 4043, OB, mesh ); // CLEAR_MESH createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
popupMgr()->insert( separator(), -1, 0 ); popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 417, OB, mesh/*, "&& " + hasElems*/); // convert to quadratic createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D createPopupItem( 418, OB, mesh/*, "&& " + hasVolumes*/); // create 2D mesh on 3D
popupMgr()->insert( separator(), -1, 0 ); popupMgr()->insert( separator(), -1, 0 );

View File

@ -36,6 +36,7 @@
#include <QFrame> #include <QFrame>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QGridLayout> #include <QGridLayout>
#include <QLabel>
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
@ -70,6 +71,8 @@ SMESHGUI_ConvToQuadDlg::SMESHGUI_ConvToQuadDlg()
myBG->addButton(myRB2, 1); myBG->addButton(myRB2, 1);
myRB1->setChecked( true ); myRB1->setChecked( true );
myWarning = new QLabel(QString("<b>%1</b>").arg(tr("NON_CONFORM_WARNING")), mainFrame());
// Fill layout // Fill layout
QGridLayout* aLay = new QGridLayout( mainFrame() ); QGridLayout* aLay = new QGridLayout( mainFrame() );
aLay->setMargin( 5 ); aLay->setMargin( 5 );
@ -80,6 +83,7 @@ SMESHGUI_ConvToQuadDlg::SMESHGUI_ConvToQuadDlg()
aLay->addWidget( objectWg( 0, Control ), 0, 2 ); aLay->addWidget( objectWg( 0, Control ), 0, 2 );
aLay->addWidget( myMedNdsOnGeom, 1, 0, 1, 3 ); aLay->addWidget( myMedNdsOnGeom, 1, 0, 1, 3 );
aLay->addWidget( myBGBox, 2, 0, 1, 3 ); aLay->addWidget( myBGBox, 2, 0, 1, 3 );
aLay->addWidget( myWarning, 3, 0, 1, 3 );
connect(myBG, SIGNAL( buttonClicked( int ) ), this, SIGNAL( onClicked( int ) ) ); connect(myBG, SIGNAL( buttonClicked( int ) ), this, SIGNAL( onClicked( int ) ) );
} }
@ -113,11 +117,26 @@ int SMESHGUI_ConvToQuadDlg::CurrentRB( )
return myBG->checkedId(); return myBG->checkedId();
} }
void SMESHGUI_ConvToQuadDlg::ShowWarning(bool toShow)
{
if ( toShow )
myWarning->show();
else
myWarning->hide();
}
bool SMESHGUI_ConvToQuadDlg::isWarningShown()
{
return myWarning->isVisible();
}
void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck ) void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck )
{ {
myBGBox->setEnabled( theCheck ); //myBGBox->setEnabled( theCheck );
myRB1->setEnabled( theCheck );
myRB2->setEnabled( theCheck );
myMedNdsOnGeom->setEnabled( theCheck ); myMedNdsOnGeom->setEnabled( theCheck );
setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply ); //setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply );
} }
void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck ) void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck )

View File

@ -36,6 +36,7 @@ class QCheckBox;
class QRadioButton; class QRadioButton;
class QButtonGroup; class QButtonGroup;
class QGroupBox; class QGroupBox;
class QLabel;
class SMESHGUI_EXPORT SMESHGUI_ConvToQuadDlg : public SMESHGUI_Dialog class SMESHGUI_EXPORT SMESHGUI_ConvToQuadDlg : public SMESHGUI_Dialog
{ {
@ -53,6 +54,8 @@ public:
void SetEnabledControls( const bool ); void SetEnabledControls( const bool );
void SetEnabledRB( const int, const bool ); void SetEnabledRB( const int, const bool );
int CurrentRB(); //returns the ID of the selected toggle button int CurrentRB(); //returns the ID of the selected toggle button
void ShowWarning(bool);
bool isWarningShown();
signals: signals:
void onClicked( int ); void onClicked( int );
@ -63,6 +66,7 @@ private:
QButtonGroup* myBG; QButtonGroup* myBG;
QRadioButton* myRB1; QRadioButton* myRB1;
QRadioButton* myRB2; QRadioButton* myRB2;
QLabel* myWarning;
}; };
#endif // SMESHGUI_CONVTOQUADDLG_H #endif // SMESHGUI_CONVTOQUADDLG_H

View File

@ -30,8 +30,9 @@
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_ConvToQuadDlg.h" #include "SMESHGUI_ConvToQuadDlg.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMDSAbs_ElementType.hxx"
#include <SMESH_TypeFilter.hxx> #include "SMESH_TypeFilter.hxx"
// SALOME GUI includes // SALOME GUI includes
#include <LightApp_UpdateFlags.h> #include <LightApp_UpdateFlags.h>
@ -100,6 +101,7 @@ void SMESHGUI_ConvToQuadOp::startOperation()
myDlg->SetMediumNdsOnGeom( false ); myDlg->SetMediumNdsOnGeom( false );
myDlg->activateObject( 0 ); myDlg->activateObject( 0 );
myDlg->ShowWarning( false );
myDlg->show(); myDlg->show();
selectionDone(); selectionDone();
@ -120,22 +122,26 @@ void SMESHGUI_ConvToQuadOp::selectionDone()
SMESHGUI_SelectionOp::selectionDone(); SMESHGUI_SelectionOp::selectionDone();
try try
{ {
QString anMeshEntry = myDlg->selectedObject( 0 ); QString anObjEntry = myDlg->selectedObject( 0 );
_PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.toLatin1().data() ); _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
if ( !pMesh ) return; if ( !pObj ) return;
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_IDSource_var idSource =
SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh ); SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
if( mesh->_is_nil() ) myDlg->setButtonEnabled( true, QtxDialog::OK | QtxDialog::Apply );
if( idSource->_is_nil() )
{ {
myDlg->SetEnabledControls( false ); myDlg->SetEnabledControls( false );
myDlg->setButtonEnabled( false, QtxDialog::OK | QtxDialog::Apply );
return;
} }
else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Quadratic ) MeshType meshType = ConsistMesh( idSource );
if( meshType == SMESHGUI_ConvToQuadOp::Quadratic )
{ {
myDlg->SetEnabledRB( 0, false ); myDlg->SetEnabledRB( 0, false );
} }
else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Linear ) else if( meshType == SMESHGUI_ConvToQuadOp::Linear )
{ {
myDlg->SetEnabledRB( 1, false ); myDlg->SetEnabledRB( 1, false );
} }
@ -143,6 +149,22 @@ void SMESHGUI_ConvToQuadOp::selectionDone()
{ {
myDlg->SetEnabledControls( true ); myDlg->SetEnabledControls( true );
} }
// show warning on non-conformal result mesh
if ( ! idSource->_is_nil() )
{
SMESH::SMESH_subMesh_var subMesh =
SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pObj );
bool toShow = false;
if ( !subMesh->_is_nil() )
{
SMESH::SMESH_Mesh_var mesh = idSource->GetMesh();
idSource = SMESH::SMESH_IDSource::_narrow( mesh );
MeshType fullMeshType = ConsistMesh( idSource );
toShow = ( fullMeshType != Comp );
}
myDlg->ShowWarning( toShow );
}
} }
catch ( const SALOME::SALOME_Exception& S_ex ) catch ( const SALOME::SALOME_Exception& S_ex )
{ {
@ -165,7 +187,7 @@ void SMESHGUI_ConvToQuadOp::selectionDone()
SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) const SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) const
{ {
if ( theId == 0 ) if ( theId == 0 )
return new SMESH_TypeFilter( MESH ); return new SMESH_TypeFilter( MESHorSUBMESH );
else else
return 0; return 0;
} }
@ -183,25 +205,26 @@ bool SMESHGUI_ConvToQuadOp::onApply()
QString aMess; QString aMess;
QString anMeshEntry = myDlg->selectedObject( 0 ); QString anObjEntry = myDlg->selectedObject( 0 );
_PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.toLatin1().data() ); _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
if ( !pMesh ) if ( !pObj )
{ {
dlg()->show(); dlg()->show();
SUIT_MessageBox::warning( myDlg, SUIT_MessageBox::warning( myDlg,
tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED") ); tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED") );
return false; return false;
} }
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh_var mesh;
SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh ); SMESH::SMESH_IDSource_var idSource =
SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
if( !CORBA::is_nil(idSource) )
mesh = idSource->GetMesh();
if( CORBA::is_nil(mesh) ) if( CORBA::is_nil(mesh) )
{ {
SUIT_MessageBox::warning( myDlg, SUIT_MessageBox::warning( myDlg,
tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL") ); tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL") );
return false; return false;
} }
@ -210,18 +233,24 @@ bool SMESHGUI_ConvToQuadOp::onApply()
try try
{ {
SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor();
aResult = true;
if( !myDlg->CurrentRB() ) if( !myDlg->CurrentRB() )
{ {
bool aParam = true; bool aParam = true;
if( myDlg->IsEnabledCheck() ) if( myDlg->IsEnabledCheck() )
aParam = myDlg->IsMediumNdsOnGeom(); aParam = myDlg->IsMediumNdsOnGeom();
if ( myDlg->isWarningShown() )
aEditor->ConvertToQuadraticObject( aParam, idSource );
else
aEditor->ConvertToQuadratic( aParam ); aEditor->ConvertToQuadratic( aParam );
aResult = true;
} }
else else
{ {
aResult = aEditor->ConvertFromQuadratic(); if ( myDlg->isWarningShown() )
aEditor->ConvertFromQuadraticObject( idSource );
else
aEditor->ConvertFromQuadratic();
} }
} }
catch ( const SALOME::SALOME_Exception& S_ex ) catch ( const SALOME::SALOME_Exception& S_ex )
@ -247,42 +276,43 @@ bool SMESHGUI_ConvToQuadOp::onApply()
* Determines, what elements this mesh contains. * Determines, what elements this mesh contains.
*/ */
//================================================================================ //================================================================================
SMESHGUI_ConvToQuadOp::MeshType SMESHGUI_ConvToQuadOp::ConsistMesh( const SMESH::SMESH_Mesh_var& mesh) const SMESHGUI_ConvToQuadOp::MeshType SMESHGUI_ConvToQuadOp::ConsistMesh( const SMESH::SMESH_IDSource_var& idSource) const
{ {
int nbAllElem = 0, nbQEdges =0, nbQFaces =0, nbQVolum = 0; SMESH::long_array_var nbElemOfType = idSource->GetMeshInfo();
int nbEdges = 0, nbFaces = 0, nbVolum = 0; bool hasQuad = ( nbElemOfType[SMDSEntity_Quad_Edge ] ||
nbElemOfType[SMDSEntity_Quad_Triangle ] ||
nbElemOfType[SMDSEntity_Quad_Quadrangle] ||
nbElemOfType[SMDSEntity_Quad_Tetra ] ||
nbElemOfType[SMDSEntity_Quad_Hexa ] ||
nbElemOfType[SMDSEntity_Quad_Pyramid ] ||
nbElemOfType[SMDSEntity_Quad_Penta ] );
nbAllElem = (int)mesh->NbElements(); bool hasLin = ( nbElemOfType[SMDSEntity_Edge ] ||
nbQEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC); nbElemOfType[SMDSEntity_Triangle ] ||
nbQFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_QUADRATIC); nbElemOfType[SMDSEntity_Quadrangle] ||
nbQVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_QUADRATIC); nbElemOfType[SMDSEntity_Tetra ] ||
nbElemOfType[SMDSEntity_Hexa ] ||
nbElemOfType[SMDSEntity_Pyramid ] ||
nbElemOfType[SMDSEntity_Penta ] );
nbEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR); if ( hasQuad && hasLin )
nbFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_LINEAR); return Comp;
nbVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_LINEAR); return hasQuad ? Quadratic : Linear;
if( nbAllElem == (nbQEdges+nbQFaces+nbQVolum) )
return SMESHGUI_ConvToQuadOp::Quadratic;
else if ( nbAllElem == (nbEdges+nbFaces+nbVolum) )
return SMESHGUI_ConvToQuadOp::Linear;
else
return SMESHGUI_ConvToQuadOp::Comp;
} }
void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id ) void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id )
{ {
QString anMeshEntry = myDlg->selectedObject( 0 ); QString anObjEntry = myDlg->selectedObject( 0 );
_PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.toLatin1().data() ); _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
if ( !pMesh ) return; if ( !pObj ) return;
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_IDSource_var idSource =
SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh ); SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
SMESH::SMESH_Mesh_var mesh = idSource->GetMesh();
GEOM::GEOM_Object_var mainGeom; bool hasGeom = mesh->HasShapeToMesh();
mainGeom = mesh->GetShapeToMesh();
if( id || mainGeom->_is_nil() ) if( id || !hasGeom )
myDlg->SetEnabledCheck( false ); myDlg->SetEnabledCheck( false );
else else
myDlg->SetEnabledCheck( true ); myDlg->SetEnabledCheck( true );

View File

@ -55,7 +55,7 @@ protected:
virtual void startOperation(); virtual void startOperation();
virtual void selectionDone(); virtual void selectionDone();
virtual SUIT_SelectionFilter* createFilter( const int ) const; virtual SUIT_SelectionFilter* createFilter( const int ) const;
MeshType ConsistMesh( const SMESH::SMESH_Mesh_var& ) const; MeshType ConsistMesh( const SMESH::SMESH_IDSource_var& ) const;
protected slots: protected slots:
virtual bool onApply(); virtual bool onApply();

View File

@ -3903,7 +3903,7 @@ Do you want to restore original submesh priority?</translation>
</message> </message>
<message> <message>
<source>MESH</source> <source>MESH</source>
<translation>Mesh</translation> <translation>Mesh or Sub-mesh</translation>
</message> </message>
<message> <message>
<source>RADIOBTN_1</source> <source>RADIOBTN_1</source>
@ -3913,6 +3913,10 @@ Do you want to restore original submesh priority?</translation>
<source>RADIOBTN_2</source> <source>RADIOBTN_2</source>
<translation>Convert from quadratic</translation> <translation>Convert from quadratic</translation>
</message> </message>
<message>
<source>NON_CONFORM_WARNING</source>
<translation>Warning: mesh can become non-conformal</translation>
</message>
</context> </context>
<context> <context>
<name>SMESHGUI_ConvToQuadOp</name> <name>SMESHGUI_ConvToQuadOp</name>