Salome HOME
0020145: EDF 666 SMESH: Modifications of GEOM groups are not taken into account
[modules/smesh.git] / src / StdMeshers / StdMeshers_FaceSide.cxx
index 5850cb74ea5523b2b9922e542490b845c7488303..dbf7a3675b8220988fbc0424d03e863321d959fb 100644 (file)
@@ -1,31 +1,30 @@
-//  SMESH SMESH : implementaion of SMESH idl descriptions
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH SMESH : implementaion of SMESH idl descriptions
 // File      : StdMeshers_FaceSide.hxx
 // Created   : Wed Jan 31 18:41:25 2007
 // Author    : Edward AGAPOV (eap)
 // Module    : SMESH
-
+//
 #include "StdMeshers_FaceSide.hxx"
 
 #include "SMDS_EdgePosition.hxx"
@@ -34,7 +33,7 @@
 #include "SMESHDS_SubMesh.hxx"
 //#include "SMESH_Algo.hxx"
 #include "SMESH_Mesh.hxx"
-#include "SMESH_MeshEditor.hxx"
+#include "SMESH_MesherHelper.hxx"
 #include "SMESH_ComputeError.hxx"
 #include "SMESH_Block.hxx"
 
@@ -44,6 +43,7 @@
 #include <BRep_Builder.hxx>
 #include <BRep_Tool.hxx>
 #include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Wire.hxx>
@@ -216,9 +216,9 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool   isXConst,
 #ifdef _DEBUG_
         if ( normPar > 1 || normPar < 0) {
           dump("DEBUG");
-          cout << "WRONG normPar: "<<normPar<< " prevNormPar="<<prevNormPar
-               << " u="<<u << " myFirst[i]="<<myFirst[i]<< " myLast[i]="<<myLast[i]
-               << " paramSize="<<paramSize<<endl;
+          MESSAGE ( "WRONG normPar: "<<normPar<< " prevNormPar="<<prevNormPar
+                    << " u="<<u << " myFirst[i]="<<myFirst[i]<< " myLast[i]="<<myLast[i]
+                    << " paramSize="<<paramSize );
         }
 #endif
         u2node.insert( make_pair( normPar, node ));
@@ -250,10 +250,10 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool   isXConst,
 #ifdef _DEBUG_
         if ( EdgeIndex >= myEdge.size() ) {
           dump("DEBUG");
-          cout << "WRONg EdgeIndex " << 1+EdgeIndex
-               << " myNormPar.size()="<<myNormPar.size()
-               << " myNormPar["<< EdgeIndex<<"]="<< myNormPar[ EdgeIndex ]
-               << " uvPt.normParam="<<uvPt.normParam <<endl;
+          MESSAGE ( "WRONg EdgeIndex " << 1+EdgeIndex
+                    << " myNormPar.size()="<<myNormPar.size()
+                    << " myNormPar["<< EdgeIndex<<"]="<< myNormPar[ EdgeIndex ]
+                    << " uvPt.normParam="<<uvPt.normParam );
         }
 #endif
         paramSize = myNormPar[ EdgeIndex ] - prevNormPar;
@@ -381,26 +381,32 @@ void StdMeshers_FaceSide::Reverse()
 void StdMeshers_FaceSide::dump(const char* msg) const
 {
 #ifdef _DEBUG_
-  cout << endl;
-  if (msg) cout << msg <<endl;
-  cout<<"NB EDGES: "<< myEdge.size() <<endl;
-  cout << "nbPoints: "<<myNbPonits<<" vecSize: " << myPoints.size()<<" "<<myFalsePoints.size() <<endl;
+  if (msg) MESSAGE ( std::endl << msg );
+  MESSAGE_BEGIN ("NB EDGES: "<< myEdge.size() );
+  MESSAGE_ADD ( "nbPoints: "<<myNbPonits<<" vecSize: " << myPoints.size()<<" "<<myFalsePoints.size() );
   for ( int i=0; i<myEdge.size(); ++i)
   {
-    cout << "\t"<<i+1<<endl;
-    cout << "\tEDGE: ";
-    if (myEdge[i].IsNull())
-      cout<<"NULL"<<endl;
+    MESSAGE_ADD ( "\t"<<i+1 );
+    MESSAGE_ADD ( "\tEDGE: " );
+    if (myEdge[i].IsNull()) {
+      MESSAGE_ADD ( "NULL" );
+    }
     else {
       TopAbs::Print(myEdge[i].Orientation(),cout)<<" "<<myEdge[i].TShape().operator->()<<endl;
-      cout << "\tV1: " << TopExp::FirstVertex( myEdge[i], 1).TShape().operator->()
-           << "  V2: " << TopExp::LastVertex( myEdge[i], 1).TShape().operator->() << endl;
+      MESSAGE_ADD ( "\tV1: " << TopExp::FirstVertex( myEdge[i], 1).TShape().operator->()
+                 << "  V2: " << TopExp::LastVertex( myEdge[i], 1).TShape().operator->() );
     }
-    cout << "\tC2d: ";
-    if (myC2d[i].IsNull()) cout<<"NULL"<<endl;
-    else cout << myC2d[i].operator->()<<endl;
-    cout << "\tF: "<<myFirst[i]<< " L: "<< myLast[i]<<endl;
-    cout << "\tnormPar: "<<myNormPar[i]<<endl;
+    MESSAGE_ADD ( "\tC2d: ");
+    
+    if (myC2d[i].IsNull()) {
+      MESSAGE_ADD ( "NULL" );
+    }
+    else {
+      MESSAGE_ADD ( myC2d[i].operator->() );
+    }
+      
+    MESSAGE_ADD ( "\tF: "<<myFirst[i]<< " L: "<< myLast[i] );
+    MESSAGE_END ( "\tnormPar: "<<myNormPar[i]<<endl );
   }
 #endif
 }
@@ -505,12 +511,20 @@ TSideVector StdMeshers_FaceSide::GetFaceWires(const TopoDS_Face& theFace,
         return TSideVector(0);
       }
     }
+    // find out side orientation, which is important if there are several wires (PAL19080) 
+    bool isForward = true;
+    if ( nbWires > 1 ) {
+      TopExp_Explorer e( theFace, TopAbs_EDGE );
+      while ( ! e.Current().IsSame( wireEdges.back() ))
+        e.Next();
+      isForward = ( e.Current().Orientation() == wireEdges.back().Orientation() );
+    }
+
     StdMeshers_FaceSide* wire = new StdMeshers_FaceSide( theFace, wireEdges, &theMesh,
-                                                         true, theIgnoreMediumNodes);
+                                                         isForward, theIgnoreMediumNodes);
     wires[ iW ] = StdMeshers_FaceSidePtr( wire );
     from = to;
   }
   return wires;
 }
 
-