Salome HOME
MPV: Merge V1_2d
[modules/geom.git] / src / PARTITION / Partition_Inter3d.cxx
index 7724b73f1a2a76103622ccc3030f36e346fbaa17..e9bf649ce6fb4d905706ac6a7c48b9fb7f460471 100644 (file)
@@ -67,7 +67,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>
@@ -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;