]> OCCT Git - occt.git/commitdiff
0033306: Modeling Algorithm - Crash in TrimEdge() method IR-2023-01-13
authorakaftasev <akaftasev@opencascade.com>
Wed, 4 Jan 2023 11:47:00 +0000 (14:47 +0300)
committerVadim Glukhikh <vadim.glukhikh@opencascade.com>
Mon, 9 Jan 2023 21:44:11 +0000 (21:44 +0000)
Added condition to not cut the edges by closely located parameters

src/BRepFill/BRepFill_CompatibleWires.cxx
tests/bugs/modalg_8/bug33306 [new file with mode: 0644]

index bc80acbe44e9c014650049c387117cf864db6de2..0fbf3bd666ee14ccddf56ef780c9b30f6455870e 100644 (file)
@@ -351,6 +351,10 @@ static void TrimEdge (const TopoDS_Edge&              CurrentEdge,
     for (j=1; j<=ndec; j++) {
       // piece of edge  
       m1 = (CutValues.Value(j)-t0)*(last-first)/(t1-t0)+first;
+      if (Abs(m0 - m1) < Precision::Confusion())
+      {
+        return;
+      }
       TopoDS_Edge CutE = BRepLib_MakeEdge(C,V0,Vbid,m0,m1);
       CutE.Orientation(CurrentOrient);
       S.Append(CutE);
@@ -358,6 +362,10 @@ static void TrimEdge (const TopoDS_Edge&              CurrentEdge,
       V0 = TopExp::LastVertex(CutE);
       if (j==ndec) {
        // last piece
+        if (Abs(m0 - last) < Precision::Confusion())
+        {
+          return;
+        }
        TopoDS_Edge LastE = BRepLib_MakeEdge(C,V0,Vl,m0,last);
        LastE.Orientation(CurrentOrient);
        S.Append(LastE);
@@ -371,6 +379,10 @@ static void TrimEdge (const TopoDS_Edge&              CurrentEdge,
     for (j=ndec; j>=1; j--) {
       // piece of edge  
       m0 = (CutValues.Value(j)-t0)*(last-first)/(t1-t0)+first;
+      if (Abs(m0 - m1) < Precision::Confusion())
+      {
+        return;
+      }
       TopoDS_Edge CutE = BRepLib_MakeEdge(C,Vbid,V1,m0,m1);
       CutE.Orientation(CurrentOrient);
       S.Append(CutE);
@@ -378,6 +390,10 @@ static void TrimEdge (const TopoDS_Edge&              CurrentEdge,
       V1 = TopExp::FirstVertex(CutE);
       if (j==1) {
        // last piece
+        if (Abs(first - m1) < Precision::Confusion())
+        {
+          return;
+        }
        TopoDS_Edge LastE = BRepLib_MakeEdge(C,Vf,V1,first,m1);
        LastE.Orientation(CurrentOrient);
        S.Append(LastE);
@@ -547,6 +563,10 @@ static Standard_Boolean EdgeIntersectOnWire (const gp_Pnt& P1,
          SR.Clear();
          SR.Append(param);
          TrimEdge(E,SR,first,last,SO,SE);
+          if (SE.IsEmpty())
+          {
+            return Standard_False;
+          }
           theEdgeNewEdges(E) = SE;
          TopoDS_Vertex VV1,VV2;
          TopExp::Vertices(TopoDS::Edge(SE.Value(1)),VV1,VV2);
diff --git a/tests/bugs/modalg_8/bug33306 b/tests/bugs/modalg_8/bug33306
new file mode 100644 (file)
index 0000000..5021d51
--- /dev/null
@@ -0,0 +1,11 @@
+puts "REQUIRED ALL: Algorithm has failed"
+
+puts "========================"
+puts "0033306: Modeling Algorithm - Crash in TrimEdge() method"
+puts "========================"
+puts ""
+
+restore [locate_data_file bug33306_1.brep] w1
+restore [locate_data_file bug33306_2.brep] w2
+
+thrusections res 0 0 w1 w2