X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_MeshEditor.cxx;h=13e319ab58a3da2ab1f2e2ffa6fad1dec2a818b9;hb=1bc504bf901039d3cf41d8f1a65f1f955579cf34;hp=d71d4efdc67ab8cad8fc43fb9b3bd1e7ee70caec;hpb=3f9592083e6bd379bfaee0a5ebc92053bfecfc59;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index d71d4efdc..13e319ab5 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -470,34 +470,40 @@ bool SMESH_MeshEditor::DeleteDiag (const SMDS_MeshNode * theNode1, //======================================================================= //function : Reorient -//purpose : Reverse the normal of theFace -// Return false if theFace is null +//purpose : Reverse theElement orientation //======================================================================= -bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theFace) +bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theElem) { - if (!theFace) return false; - const SMDS_FaceOfNodes* F = dynamic_cast( theFace ); - if (!F) return false; - - const SMDS_MeshNode* aNodes [4], *tmpNode; - int i = 0; - SMDS_ElemIteratorPtr it = theFace->nodesIterator(); - while ( it->more() ) - aNodes[ i++ ] = static_cast( it->next() ); - - // exchange nodes with indeces 0 and 2 - tmpNode = aNodes[ 0 ]; - aNodes[ 0 ] = aNodes[ 2 ]; - aNodes[ 2 ] = tmpNode; - - //MESSAGE( theFace ); - - GetMeshDS()->ChangeElementNodes( theFace, aNodes, theFace->NbNodes() ); + if (!theElem) + return false; + SMDS_ElemIteratorPtr it = theElem->nodesIterator(); + if ( !it || !it->more() ) + return false; - //MESSAGE( theFace ); + switch ( theElem->GetType() ) { + + case SMDSAbs_Edge: + case SMDSAbs_Face: + { + int i = theElem->NbNodes(); + vector aNodes( i ); + while ( it->more() ) + aNodes[ --i ]= static_cast( it->next() ); + return GetMeshDS()->ChangeElementNodes( theElem, &aNodes[0], theElem->NbNodes() ); + } + case SMDSAbs_Volume: + { + SMDS_VolumeTool vTool; + if ( !vTool.Set( theElem )) + return false; + vTool.Inverse(); + return GetMeshDS()->ChangeElementNodes( theElem, vTool.GetNodes(), vTool.NbNodes() ); + } + default:; + } - return true; + return false; } //======================================================================= @@ -2924,7 +2930,7 @@ static const SMDS_MeshElement* findAdjacentFace(const SMDS_MeshNode* n1, set elemSet, avoidSet; if ( elem ) avoidSet.insert ( elem ); - SMESH_MeshEditor::FindFaceInSet( n1, n2, elemSet, avoidSet ); + return SMESH_MeshEditor::FindFaceInSet( n1, n2, elemSet, avoidSet ); } //=======================================================================