0025175: avoid unsafe 3D curve usages
authordrazmyslovich <razmyslovich@volumegraphics.com>
Thu, 18 Sep 2014 11:53:05 +0000 (15:53 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 18 Sep 2014 11:54:42 +0000 (15:54 +0400)
Test case for issue CR25175

src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx
tests/bugs/modalg_5/bug25175 [new file with mode: 0644]

index fb26f0b..e2787e0 100644 (file)
@@ -1057,6 +1057,7 @@ void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequence
     TopLoc_Location loc;
     Standard_Real first, last;
     Handle(Geom_Curve) c3d = BRep_Tool::Curve(sec, loc, first, last);
+    if (c3d.IsNull()) continue;
     if (!loc.IsIdentity()) {
       c3d = Handle(Geom_Curve)::DownCast(c3d->Copy());
       c3d->Transform(loc.Transformation());
@@ -3604,15 +3605,16 @@ void BRepBuilderAPI_Sewing::Cutting(const Handle(Message_ProgressIndicator)& the
     const TopoDS_Edge& bound = TopoDS::Edge(myBoundFaces.FindKey(i));
     // Do not cut floating edges
     if (!myBoundFaces(i).Extent()) continue;
+    // Obtain bound curve
+    c3d = BRep_Tool::Curve(bound, loc, first, last);
+    if (c3d.IsNull()) continue;
+    if (!loc.IsIdentity()) {
+      c3d = Handle(Geom_Curve)::DownCast(c3d->Copy());
+      c3d->Transform(loc.Transformation());
+    }
     // Create cutting sections
     TopTools_ListOfShape listSections;
     { //szv: Use brackets to destroy local variables
-      // Obtain bound curve
-      c3d = BRep_Tool::Curve(bound, loc, first, last);
-      if (!loc.IsIdentity()) {
-        c3d = Handle(Geom_Curve)::DownCast(c3d->Copy());
-        c3d->Transform(loc.Transformation());
-      }
       // Obtain candidate vertices
       TopoDS_Vertex V1, V2;
       TopTools_IndexedMapOfShape CandidateVertices;
diff --git a/tests/bugs/modalg_5/bug25175 b/tests/bugs/modalg_5/bug25175
new file mode 100644 (file)
index 0000000..11473f4
--- /dev/null
@@ -0,0 +1,16 @@
+puts "============"
+puts "OCC25175"
+puts "============"
+puts ""
+###########################################################################
+# BRepBuilderAPI_Sewing can crash if an edge without 3D curve is presented
+###########################################################################
+
+pload XSDRAW
+
+igesread [locate_data_file bug25175_3.igs] a *
+
+sewing result 0.1 a
+
+set 2dviewer 1
+