}
//=======================================================================
-//function : ConvertElemToQuadratic
-//purpose :
+/*!
+ * \brief Convert elements contained in a submesh to quadratic
+ * \retval int - nb of checked elements
+ */
//=======================================================================
-void SMESH_MeshEditor::ConvertElemToQuadratic(SMESHDS_SubMesh * theSm,
+
+int SMESH_MeshEditor::ConvertElemToQuadratic(SMESHDS_SubMesh * theSm,
SMESH_MesherHelper& theHelper,
const bool theForce3d)
{
- if( !theSm ) return;
- SMESHDS_Mesh* meshDS = GetMeshDS();
+ int nbElem = 0;
+ if( !theSm ) return nbElem;
SMDS_ElemIteratorPtr ElemItr = theSm->GetElements();
while(ElemItr->more())
{
+ nbElem++;
const SMDS_MeshElement* elem = ElemItr->next();
if( !elem || elem->IsQuadratic() ) continue;
SMDSAbs_ElementType aType = elem->GetType();
theSm->RemoveElement(elem);
- meshDS->SMDS_Mesh::RemoveFreeElement(elem);
+ GetMeshDS()->SMDS_Mesh::RemoveFreeElement(elem);
const SMDS_MeshElement* NewElem = 0;
}
if( NewElem )
{
- AddToSameGroups( NewElem, elem, meshDS);
+ AddToSameGroups( NewElem, elem, GetMeshDS());
theSm->AddElement( NewElem );
}
if ( NewElem != elem )
- RemoveElemFromGroups (elem, meshDS);
+ RemoveElemFromGroups (elem, GetMeshDS());
}
+ return nbElem;
}
//=======================================================================
SMESH_MesherHelper aHelper(*myMesh);
aHelper.SetIsQuadratic( true );
+ int nbCheckedElems = 0;
if ( myMesh->HasShapeToMesh() )
{
- SMESH_subMesh *aSubMesh = myMesh->GetSubMesh(myMesh->GetShapeToMesh());
- SMESH_subMeshIteratorPtr smIt = aSubMesh->getDependsOnIterator(false,false);
- while ( smIt->more() ) {
- SMESH_subMesh* sm = smIt->next();
- if ( SMESHDS_SubMesh *smDS = sm->GetSubMeshDS() ) {
- aHelper.SetSubShape( sm->GetSubShape() );
- ConvertElemToQuadratic(smDS, aHelper, theForce3d);
+ if ( SMESH_subMesh *aSubMesh = myMesh->GetSubMeshContaining(myMesh->GetShapeToMesh()))
+ {
+ SMESH_subMeshIteratorPtr smIt = aSubMesh->getDependsOnIterator(true,false);
+ while ( smIt->more() ) {
+ SMESH_subMesh* sm = smIt->next();
+ if ( SMESHDS_SubMesh *smDS = sm->GetSubMeshDS() ) {
+ aHelper.SetSubShape( sm->GetSubShape() );
+ nbCheckedElems += ConvertElemToQuadratic(smDS, aHelper, theForce3d);
+ }
}
}
- aHelper.SetSubShape( aSubMesh->GetSubShape() );
- ConvertElemToQuadratic(aSubMesh->GetSubMeshDS(), aHelper, theForce3d);
}
- else
+ int totalNbElems = meshDS->NbEdges() + meshDS->NbFaces() + meshDS->NbVolumes();
+ if ( nbCheckedElems < totalNbElems ) // not all elements in submeshes
{
SMDS_EdgeIteratorPtr aEdgeItr = meshDS->edgesIterator();
while(aEdgeItr->more())
}
//=======================================================================
-//function : RemoveQuadElem
-//purpose :
+/*!
+ * \brief Convert quadratic elements to linear ones and remove quadratic nodes
+ * \retval int - nb of checked elements
+ */
//=======================================================================
-void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh * theSm,
- SMDS_ElemIteratorPtr theItr,
- const int theShapeID)
+
+int SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh * theSm,
+ SMDS_ElemIteratorPtr theItr,
+ const int theShapeID)
{
+ int nbElem = 0;
SMESHDS_Mesh* meshDS = GetMeshDS();
while( theItr->more() )
{
const SMDS_MeshElement* elem = theItr->next();
+ nbElem++;
if( elem && elem->IsQuadratic())
{
int id = elem->GetID();
if( aNds.empty() ) continue;
SMDSAbs_ElementType aType = elem->GetType();
- //remove old quadratic elements
+ //remove old quadratic element
meshDS->SMDS_Mesh::RemoveFreeElement( elem );
if ( theSm )
theSm->RemoveElement( elem );
}
}
}
+ return nbElem;
}
//=======================================================================
//=======================================================================
bool SMESH_MeshEditor::ConvertFromQuadratic()
{
+ int nbCheckedElems = 0;
if ( myMesh->HasShapeToMesh() )
{
- SMESH_subMesh *aSubMesh = myMesh->GetSubMesh(myMesh->GetShapeToMesh());
- SMESH_subMeshIteratorPtr smIt = aSubMesh->getDependsOnIterator(true,false);
- while ( smIt->more() ) {
- SMESH_subMesh* sm = smIt->next();
- if ( SMESHDS_SubMesh *smDS = sm->GetSubMeshDS() )
- RemoveQuadElem( smDS, smDS->GetElements(), sm->GetId() );
+ if ( SMESH_subMesh *aSubMesh = myMesh->GetSubMeshContaining(myMesh->GetShapeToMesh()))
+ {
+ SMESH_subMeshIteratorPtr smIt = aSubMesh->getDependsOnIterator(true,false);
+ while ( smIt->more() ) {
+ SMESH_subMesh* sm = smIt->next();
+ if ( SMESHDS_SubMesh *smDS = sm->GetSubMeshDS() )
+ nbCheckedElems += RemoveQuadElem( smDS, smDS->GetElements(), sm->GetId() );
+ }
}
}
- else
+
+ int totalNbElems =
+ GetMeshDS()->NbEdges() + GetMeshDS()->NbFaces() + GetMeshDS()->NbVolumes();
+ if ( nbCheckedElems < totalNbElems ) // not all elements in submeshes
{
SMESHDS_SubMesh *aSM = 0;
RemoveQuadElem( aSM, GetMeshDS()->elementsIterator(), 0 );
private:
- void ConvertElemToQuadratic(SMESHDS_SubMesh * theSm,
- SMESH_MesherHelper& theHelper,
- const bool theForce3d);
- //Auxiliary function for "ConvertToQuadratic" is intended to convert
- //elements contained in submesh to quadratic
-
- void RemoveQuadElem( SMESHDS_SubMesh * theSm,
- SMDS_ElemIteratorPtr theItr,
- const int theShapeID);
- //Auxiliary function for "ConvertFromQuadratic" is intended to convert quadratic
- //element to ordinary and for removing quadratic nodes
+ /*!
+ * \brief Convert elements contained in a submesh to quadratic
+ * \retval int - nb of checked elements
+ */
+ int ConvertElemToQuadratic(SMESHDS_SubMesh * theSm,
+ SMESH_MesherHelper& theHelper,
+ const bool theForce3d);
+
+ /*!
+ * \brief Convert quadratic elements to linear ones and remove quadratic nodes
+ * \retval int - nb of checked elements
+ */
+ int RemoveQuadElem( SMESHDS_SubMesh * theSm,
+ SMDS_ElemIteratorPtr theItr,
+ const int theShapeID);
+ //Auxiliary function for "ConvertFromQuadratic" is intended to
private: