0028577: Get rid of the TopOpeBRep* algorithms in TKOffset toolkit
authoremv <emv@opencascade.com>
Tue, 21 Mar 2017 12:47:34 +0000 (15:47 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 23 Mar 2017 13:53:49 +0000 (16:53 +0300)
The TKOffset toolkit has been cleared from the usage of the obsolete TopOpeBRep* classes.

src/BRepLib/BRepLib_FuseEdges.cxx
src/BRepOffset/BRepOffset_Inter3d.cxx
src/BRepOffset/BRepOffset_Tool.cxx
src/BRepOffsetAPI/BRepOffsetAPI_DraftAngle.cxx

index 877111d..528eabd 100644 (file)
@@ -71,9 +71,6 @@
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 
-//#ifdef OCCT_DEBUG
-//Standard_IMPORT Standard_Boolean TopOpeBRepBuild_GettraceFE();
-//#endif
 static void BCSmoothing(Handle(Geom_BSplineCurve)& theC,
                        const Standard_Integer theCont,
                        const Standard_Real theTol)
@@ -366,11 +363,6 @@ TopoDS_Shape& BRepLib_FuseEdges::Shape()
 
 void BRepLib_FuseEdges::BuildListEdges()
 {
-
-//#ifdef OCCT_DEBUG
-  //Standard_Boolean tFE = TopOpeBRepBuild_GettraceFE();
-//#endif
-
   //--------------------------------------------------------
   // Step One : Build the map ancestors
   //--------------------------------------------------------
@@ -416,11 +408,6 @@ void BRepLib_FuseEdges::BuildListEdges()
 
 void BRepLib_FuseEdges::BuildListResultEdges()
 {
-
-//#ifdef OCCT_DEBUG
-  //Standard_Boolean tFE = TopOpeBRepBuild_GettraceFE();
-//#endif
-
   // if we have edges to fuse
   if (myMapLstEdg.Extent() > 0) {
     TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape itLstEdg;
@@ -545,11 +532,6 @@ void BRepLib_FuseEdges::BuildListResultEdges()
 
 void BRepLib_FuseEdges::Perform()
 {
-
-//#ifdef OCCT_DEBUG
-  //Standard_Boolean tFE = TopOpeBRepBuild_GettraceFE();
-//#endif
-
   if (!myResultEdgesDone) {
     BuildListResultEdges();
   }
@@ -803,9 +785,6 @@ Standard_Boolean BRepLib_FuseEdges::SameSupport(const TopoDS_Edge& E1,
       typC1 != STANDARD_TYPE(Geom_Ellipse) &&
       typC1 != STANDARD_TYPE(Geom_BSplineCurve) && 
       typC1 != STANDARD_TYPE(Geom_BezierCurve)) {
-#ifdef OCCT_DEBUG
-    cout << " TopOpeBRepTool_FuseEdge : Type de Support non traite" << endl;
-#endif
     return Standard_False;
   }
 
index d8de6e9..9296c52 100644 (file)
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
-#include <TopOpeBRepTool_BoxSort.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_MapIteratorOfMapOfShape.hxx>
 #include <TopTools_MapOfShape.hxx>
 //
+#include <BRepBndLib.hxx>
+#include <BOPCol_BoxBndTree.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+//
 #include <BOPTools_AlgoTools.hxx>
 
 //=======================================================================
@@ -160,40 +163,55 @@ void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
   // Calculate the intersections of offset faces 
   // Distinction of intersection between faces // tangents.
   //---------------------------------------------------------------
-  TopoDS_Face                        F2;
-  TopTools_ListIteratorOfListOfShape it;
 
-  //---------------------------------------------------------------
-  // Construction of bounding boxes
-  //---------------------------------------------------------------
-  TopOpeBRepTool_BoxSort BOS;
-  BRep_Builder B;
-  TopoDS_Compound CompOS;
-  B.MakeCompound(CompOS);
-  
-  for (it.Initialize(SetOfFaces); it.More(); it.Next()) {
-    const TopoDS_Shape& OS = it.Value();
-    B.Add(CompOS,OS);
+  // Prepare tools for sorting the bounding boxes
+  BOPCol_BoxBndTree aBBTree;
+  NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
+  //
+  NCollection_IndexedDataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher> aMFaces;
+  // Construct bounding boxes for faces and add them to the tree
+  TopTools_ListIteratorOfListOfShape aItL(SetOfFaces);
+  for (; aItL.More(); aItL.Next()) {
+    const TopoDS_Face& aF = TopoDS::Face(aItL.Value());
+    //
+    // compute bounding box
+    Bnd_Box aBoxF;
+    BRepBndLib::Add(aF, aBoxF);
+    //
+    Standard_Integer i = aMFaces.Add(aF, aBoxF);
+    //
+    aTreeFiller.Add(i, aBoxF);
   }
-  BOS.AddBoxesMakeCOB(CompOS,TopAbs_FACE);
-
-  //---------------------------
-  // Intersection of faces // 
-  //---------------------------
-  for (it.Initialize(SetOfFaces); it.More(); it.Next()) {
-    const TopoDS_Face& F1  = TopoDS::Face(it.Value());
-    TColStd_ListIteratorOfListOfInteger itLI = BOS.Compare(F1);
-    for (; itLI.More(); itLI.Next()) {
-      F2     = TopoDS::Face(BOS.TouchedShape(itLI));
-      FaceInter(F1,F2,InitOffsetFace);
+  //
+  // shake tree filler
+  aTreeFiller.Fill();
+  //
+  // get faces with interfering bounding boxes
+  aItL.Initialize(SetOfFaces);
+  for (; aItL.More(); aItL.Next()) {
+    const TopoDS_Face& aF1 = TopoDS::Face(aItL.Value());
+    const Bnd_Box& aBoxF1 = aMFaces.FindFromKey(aF1);
+    //
+    BOPCol_BoxBndTreeSelector aSelector;
+    aSelector.SetBox(aBoxF1);
+    aBBTree.Select(aSelector);
+    //
+    const BOPCol_ListOfInteger& aLI = aSelector.Indices();
+    BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
+    for (; aItLI.More(); aItLI.Next()) {
+      Standard_Integer i = aItLI.Value();
+      const TopoDS_Face& aF2 = TopoDS::Face(aMFaces.FindKey(i));
+      //
+      // intersect faces
+      FaceInter(aF1, aF2, InitOffsetFace);
     }
   }
 }
 
 
 //=======================================================================
-//function : CompletInt
-//purpose  : 
+//function : FaceInter
+//purpose  : Performs intersection of the given faces
 //=======================================================================
 
 void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
index e7488cd..8122387 100644 (file)
@@ -24,6 +24,7 @@
 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
 #include <BRep_TEdge.hxx>
 #include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <BRepAdaptor_Curve2d.hxx>
 #include <BRepAdaptor_HCurve.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Wire.hxx>
-#include <TopOpeBRep_DSFiller.hxx>
-#include <TopOpeBRep_FacesFiller.hxx>
-#include <TopOpeBRep_GeomTool.hxx>
-#include <TopOpeBRep_ShapeIntersector.hxx>
-#include <TopOpeBRepBuild_Builder.hxx>
-#include <TopOpeBRepDS_CurveExplorer.hxx>
-#include <TopOpeBRepDS_HDataStructure.hxx>
-#include <TopOpeBRepTool_GeomTool.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
index bac073c..c3425a8 100644 (file)
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Wire.hxx>
-#include <TopOpeBRep_EdgesIntersector.hxx>
-#include <TopOpeBRep_Point2d.hxx>
 #include <TopTools_DataMapOfShapeSequenceOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TopTools_SequenceOfShape.hxx>
 
+#include <Geom2dInt_GInter.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+
 //=======================================================================
 //function : BRepOffsetAPI_DraftAngle
 //purpose  : 
@@ -365,6 +366,19 @@ void BRepOffsetAPI_DraftAngle::CorrectWires()
     CurEdge = Eseq(i);
     CurWire = Wseq(i);
     CurFace = Fseq(i);
+    //
+    const TopoDS_Face& aFace = TopoDS::Face(CurFace);
+    //
+    // Prepare 2D adaptors for intersection.
+    // The seam edge has two 2D curve, thus we have to create 2 adaptors
+    BRepAdaptor_Curve2d aBAC2D1(TopoDS::Edge(CurEdge), aFace);
+    BRepAdaptor_Curve2d aBAC2D1R(TopoDS::Edge(CurEdge.Reversed()), aFace);
+    // Get surface of the face to get 3D intersection point
+    TopLoc_Location aLoc;
+    const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(aFace, aLoc);
+    // Get the tolerance of the current edge to compare intersection points
+    Standard_Real aTolCurE = BRep_Tool::Tolerance(TopoDS::Edge(CurEdge));
+    //
     wit.Initialize( CurFace );
     for (; wit.More(); wit.Next())
     {
@@ -372,102 +386,83 @@ void BRepOffsetAPI_DraftAngle::CorrectWires()
       if (! aWire.IsSame( CurWire ))
       {
         TColgp_SequenceOfPnt pts;
-        TopTools_SequenceOfShape edges;
-        TColStd_SequenceOfReal pars;
         Standard_Boolean Wadd = Standard_False;
         eit.Initialize( aWire );
         for (; eit.More(); eit.Next())
         {
-          TopoDS_Shape anEdge = eit.Value();
-          TopOpeBRep_EdgesIntersector EInter;
-          EInter.SetFaces( CurFace, CurFace );
-          EInter.ForceTolerances( TolInter, TolInter );
-          EInter.Perform( CurEdge, anEdge );
-          if (EInter.IsEmpty())
-          {
-            EInter.Perform( CurEdge.Reversed(), anEdge );
-            if (EInter.IsEmpty())
+          const TopoDS_Edge& anEdge = TopoDS::Edge(eit.Value());
+          //
+          // Prepare 2D adaptor for intersection
+          BRepAdaptor_Curve2d aBAC2D2(anEdge, aFace);
+          // Perform intersection
+          Geom2dInt_GInter aGInter;
+          aGInter.Perform(aBAC2D1, aBAC2D2, TolInter, TolInter);
+          if (!aGInter.IsDone() || aGInter.IsEmpty()) {
+            // If first intersection is empty try intersection with reversed edge
+            aGInter.Perform(aBAC2D1R, aBAC2D2, TolInter, TolInter);
+            if (!aGInter.IsDone() || aGInter.IsEmpty()) {
               continue;
+            }
           }
+          //
           Wadd = Standard_True;
           if (! WFmap.IsBound( aWire ))
             WFmap.Bind( aWire, CurFace );
           Standard_Integer ind = 0;
-          for (j = 1; j <= NonSeam.Length(); j++)
-            if (anEdge.IsSame( NonSeam(j) ))
+          for (j = 1; j <= NonSeam.Length(); j++) {
+            if (anEdge.IsSame(NonSeam(j)))
             {
               ind = j;
               break;
             }
-            if (ind == 0)
-            {
-              NonSeam.Append( anEdge );
-              NonSeamWires.Append( aWire );
-              ind = NonSeam.Length();
-              TColStd_SequenceOfReal emptyseq1, emptyseq2;
-              TopTools_SequenceOfShape emptyedgeseq;
-              ParsNonSeam.Append( emptyseq1 );
-              Seam.Append( emptyedgeseq );
-              ParsSeam.Append( emptyseq2 );
+          }
+          if (ind == 0)
+          {
+            NonSeam.Append(anEdge);
+            NonSeamWires.Append(aWire);
+            ind = NonSeam.Length();
+            TColStd_SequenceOfReal emptyseq1, emptyseq2;
+            TopTools_SequenceOfShape emptyedgeseq;
+            ParsNonSeam.Append(emptyseq1);
+            Seam.Append(emptyedgeseq);
+            ParsSeam.Append(emptyseq2);
+          }
+          if (!Emap.IsBound(CurEdge))
+          {
+            TColStd_SequenceOfReal emptyseq;
+            Emap.Bind(CurEdge, emptyseq);
+          }
+          //
+          // Get the tolerance of edge to compare intersection points
+          Standard_Real aTolE = BRep_Tool::Tolerance(anEdge);
+          // Tolerance to compare the intersection points is the maximal
+          // tolerance of intersecting edges
+          Standard_Real aTolCmp = Max(aTolCurE, aTolE);
+          //
+          Standard_Integer k, aNbIntPnt = aGInter.NbPoints();
+          for (k = 1; k <= aNbIntPnt; ++k) {
+            const IntRes2d_IntersectionPoint& aP2DInt = aGInter.Point(k);
+            const gp_Pnt2d& aP2D = aP2DInt.Value();
+            gp_Pnt aP3D = aSurf->Value(aP2D.X(), aP2D.Y());
+            //
+            // Check if the intersection point is new
+            Standard_Integer ied = 0;
+            for (j = 1; j <= pts.Length(); j++) {
+              if (aP3D.IsEqual(pts(j), aTolCmp))
+              {
+                ied = j;
+                break;
+              }
             }
-            if (! Emap.IsBound( CurEdge ))
+            if (ied == 0)
             {
-              TColStd_SequenceOfReal emptyseq;
-              Emap.Bind( CurEdge, emptyseq );
+              pts.Append(aP3D);
+              Emap(CurEdge).Append(aP2DInt.ParamOnFirst());
+              ParsNonSeam(ind).Append(aP2DInt.ParamOnSecond());
+              Seam(ind).Append(CurEdge);
+              ParsSeam(ind).Append(aP2DInt.ParamOnFirst());
             }
-            EInter.InitPoint();
-            for (; EInter.MorePoint(); EInter.NextPoint())
-            {
-              const TopOpeBRep_Point2d& bp = EInter.Point();
-              if (bp.IsVertex(2))
-              {
-                gp_Pnt Pnt = bp.Value();
-                Standard_Integer ied = 0;
-                for (j = 1; j <= pts.Length(); j++)
-                  if (Pnt.IsEqual( pts(j), Precision::Confusion() ))
-                  {
-                    ied = j;
-                    break;
-                  }
-                  if (ied == 0)
-                  {
-                    pts.Append( Pnt );
-                    edges.Append( anEdge );
-                    pars.Append( bp.Parameter(2) );
-                    Emap(CurEdge).Append( bp.Parameter(1) );
-                    ParsNonSeam(ind).Append( bp.Parameter(2) );
-                    Seam(ind).Append( CurEdge );
-                    ParsSeam(ind).Append( bp.Parameter(1) );
-                  }
-                  /*
-                  else
-                  {
-                  Standard_Real ParOnSeam = bp.Parameter(1);
-                  Standard_Real Par1 = pars(ied);
-                  Standard_Real Par2 = bp.Parameter(2);
-                  BRepAdaptor_Curve2d SeamCurve( CurEdge, CurFace );
-                  BRepAdaptor_Curve2d Curve1( edges(ied), CurFace );
-                  BRepAdaptor_Curve2d Curve2( anEdge. CurFace );
-                  gp_Pnt2d P2d;
-                  gp_Vec2d SeamDer, Der1, Der2;
-                  //SeamCurve->D1( ParOnSeam, P2d, SeamDer );
-                  //Curve1->D1( Par1, P2d, Der1 );
-                  //Curve2->D1( Par2, P2d, Der2 );
-                  Standard_Real Crossed1 = SeamDer ^ Der1;
-                  Standard_Real Crossed2 = SeamDer ^ Der2;
-                  //if (Crossed1 > 0
-                  }
-                  */
-              }
-              else // ! bp.IsVertex(2)
-              {
-                //Temporary the case of tangency is not implemented
-                Emap(CurEdge).Append( bp.Parameter(1) );
-                ParsNonSeam(ind).Append( bp.Parameter(2) );
-                Seam(ind).Append( CurEdge );
-                ParsSeam(ind).Append( bp.Parameter(1) );
-              }
-            } //for (; EInter.MorePoint(); EInter.NextPoint())
+          }
         } //for (; eit.More(); eit.Next())
         if (Wadd)
         {