From 056072196c8dba36603cd34346a8da924c503629 Mon Sep 17 00:00:00 2001 From: ema Date: Fri, 8 Jul 2016 14:01:12 +0300 Subject: [PATCH] 0026270: GeomFill_NSections constructor crash Correction of code to avoid of usage of undefined associated parameters in order not to get exception in constructor. Creation of test case for this issue --- src/GeomFill/GeomFill_NSections.cxx | 20 +++++++---- src/QABugs/QABugs_20.cxx | 55 +++++++++++++++++++++++++++++ tests/bugs/modalg_6/bug26270 | 10 ++++++ 3 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 tests/bugs/modalg_6/bug26270 diff --git a/src/GeomFill/GeomFill_NSections.cxx b/src/GeomFill/GeomFill_NSections.cxx index 778f14cda4..1a85a22169 100644 --- a/src/GeomFill/GeomFill_NSections.cxx +++ b/src/GeomFill/GeomFill_NSections.cxx @@ -208,6 +208,10 @@ static void ResultEval(const Handle(Geom_BSplineSurface)& surf, GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC) { mySections = NC; + UFirst = 0.; + ULast = 1.; + VFirst = 0.; + VLast = 1.; myRefSurf.Nullify(); ComputeSurface(); } @@ -565,16 +569,20 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC, Standard_Integer Nbcurves = mySections.Length(); Standard_Integer Nbpar = myParams.Length(); - Handle(TColStd_HArray1OfReal) HPar - = new TColStd_HArray1OfReal(1,Nbpar); - for (i=1;i<=Nbpar;i++) { - HPar->SetValue(i,myParams(i)); + if (Nbpar > 0) + { + Handle(TColStd_HArray1OfReal) HPar + = new TColStd_HArray1OfReal(1, Nbpar); + for (i = 1; i <= Nbpar; i++) { + HPar->SetValue(i, myParams(i)); + } + section.SetParam(HPar); } - section.SetParam(HPar); section.Perform(Precision::PConfusion()); + Handle(GeomFill_Line) line = new GeomFill_Line(Nbcurves); Standard_Integer nbIt = 0, degmin = 2, degmax = 6; - Standard_Boolean knownP = Standard_True; + Standard_Boolean knownP = Nbpar > 0; GeomFill_AppSurf anApprox(degmin, degmax, myPres3d, myPres3d, nbIt, knownP); Standard_Boolean SpApprox = Standard_True; anApprox.Perform(line, section, SpApprox); diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index bf4fba6549..2f9ce9617c 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -2025,6 +2025,60 @@ static Standard_Integer OCC27357(Draw_Interpretor& theDI, } return 0; } +#include +#include +#include +#include +#include +#include +//======================================================================= +//function : OCC26270 +//purpose : +//======================================================================= +static Standard_Integer OCC26270(Draw_Interpretor& theDI, + Standard_Integer theNArg, + const char **theArgVal) +{ + if (theNArg != 3) + { + theDI << "Usage :" << theArgVal[0] << " shape result\n"; + return 0; + } + TopoDS_Shape aShape = DBRep::Get(theArgVal[1]); + TopExp_Explorer anExp(aShape, TopAbs_EDGE); + TColGeom_SequenceOfCurve aCurveSeq; + for (; anExp.More(); anExp.Next()) + { + Standard_Real f, l; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(anExp.Current()), f, l); + if (!aCurve.IsNull()) + { + aCurve = new Geom_TrimmedCurve(aCurve, f, l); + aCurveSeq.Append(aCurve); + } + } + if (aCurveSeq.Length() > 1) + { + try + { + OCC_CATCH_SIGNALS + GeomFill_NSections aBSurface(aCurveSeq); + Handle(Geom_BSplineSurface) aRes = aBSurface.BSplineSurface(); + if (!aRes.IsNull()) + { + BRepBuilderAPI_MakeFace b_face1(aRes, Precision::Confusion()); + TopoDS_Face bsp_face1 = b_face1.Face(); + DBRep::Set(theArgVal[2], bsp_face1); + } + } + catch (Standard_Failure) + { + theDI << "ERROR: Exception in GeomFill_NSections\n"; + } + } + return 0; +} + void QABugs::Commands_20(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2042,5 +2096,6 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { theCommands.Add ("OCC26747_2", "OCC26747_2 result", __FILE__, OCC26747_2, group); theCommands.Add ("OCC26747_3", "OCC26747_3 result", __FILE__, OCC26747_3, group); theCommands.Add ("OCC27357", "OCC27357", __FILE__, OCC27357, group); + theCommands.Add("OCC26270", "OCC26270 shape result", __FILE__, OCC26270, group); return; } diff --git a/tests/bugs/modalg_6/bug26270 b/tests/bugs/modalg_6/bug26270 new file mode 100644 index 0000000000..263c53a721 --- /dev/null +++ b/tests/bugs/modalg_6/bug26270 @@ -0,0 +1,10 @@ +pload QAcommands +puts "================" +puts "OCC26270" +puts "================" +puts "" +############################### +## GeomFill_NSections constructor crash +############################### +restore [locate_data_file OCC606_2.brep] w2 +OCC26270 w2 result