From: eap Date: Fri, 21 Jan 2005 12:16:32 +0000 (+0000) Subject: PAL7358. Now Reorient() can work with edge, faces and volumes X-Git-Tag: V2_2_0b2~40 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=08e0a4de43baa17209cefa536be155f1585297a0 PAL7358. Now Reorient() can work with edge, faces and volumes --- diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index d71d4efdc..b884dcd53 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; } //======================================================================= diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index fecb8b3bc..677d9c033 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -70,9 +70,8 @@ class SMESH_MeshEditor { // with a quadrangle built on the same 4 nodes. // Return false if proper faces not found - bool Reorient (const SMDS_MeshElement * theFace); - // Reverse the normal of theFace - // Return false if theFace is null + bool Reorient (const SMDS_MeshElement * theElement); + // Reverse theElement orientation bool TriToQuad (std::set & theElems,