From: eap Date: Thu, 12 Apr 2007 14:06:31 +0000 (+0000) Subject: PAL13330( When mesh generation does not success, trace where ) X-Git-Tag: V3_2_6pre4~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f823b723b677012f52549f0750045df73ad0850d;p=modules%2Fsmesh.git PAL13330( When mesh generation does not success, trace where ) fix conversion to/from quadratic order --- diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index bc045f7f2..89fd80c5a 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -6307,18 +6307,22 @@ void SMESH_MeshEditor::UpdateVolumes (const SMDS_MeshNode* theBetweenNode } //======================================================================= -//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; @@ -6333,7 +6337,7 @@ void SMESH_MeshEditor::ConvertElemToQuadratic(SMESHDS_SubMesh * theSm, SMDSAbs_ElementType aType = elem->GetType(); theSm->RemoveElement(elem); - meshDS->SMDS_Mesh::RemoveFreeElement(elem); + GetMeshDS()->SMDS_Mesh::RemoveFreeElement(elem); const SMDS_MeshElement* NewElem = 0; @@ -6383,12 +6387,13 @@ void SMESH_MeshEditor::ConvertElemToQuadratic(SMESHDS_SubMesh * theSm, } if( NewElem ) { - AddToSameGroups( NewElem, elem, meshDS); + AddToSameGroups( NewElem, elem, GetMeshDS()); theSm->AddElement( NewElem ); } if ( NewElem != elem ) - RemoveElemFromGroups (elem, meshDS); + RemoveElemFromGroups (elem, GetMeshDS()); } + return nbElem; } //======================================================================= @@ -6402,21 +6407,23 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d) 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()) @@ -6515,17 +6522,22 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d) } //======================================================================= -//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(); @@ -6546,7 +6558,7 @@ void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh * theSm, 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 ); @@ -6573,6 +6585,7 @@ void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh * theSm, } } } + return nbElem; } //======================================================================= @@ -6581,17 +6594,23 @@ void SMESH_MeshEditor::RemoveQuadElem(SMESHDS_SubMesh * theSm, //======================================================================= 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 ); diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index 483c2eae9..54b601460 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -501,17 +501,22 @@ public: 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: