0031496: Modeling Algorithms - BRepAlgo::ConcatenateWireC0() crashes
authorifv <ifv@opencascade.com>
Mon, 13 Apr 2020 11:34:12 +0000 (14:34 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 16 Apr 2020 06:59:25 +0000 (09:59 +0300)
BRepAlgo.cxx: fixing of wrong treatment of reversed edges
bug31496: test case added

src/BRepAlgo/BRepAlgo.cxx
tests/bugs/modalg_7/bug31496 [new file with mode: 0644]

index 40a6277..db36f5b 100644 (file)
@@ -421,9 +421,18 @@ TopoDS_Edge  BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire)
     isReverse = !IsFwdSeq(1);
   }
 
-  TopoDS_Vertex FirstVtx_final = FirstVertex;
+  TopoDS_Vertex FirstVtx_final, LastVtx_final;
+  if (isReverse)
+  {
+    FirstVtx_final = LastVertex;
+    LastVtx_final = FirstVertex;
+  }
+  else
+  {
+    FirstVtx_final = FirstVertex;
+    LastVtx_final = LastVertex;
+  }
   FirstVtx_final.Orientation(TopAbs_FORWARD);
-  TopoDS_Vertex LastVtx_final = LastVertex;
   LastVtx_final.Orientation(TopAbs_REVERSED);
 
   if (CurveSeq.IsEmpty())
@@ -497,6 +506,9 @@ TopoDS_Edge  BRepAlgo::ConcatenateWireC0(const TopoDS_Wire& aWire)
       concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve());
     }
 
+    if (isReverse) {
+      concatcurve->ChangeValue(concatcurve->Lower())->Reverse();
+    }
     ResEdge = BRepLib_MakeEdge(concatcurve->Value(concatcurve->Lower()),
       FirstVtx_final, LastVtx_final,
       concatcurve->Value(concatcurve->Lower())->FirstParameter(),
diff --git a/tests/bugs/modalg_7/bug31496 b/tests/bugs/modalg_7/bug31496
new file mode 100644 (file)
index 0000000..4d59ba8
--- /dev/null
@@ -0,0 +1,17 @@
+puts "==================================================="
+puts "0031496: Modeling Algorithms - BRepAlgo::ConcatenateWireC0() crashes"
+puts "==================================================="
+vertex v1 0 0 0
+vertex v2 1 0 0
+vertex v3 2 0 0
+vertex v4 3 0 0
+edge e1 v1 v2
+edge e2 v2 v3
+edge e3 v3 v4
+wire w e1 e2 e3
+invert w
+concatC0wire e w
+checknbshapes e -vertex 2 -edge 1
+nurbsconvert w w
+concatC0wire e w
+checknbshapes e -vertex 2 -edge 1