Salome HOME
Update copyright information
[modules/geom.git] / src / PARTITION / Partition_Inter3d.cxx
index 7724b73f1a2a76103622ccc3030f36e346fbaa17..87de801359b9aeb93a0896dd5e2e2ed5ad3440c6 100644 (file)
@@ -1,32 +1,30 @@
-//  GEOM PARTITION : partition algorithm
+//  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
+//
+//  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.
 //
-//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  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
 //
+//  GEOM PARTITION : partition algorithm
 //  File   : Partition_Inter3d.cxx
 //  Author : Benedicte MARTIN
 //  Module : GEOM
 //  $Header$
-
-using namespace std;
+//
 #include "Partition_Inter2d.hxx"
 #include "Partition_Inter3d.ixx"
 #include "utilities.h"
@@ -67,7 +65,6 @@ using namespace std;
 #include <Geom_RectangularTrimmedSurface.hxx>
 #include <Geom_SphericalSurface.hxx>
 #include <Geom_Surface.hxx>
-#include <Geom_ToroidalSurface.hxx>
 #include <Geom_TrimmedCurve.hxx>
 #include <Precision.hxx>
 #include <TColStd_MapOfInteger.hxx>
@@ -85,6 +82,8 @@ using namespace std;
 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
 #include <stdio.h>
 
+using namespace std;
+
 //=======================================================================
 //function : Partition_Inter3d
 //purpose  : 
@@ -136,10 +135,10 @@ void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,
     // avoid intersecting faces of one shape
     TopoDS_Shape S1;
     if (FaceShapeMap.IsBound(F1)) S1 = FaceShapeMap.Find(F1);
-    // avoid intersecting faces sharing vertices, suppose they belong to
-    // shapes sharing same faces
-    TopTools_IndexedMapOfShape VM;
-    TopExp::MapShapes( F1, TopAbs_VERTEX, VM);
+
+    // to filter faces sharing an edge
+    TopTools_IndexedMapOfShape EM;
+    TopExp::MapShapes( F1, TopAbs_EDGE, EM);
     
     TColStd_ListIteratorOfListOfInteger itLI = BOS.Compare(F1);
     for (; itLI.More(); itLI.Next()) {
@@ -152,13 +151,22 @@ void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,
       if (!S1.IsNull() && S1.IsSame(S2))
        continue; // descendants of one shape
 
-      TopExp_Explorer expV (F2, TopAbs_VERTEX);
-      for ( ; expV.More(); expV.Next())
-       if (VM.Contains( expV.Current() ))
+      TopExp_Explorer expE (F2, TopAbs_EDGE);
+      for ( ; expE.More(); expE.Next())
+       if (EM.Contains( expE.Current() ))
          break;
-      if (expV.More())
-       continue; // faces have a common edge
-      
+      if (expE.More())
+      {
+        // faces have a common edge, check if they are a tool and a face
+        // generated by the tool in another shape; in that case they are
+        // to be intersected
+        TopLoc_Location L1, L2;
+        Handle(Geom_Surface) S1 = BRep_Tool::Surface( F1, L1 );
+        Handle(Geom_Surface) S2 = BRep_Tool::Surface( F2, L2 );
+        if ( S1 != S2 || L1 != L2 )
+          continue;
+      }
+
       F1.Orientation(TopAbs_FORWARD);
       F2.Orientation(TopAbs_FORWARD);
       FacesPartition(F1,F2);     
@@ -210,8 +218,7 @@ static void PutInBounds (const TopoDS_Face&          F,
   // UPeriodic, sometimes it is in domain but nontheless it has
   // wrong position.
   // Check pcurve position by 3D point
-  if (S->IsKind(STANDARD_TYPE( Geom_SphericalSurface )) ||
-      S->IsKind(STANDARD_TYPE( Geom_ToroidalSurface )))
+  if (S->IsKind(STANDARD_TYPE( Geom_SphericalSurface )))
   {
     // get point on the surface
     gp_Pnt Ps = S->Value( Pm.X(), Pm.Y() );
@@ -472,11 +479,17 @@ void Partition_Inter3d::Inter3D(const TopoDS_Face& F1,
 
     TopoDS_Edge se = TopoDS::Edge( itLSE.Value() );
 
+    // move itLSE to the next se
     Standard_Integer ancRank = DS.AncestorRank(se);
     if (ME[ancRank-1].Contains( se ))
+    {
       LSE.Remove( itLSE ); // se is an edge of face it intersects
+      continue;
+    }
     else
+    {
       itLSE.Next();
+    }
 
     const TopoDS_Face& F = (ancRank == 1) ? F2 : F1;