From 1f0adf314da249c99036d827aed189c49970e31e Mon Sep 17 00:00:00 2001 From: nbv Date: Thu, 17 Sep 2015 13:52:17 +0300 Subject: [PATCH] 0026687: SIGSEGV in BRepBuilderAPI_MakeFace 1. Check face location has been added. 2. Message, if mkplane command fails, has been added. 3. Test case for this issue has been created. Changes in accordance with the remark. Small correction of test case for issue CR26687 --- src/BRepLib/BRepLib_FindSurface.cxx | 3 ++- src/BRepTest/BRepTest_SurfaceCommands.cxx | 27 ++++++++++++++++++++--- tests/bugs/modalg_6/bug26687 | 21 ++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100755 tests/bugs/modalg_6/bug26687 diff --git a/src/BRepLib/BRepLib_FindSurface.cxx b/src/BRepLib/BRepLib_FindSurface.cxx index fa2f648102..b01ac1b9f2 100644 --- a/src/BRepLib/BRepLib_FindSurface.cxx +++ b/src/BRepLib/BRepLib_FindSurface.cxx @@ -118,6 +118,7 @@ static Standard_Boolean Is2DClosed(const TopoDS_Shape& theShape, { try { + OCC_CATCH_SIGNALS // get a wire theShape TopExp_Explorer aWireExp( theShape, TopAbs_WIRE ); if ( !aWireExp.More() ) { @@ -225,7 +226,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S, if (SS.IsNull()) { break; } - if (SS == mySurface) { + if ((SS == mySurface) && (L.IsEqual(myLocation))) { break; } SS.Nullify(); diff --git a/src/BRepTest/BRepTest_SurfaceCommands.cxx b/src/BRepTest/BRepTest_SurfaceCommands.cxx index 72ec47096c..d3efa41d21 100644 --- a/src/BRepTest/BRepTest_SurfaceCommands.cxx +++ b/src/BRepTest/BRepTest_SurfaceCommands.cxx @@ -180,7 +180,7 @@ static Standard_Integer mksurface(Draw_Interpretor& , Standard_Integer n, const // mkplane //======================================================================= -static Standard_Integer mkplane(Draw_Interpretor& , Standard_Integer n, const char** a) +static Standard_Integer mkplane(Draw_Interpretor& theDI, Standard_Integer n, const char** a) { if (n < 3) return 1; @@ -192,9 +192,30 @@ static Standard_Integer mkplane(Draw_Interpretor& , Standard_Integer n, const ch OnlyPlane = !strcmp(a[3],"1"); } - TopoDS_Face F = BRepBuilderAPI_MakeFace(TopoDS::Wire(S), OnlyPlane); + BRepBuilderAPI_MakeFace aMF(TopoDS::Wire(S), OnlyPlane); + + switch(aMF.Error()) + { + case BRepBuilderAPI_FaceDone: + DBRep::Set(a[1],aMF.Face()); + break; + case BRepLib_NoFace: + theDI << "Error. mkplane has been finished with \"No Face\" status.\n"; + break; + case BRepLib_NotPlanar: + theDI << "Error. mkplane has been finished with \"Not Planar\" status.\n"; + break; + case BRepLib_CurveProjectionFailed: + theDI << "Error. mkplane has been finished with \"Fail in projection curve\" status.\n"; + break; + case BRepLib_ParametersOutOfRange: + theDI << "Error. mkplane has been finished with \"Parameters are out of range\" status.\n"; + break; + default: + theDI << "Error. Undefined status. Please check the code.\n"; + break; + } - DBRep::Set(a[1],F); return 0; } diff --git a/tests/bugs/modalg_6/bug26687 b/tests/bugs/modalg_6/bug26687 new file mode 100755 index 0000000000..059f001107 --- /dev/null +++ b/tests/bugs/modalg_6/bug26687 @@ -0,0 +1,21 @@ +puts "REQUIRED: Error. mkplane has been finished with \"Not Planar\" status." + +puts "========" +puts "OCC26687" +puts "========" +puts "" +################################################# +# 0026687: SIGSEGV in BRepBuilderAPI_MakeFace +################################################# + +restore [locate_data_file bug26687_w.brep] w + +#It is impossible to create a plane there is no any surface +#which every edge has its p-cuve in. + +mkplane f w + +smallview +donly f +fit +xwd ${imagedir}/${test_image}.png -- 2.20.1