]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/NMTDS/NMTDS_Tools.cxx
Salome HOME
0021672: [CEA 565] Dump Study from script
[modules/geom.git] / src / NMTDS / NMTDS_Tools.cxx
index 8944fe5014cfaacae0aabb96fb5c33147d565ce2..f34ce68e5e9623069315365bff04bbf906ac8347 100644 (file)
@@ -1,29 +1,27 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+//
 // 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 
+// 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 
+//
+// 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 
+// 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
 //
-// File:       NMTDS_Tools.cxx
-// Created:    Tue Feb 20 14:57:28 2007
-// Author:     Peter KURNEV
-//             <pkv@irinox>
 
+// File:        NMTDS_Tools.cxx
+// Created:     Tue Feb 20 14:57:28 2007
+// Author:      Peter KURNEV
 
-#include <NMTDS_Tools.ixx>
+#include <NMTDS_Tools.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <gp_Pnt.hxx>
 #include <BRep_Tool.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <BRep_Builder.hxx>
 
-void CopySource(const TopoDS_Shape& aS, 
-               TopTools_IndexedDataMapOfShapeShape& aMapSS, 
-               TopoDS_Shape& aSC);
+void CopySource(const TopoDS_Shape& aS,
+                TopTools_IndexedDataMapOfShapeShape& aMapSS,
+                TopoDS_Shape& aSC);
 
 //=======================================================================
 //function : CopyShape
-//purpose  : 
+//purpose  :
 //=======================================================================
-  void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS, 
-                             TopoDS_Shape& aSC)
+  void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
+                              TopoDS_Shape& aSC)
 {
   TopTools_IndexedDataMapOfShapeShape aMapSS;
   //
@@ -50,25 +48,26 @@ void CopySource(const TopoDS_Shape& aS,
 }
 //=======================================================================
 //function : CopyShape
-//purpose  : 
+//purpose  :
 //=======================================================================
-  void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS, 
-                             TopoDS_Shape& aSC,
-                             TopTools_IndexedDataMapOfShapeShape& aMapSS)
+  void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS,
+                              TopoDS_Shape& aSC,
+                              TopTools_IndexedDataMapOfShapeShape& aMapSS)
 {
   CopySource(aS, aMapSS, aSC);
 }
 //=======================================================================
 //function : CopySource
-//purpose  : 
+//purpose  :
 //=======================================================================
-void CopySource(const TopoDS_Shape& aS, 
-               TopTools_IndexedDataMapOfShapeShape& aMapSS, 
-               TopoDS_Shape& aSC)
+void CopySource(const TopoDS_Shape& aS,
+                TopTools_IndexedDataMapOfShapeShape& aMapSS,
+                TopoDS_Shape& aSC)
 {
   Standard_Boolean bFree;
   TopAbs_ShapeEnum aT;
   TopoDS_Iterator aIt;
+  TopoDS_Shape aSF;
   BRep_Builder BB;
   //
   aT=aS.ShapeType();
@@ -85,13 +84,22 @@ void CopySource(const TopoDS_Shape& aS,
   //
   bFree=aSC.Free();
   aSC.Free(Standard_True);
-  aIt.Initialize(aS);
+  aSF=aS;
+  if (aT==TopAbs_EDGE){
+    TopAbs_Orientation aOr;
+    //
+    aOr=aS.Orientation();
+    if(aOr==TopAbs_INTERNAL) {
+      aSF.Orientation(TopAbs_FORWARD);
+    }
+  }
+  aIt.Initialize(aSF);
   for (; aIt.More();  aIt.Next()) {
     TopoDS_Shape aSCx;
     //
     const TopoDS_Shape& aSx=aIt.Value();
     //
-    CopySource (aSx, aMapSS, aSCx);  
+    CopySource (aSx, aMapSS, aSCx);
     //
     aSCx.Orientation(aSx.Orientation());
     BB.Add(aSC, aSCx);
@@ -100,10 +108,10 @@ void CopySource(const TopoDS_Shape& aS,
 }
 //=======================================================================
 // function: ComputeVV
-// purpose: 
+// purpose:
 //=======================================================================
-  Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1, 
-                                         const TopoDS_Vertex& aV2)
+  Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1,
+                                          const TopoDS_Vertex& aV2)
 {
   Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2;
   gp_Pnt aP1, aP2;
@@ -124,7 +132,7 @@ void CopySource(const TopoDS_Shape& aS,
 }
 //=======================================================================
 // function: HasBRep
-// purpose: 
+// purpose:
 //=======================================================================
   Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi)
 {
@@ -132,10 +140,10 @@ void CopySource(const TopoDS_Shape& aS,
 }
 //=======================================================================
 //function : TypeToInteger
-//purpose  : 
+//purpose  :
 //=======================================================================
   Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1,
-                                           const TopAbs_ShapeEnum aType2)
+                                            const TopAbs_ShapeEnum aType2)
 {
   Standard_Integer iRet, iT1, iT2, iX;
   //
@@ -169,5 +177,5 @@ void CopySource(const TopoDS_Shape& aS,
     default:
       break;
   }
-  return iRet; 
+  return iRet;
 }