0026701: BOPAlgo_Builder::Perform crash.
authorisn <isn@opencascade.com>
Thu, 24 Sep 2015 10:46:45 +0000 (13:46 +0300)
committerkgv <kgv@opencascade.com>
Thu, 24 Sep 2015 11:14:47 +0000 (14:14 +0300)
(data race)

Add comments and make minor cosmetic changes.

Test case for issue CR26701

Correction of test case for issue CR26701

src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx
src/BOPTools/BOPTools_AlgoTools2D.cxx
src/BOPTools/BOPTools_AlgoTools2D.hxx
tests/bugs/modalg_6/bug26701 [new file with mode: 0755]

index 8bc56b9..1ecde6d 100644 (file)
@@ -287,13 +287,28 @@ class BOPAlgo_BPC {
     myE=aE;
   }
   //
     myE=aE;
   }
   //
+  const TopoDS_Edge& GetEdge() const {
+    return myE;
+  }
+  const TopoDS_Face& GetFace() const {
+    return myF;
+  }
+  const Handle_Geom2d_Curve& GetCurve2d() const {
+    return myCurve;
+  }
+  Standard_Boolean IsToUpdate() const {
+    return myToUpdate;
+  }
+  //
   void Perform() {
   void Perform() {
-    BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (myE, myF);
+    BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (myE, myF, myCurve, myToUpdate);
   };
   //
  protected:
   TopoDS_Edge myE;
   TopoDS_Face myF;
   };
   //
  protected:
   TopoDS_Edge myE;
   TopoDS_Face myF;
+  Handle_Geom2d_Curve myCurve;
+  Standard_Boolean myToUpdate;
 };
 //=======================================================================
 typedef BOPCol_NCVector
 };
 //=======================================================================
 typedef BOPCol_NCVector
@@ -731,6 +746,7 @@ void BOPAlgo_PaveFiller::Prepare()
     return;
   }
   //
     return;
   }
   //
+  // Build pcurves of edges on planes; first collect pairs edge-face.
   BOPAlgo_VectorOfBPC aVBPC;
   //
   for (i = 1; i <= aNbF; ++i) {
   BOPAlgo_VectorOfBPC aVBPC;
   //
   for (i = 1; i <= aNbF; ++i) {
@@ -747,6 +763,17 @@ void BOPAlgo_PaveFiller::Prepare()
   //======================================================
   BOPAlgo_BPCCnt::Perform(myRunParallel, aVBPC);
   //======================================================
   //======================================================
   BOPAlgo_BPCCnt::Perform(myRunParallel, aVBPC);
   //======================================================
+
+  // pcurves are built, and now update edges
+  BRep_Builder aBB;
+  TopoDS_Edge E;
+  for (i = 0; i < aVBPC.Extent(); i++) {
+    const BOPAlgo_BPC& aBPC=aVBPC(i);
+    if (aBPC.IsToUpdate()) {
+      Standard_Real aTolE = BRep_Tool::Tolerance(aBPC.GetEdge());
+      aBB.UpdateEdge(aBPC.GetEdge(), aBPC.GetCurve2d(), aBPC.GetFace(), aTolE);
+    }
+  }
 }
 //=======================================================================
 //function : IsBasedOnPlane
 }
 //=======================================================================
 //function : IsBasedOnPlane
index 4e54d58..9af14ea 100644 (file)
@@ -494,6 +494,21 @@ void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane
     aBB.UpdateEdge(aE, aC2D, aF, aTolE);
   }
 }
     aBB.UpdateEdge(aE, aC2D, aF, aTolE);
   }
 }
+
+//=======================================================================
+//function : BuildPCurveForEdgeOnPlane
+//purpose  : 
+//=======================================================================
+void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane 
+  (const TopoDS_Edge& aE,
+   const TopoDS_Face& aF,
+   Handle(Geom2d_Curve)& aC2D,
+   Standard_Boolean& bToUpdate)
+{
+  Standard_Real aT1, aT2;
+  aC2D=BRep_Tool_CurveOnSurface(aE, aF, aT1, aT2, bToUpdate);
+}
+
 //=======================================================================
 // function: BuildPCurveForEdgesOnPlane
 // purpose: 
 //=======================================================================
 // function: BuildPCurveForEdgesOnPlane
 // purpose: 
index b3e2599..eb3f602 100644 (file)
@@ -112,8 +112,14 @@ public:
   //! Compute intermediate value of parameter for the edge <anE>.
   Standard_EXPORT static Standard_Real IntermediatePoint (const TopoDS_Edge& anE);
   
   //! Compute intermediate value of parameter for the edge <anE>.
   Standard_EXPORT static Standard_Real IntermediatePoint (const TopoDS_Edge& anE);
   
+  //! Build pcurve of edge on face if the surface is plane, and update the edge.
   Standard_EXPORT static void BuildPCurveForEdgeOnPlane (const TopoDS_Edge& theE, const TopoDS_Face& theF);
   
   Standard_EXPORT static void BuildPCurveForEdgeOnPlane (const TopoDS_Edge& theE, const TopoDS_Face& theF);
   
+  //! Build pcurve of edge on face if the surface is plane, but do not update the edge.
+  //! The output are the pcurve and the flag telling that pcurve was built.
+  Standard_EXPORT static void BuildPCurveForEdgeOnPlane (const TopoDS_Edge& theE, const TopoDS_Face& theF,
+                                                         Handle(Geom2d_Curve)& aC2D, Standard_Boolean& bToUpdate);
+
   Standard_EXPORT static void BuildPCurveForEdgesOnPlane (const BOPCol_ListOfShape& theLE, const TopoDS_Face& theF);
   
 
   Standard_EXPORT static void BuildPCurveForEdgesOnPlane (const BOPCol_ListOfShape& theLE, const TopoDS_Face& theF);
   
 
diff --git a/tests/bugs/modalg_6/bug26701 b/tests/bugs/modalg_6/bug26701
new file mode 100755 (executable)
index 0000000..fee984d
--- /dev/null
@@ -0,0 +1,35 @@
+puts "============"
+puts "OCC26701"
+puts "============"
+puts ""
+###############################
+## BOPAlgo_Builder::Perform crash.
+###############################
+
+restore [locate_data_file bug26701_crash_tbb.brep] d
+
+brunparallel 1
+
+bclearobjects
+eval baddobjects [explode d]
+
+bfillds
+bbuild result
+
+set square 8244.36
+
+set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 19252
+ EDGE      : 19264
+ WIRE      : 4824
+ FACE      : 1620
+ SHELL     : 1600
+ SOLID     : 0
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 46561
+"
+checknbshapes result -ref ${nbshapes_expected} -t -m "result obtained by Common operator"
+
+set 3dviewer 1