From 679d4fa8caee120f69b8c76b3763e9d2c53e3900 Mon Sep 17 00:00:00 2001 From: ifv Date: Mon, 20 Jul 2015 14:07:11 +0300 Subject: [PATCH] 0026387: BRepPrimAPI_MakePrism crash when extruding Paraboloid face. Test-cases for issue #26387 --- src/BRepSweep/BRepSweep_Translation.cxx | 51 ++++++++++++++++++------- tests/bugs/modalg_6/bug26387 | 11 ++++++ 2 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 tests/bugs/modalg_6/bug26387 diff --git a/src/BRepSweep/BRepSweep_Translation.cxx b/src/BRepSweep/BRepSweep_Translation.cxx index d8eae8a1c1..7889dbbece 100644 --- a/src/BRepSweep/BRepSweep_Translation.cxx +++ b/src/BRepSweep/BRepSweep_Translation.cxx @@ -153,15 +153,27 @@ TopoDS_Shape BRepSweep_Translation::MakeEmptyGeneratingEdge //Call only in case of construction with copy. Standard_ConstructionError_Raise_if (!myCopy,"BRepSweep_Translation::MakeEmptyVertex"); - TopLoc_Location L; - Standard_Real First,Last; - Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(aGenE),L,First,Last); - C = Handle(Geom_Curve)::DownCast(C->Copy()); - C->Transform(L.Transformation()); - if (aDirV.Index() == 2) C->Transform(myLocation.Transformation()); TopoDS_Edge newE; - myBuilder.Builder().MakeEdge - (newE,C,BRep_Tool::Tolerance(TopoDS::Edge(aGenE))); + if(BRep_Tool::Degenerated(TopoDS::Edge(aGenE))) + { + myBuilder.Builder().MakeEdge(newE); + myBuilder.Builder().UpdateEdge(newE, BRep_Tool::Tolerance(TopoDS::Edge(aGenE))); + myBuilder.Builder().Degenerated(newE, Standard_True); + } + else + { + TopLoc_Location L; + Standard_Real First,Last; + Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(aGenE),L,First,Last); + if(!C.IsNull()) + { + C = Handle(Geom_Curve)::DownCast(C->Copy()); + C->Transform(L.Transformation()); + if (aDirV.Index() == 2) C->Transform(myLocation.Transformation()); + } + myBuilder.Builder().MakeEdge + (newE,C,BRep_Tool::Tolerance(TopoDS::Edge(aGenE))); + } return newE; } @@ -301,12 +313,23 @@ void BRepSweep_Translation::SetPCurve { //Set on edges of cap faces the same pcurves as //edges of the generating face. - Standard_Real First,Last; - myBuilder.Builder().UpdateEdge - (TopoDS::Edge(aNewEdge), - BRep_Tool::CurveOnSurface - (TopoDS::Edge(aGenE),TopoDS::Face(aGenF),First,Last), - TopoDS::Face(aNewFace),Precision::PConfusion()); + Standard_Boolean isclosed = BRep_Tool::IsClosed(TopoDS::Edge(aGenE), TopoDS::Face(aGenF)); + if(isclosed) + { + Standard_Real First, Last; + TopoDS_Edge anE = TopoDS::Edge(aGenE.Oriented(TopAbs_FORWARD)); + Handle(Geom2d_Curve) aC1 = BRep_Tool::CurveOnSurface(anE, TopoDS::Face(aGenF), First, Last); + anE.Reverse(); + Handle(Geom2d_Curve) aC2 = BRep_Tool::CurveOnSurface(anE, TopoDS::Face(aGenF), First, Last); + myBuilder.Builder().UpdateEdge(TopoDS::Edge(aNewEdge), aC1, aC2, TopoDS::Face(aNewFace),Precision::PConfusion()); + } + else + { + Standard_Real First,Last; + myBuilder.Builder().UpdateEdge(TopoDS::Edge(aNewEdge), + BRep_Tool::CurveOnSurface(TopoDS::Edge(aGenE),TopoDS::Face(aGenF),First,Last), + TopoDS::Face(aNewFace),Precision::PConfusion()); + } } diff --git a/tests/bugs/modalg_6/bug26387 b/tests/bugs/modalg_6/bug26387 new file mode 100644 index 0000000000..e8aa421ebf --- /dev/null +++ b/tests/bugs/modalg_6/bug26387 @@ -0,0 +1,11 @@ +puts "========" +puts "OCC26387" +puts "========" +puts "" +############################################################## +# BRepPrimAPI_MakePrism crash when extruding Paraboloid face +############################################################## + +restore [locate_data_file OCC26387-Paraboloid.brep] p +prism r p 0 0 5 c +checkshape r