From a4bb1420ca9071f3b25c8d5968a4ab0ee734aa6d Mon Sep 17 00:00:00 2001 From: msv Date: Thu, 11 Dec 2014 16:42:45 +0300 Subject: [PATCH] 0025568: SIGSEGV in thrusections with edge without 3D curve -Set algorithm flag NotDone if there is a non-degenerated edge with absent 3D curve. -Check IsDone flag in thrusection command. -Add test case bugs/modalg_5/bug25568. Small correction of test case for issue CR25568 --- src/BRepFill/BRepFill_Generator.cxx | 14 +++++++++- .../BRepOffsetAPI_ThruSections.cxx | 25 ++++++++++++------ src/BRepTest/BRepTest_SweepCommands.cxx | 11 +++++--- tests/bugs/modalg_5/bug25568 | 26 +++++++++++++++++++ 4 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 tests/bugs/modalg_5/bug25568 diff --git a/src/BRepFill/BRepFill_Generator.cxx b/src/BRepFill/BRepFill_Generator.cxx index e919b39b52..989cd8be54 100644 --- a/src/BRepFill/BRepFill_Generator.cxx +++ b/src/BRepFill/BRepFill_Generator.cxx @@ -61,7 +61,7 @@ #include #include - +#include //======================================================================= @@ -96,6 +96,8 @@ Standard_Integer DetectKPart(const TopoDS_Edge& Edge1, } else { curv1 = BRep_Tool::Curve(Edge1, loc, first1, last1); + if (curv1.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); curv1 = Handle(Geom_Curve)::DownCast(curv1->Transformed(loc.Transformation())); ff = first1; @@ -161,6 +163,8 @@ Standard_Integer DetectKPart(const TopoDS_Edge& Edge1, } else { curv = BRep_Tool::Curve(Edge2, loc, first2, last2); + if (curv.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); curv = Handle(Geom_Curve)::DownCast(curv->Transformed(loc.Transformation())); ff = first2; @@ -339,6 +343,8 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2, } else { C1 = BRep_Tool::Curve(Edge1, loc, a1, b1); + if (C1.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); C1 = Handle(Geom_Curve)::DownCast(C1->Transformed(loc.Transformation())); aa = a1; bb = b1; @@ -362,6 +368,8 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2, } else { C2 = BRep_Tool::Curve(Edge2, loc, a1, b1); + if (C2.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); C2 = Handle(Geom_Curve)::DownCast(C2->Transformed(loc.Transformation())); if (Edge2.Orientation() == TopAbs_REVERSED) { C2->Reverse(); @@ -663,6 +671,8 @@ void BRepFill_Generator::Perform() } else { C1 = BRep_Tool::Curve(Edge1,L1,f1,l1); + if (C1.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); } if (degen2) { Extremities(1) = BRep_Tool::Pnt(V2l); @@ -671,6 +681,8 @@ void BRepFill_Generator::Perform() } else { C2 = BRep_Tool::Curve(Edge2,L2,f2,l2); + if (C2.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); } // compute the location diff --git a/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx b/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx index 29e3711049..be62e61aba 100644 --- a/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx +++ b/src/BRepOffsetAPI/BRepOffsetAPI_ThruSections.cxx @@ -96,6 +96,7 @@ #include #include +#include //======================================================================= @@ -391,18 +392,24 @@ void BRepOffsetAPI_ThruSections::Build() myWires = WorkingSections; } - // Calculate the resulting shape - if (myWires.Length() == 2 || myIsRuled) { - // create a ruled shell - CreateRuled(); + try { + // Calculate the resulting shape + if (myWires.Length() == 2 || myIsRuled) { + // create a ruled shell + CreateRuled(); + } + else { + // create a smoothed shell + CreateSmoothed(); + } } - else { - // create a smoothed shell - CreateSmoothed(); + catch (Standard_Failure) + { + NotDone(); + return; } // Encode the Regularities BRepLib::EncodeRegularity(myShape); - } @@ -882,6 +889,8 @@ static Handle(Geom_BSplineCurve) EdgeToBSpline (const TopoDS_Edge& theEdge) TopLoc_Location aLoc; Standard_Real aFirst, aLast; Handle(Geom_Curve) aCurve = BRep_Tool::Curve (theEdge, aLoc, aFirst, aLast); + if (aCurve.IsNull()) + Standard_NullObject::Raise("Null 3D curve in edge"); // convert its part used by edge to bspline; note that if edge curve is bspline, // conversion made via trimmed curve is still needed -- it will copy it, segment diff --git a/src/BRepTest/BRepTest_SweepCommands.cxx b/src/BRepTest/BRepTest_SweepCommands.cxx index 415384e1eb..ef1329cec5 100644 --- a/src/BRepTest/BRepTest_SweepCommands.cxx +++ b/src/BRepTest/BRepTest_SweepCommands.cxx @@ -408,10 +408,13 @@ Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char* Generator.Build(); - TopoDS_Shape Shell = Generator.Shape(); - - DBRep::Set(a[index-1], Shell); - + if (Generator.IsDone()) { + TopoDS_Shape Shell = Generator.Shape(); + DBRep::Set(a[index-1], Shell); + } + else { + cout << "Algorithm is not done" << endl; + } return 0; } diff --git a/tests/bugs/modalg_5/bug25568 b/tests/bugs/modalg_5/bug25568 new file mode 100644 index 0000000000..a80c98e13f --- /dev/null +++ b/tests/bugs/modalg_5/bug25568 @@ -0,0 +1,26 @@ +puts "============" +puts "OCC25568" +puts "============" +puts "" +######################################################################### +# SIGSEGV in thrusections with edge without 3D curve +######################################################################### + +restore [locate_data_file bug25568_loft-inv1-draw-Loft-00-section.brep] Loft-00-section +restore [locate_data_file bug25568_loft-inv1-draw-Loft-01-section.brep] Loft-01-section + +if [info exists result] {unset result} + +thrusections result 0 0 Loft-00-section Loft-01-section + +if ![isdraw result] { + if {[info commands fixshape] == ""} {pload XSDRAW} + fixshape Loft-00-section_fixed Loft-00-section + thrusections result 0 0 Loft-00-section_fixed Loft-01-section + if ![isdraw result] { + puts "Error : thrusection is failed even after fixing arguments" + } +} + +set square 25.236 +set 2dviewer 0 -- 2.20.1