\page convert_to_from_quadratic_mesh_page Convert to/from Quadratic Mesh
-\n This functionality allows you to transtorm standard meshes to
-quadratic and vice versa. See \ref adding_quadratic_elements_page "Adding quadratic elements"
+\n This functionality allows you to transtorm standard meshes (or
+sum-mesh) to quadratic and vice versa.
+See \ref adding_quadratic_elements_page "Adding quadratic elements"
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>
<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
Mesh item, or click <em>"Convert to/from quadratic"</em> button in the
toolbar.
\image html convert.png
</li>
-<li>In this dialog box you should select:
+<li>In this dialog box you should specify:
<ul>
-<li>if you wish to convert standard mesh to quadratic or quadratic to standard;</li>
-<li>if you wish to place medium nodes of the quadratic mesh on the geometry (meshed object).</li>
+<li>if you wish to convert a standard mesh to quadratic or a quadratic
+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>
\image html image156.gif
#include <QFrame>
#include <QHBoxLayout>
#include <QGridLayout>
+#include <QLabel>
#define SPACING 6
#define MARGIN 11
myBG->addButton(myRB2, 1);
myRB1->setChecked( true );
+ myWarning = new QLabel(QString("<b>%1</b>").arg(tr("NON_CONFORM_WARNING")), mainFrame());
+
// Fill layout
QGridLayout* aLay = new QGridLayout( mainFrame() );
aLay->setMargin( 5 );
aLay->addWidget( objectWg( 0, Control ), 0, 2 );
aLay->addWidget( myMedNdsOnGeom, 1, 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 ) ) );
}
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 )
{
- myBGBox->setEnabled( theCheck );
+ //myBGBox->setEnabled( theCheck );
+ myRB1->setEnabled( theCheck );
+ myRB2->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 )
#include "SMESHGUI.h"
#include "SMESHGUI_ConvToQuadDlg.h"
#include "SMESHGUI_Utils.h"
+#include "SMDSAbs_ElementType.hxx"
-#include <SMESH_TypeFilter.hxx>
+#include "SMESH_TypeFilter.hxx"
// SALOME GUI includes
#include <LightApp_UpdateFlags.h>
myDlg->SetMediumNdsOnGeom( false );
myDlg->activateObject( 0 );
+ myDlg->ShowWarning( false );
myDlg->show();
selectionDone();
SMESHGUI_SelectionOp::selectionDone();
try
{
- QString anMeshEntry = myDlg->selectedObject( 0 );
- _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.toLatin1().data() );
- if ( !pMesh ) return;
+ QString anObjEntry = myDlg->selectedObject( 0 );
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ if ( !pObj ) return;
- SMESH::SMESH_Mesh_var mesh =
- SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ SMESH::SMESH_IDSource_var idSource =
+ 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->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 );
}
- else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Linear )
+ else if( meshType == SMESHGUI_ConvToQuadOp::Linear )
{
myDlg->SetEnabledRB( 1, false );
}
{
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 )
{
SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) const
{
if ( theId == 0 )
- return new SMESH_TypeFilter( MESH );
+ return new SMESH_TypeFilter( MESHorSUBMESH );
else
return 0;
}
QString aMess;
- QString anMeshEntry = myDlg->selectedObject( 0 );
- _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.toLatin1().data() );
- if ( !pMesh )
+ QString anObjEntry = myDlg->selectedObject( 0 );
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ if ( !pObj )
{
dlg()->show();
SUIT_MessageBox::warning( myDlg,
tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED") );
-
return false;
}
- SMESH::SMESH_Mesh_var mesh =
- SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ SMESH::SMESH_Mesh_var mesh;
+ SMESH::SMESH_IDSource_var idSource =
+ SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
+ if( !CORBA::is_nil(idSource) )
+ mesh = idSource->GetMesh();
if( CORBA::is_nil(mesh) )
{
SUIT_MessageBox::warning( myDlg,
tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL") );
-
return false;
- }
+ }
bool aResult = false;
try
{
SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor();
+ aResult = true;
if( !myDlg->CurrentRB() )
{
bool aParam = true;
if( myDlg->IsEnabledCheck() )
aParam = myDlg->IsMediumNdsOnGeom();
- aEditor->ConvertToQuadratic( aParam );
- aResult = true;
+ if ( myDlg->isWarningShown() )
+ aEditor->ConvertToQuadraticObject( aParam, idSource );
+ else
+ aEditor->ConvertToQuadratic( aParam );
}
else
{
- aResult = aEditor->ConvertFromQuadratic();
+ if ( myDlg->isWarningShown() )
+ aEditor->ConvertFromQuadraticObject( idSource );
+ else
+ aEditor->ConvertFromQuadratic();
}
}
catch ( const SALOME::SALOME_Exception& S_ex )
* 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;
- int nbEdges = 0, nbFaces = 0, nbVolum = 0;
-
- nbAllElem = (int)mesh->NbElements();
- nbQEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC);
- nbQFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_QUADRATIC);
- nbQVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_QUADRATIC);
-
- nbEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR);
- nbFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_LINEAR);
- nbVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_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;
+ SMESH::long_array_var nbElemOfType = idSource->GetMeshInfo();
+ 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 ] );
+
+ bool hasLin = ( nbElemOfType[SMDSEntity_Edge ] ||
+ nbElemOfType[SMDSEntity_Triangle ] ||
+ nbElemOfType[SMDSEntity_Quadrangle] ||
+ nbElemOfType[SMDSEntity_Tetra ] ||
+ nbElemOfType[SMDSEntity_Hexa ] ||
+ nbElemOfType[SMDSEntity_Pyramid ] ||
+ nbElemOfType[SMDSEntity_Penta ] );
+
+ if ( hasQuad && hasLin )
+ return Comp;
+ return hasQuad ? Quadratic : Linear;
}
-
void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id )
{
- QString anMeshEntry = myDlg->selectedObject( 0 );
- _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.toLatin1().data() );
- if ( !pMesh ) return;
+ QString anObjEntry = myDlg->selectedObject( 0 );
+ _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
+ if ( !pObj ) return;
- SMESH::SMESH_Mesh_var mesh =
- SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
+ SMESH::SMESH_IDSource_var idSource =
+ SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( pObj );
+ SMESH::SMESH_Mesh_var mesh = idSource->GetMesh();
- GEOM::GEOM_Object_var mainGeom;
- mainGeom = mesh->GetShapeToMesh();
+ bool hasGeom = mesh->HasShapeToMesh();
- if( id || mainGeom->_is_nil() )
+ if( id || !hasGeom )
myDlg->SetEnabledCheck( false );
else
myDlg->SetEnabledCheck( true );