From 72e616511b8048731778881740b34aa9c3cd9543 Mon Sep 17 00:00:00 2001 From: dmv Date: Tue, 16 Mar 2010 09:38:51 +0000 Subject: [PATCH] 0020763: EDF 1313 GEOM : Fillet 1D can crash the application and the MakeWire tolerance is not dumped --- src/GEOMImpl/GEOMImpl_Fillet1d.cxx | 30 ++++++++++++--------- src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx | 5 ++++ src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 2 +- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_Fillet1d.cxx b/src/GEOMImpl/GEOMImpl_Fillet1d.cxx index 27153dbb4..f905e48ed 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1d.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1d.cxx @@ -117,10 +117,9 @@ static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve for(a = anInter.NbPoints(); a > 0; a--) { aPoint = anInter.Point(a); - if (aPoint.Distance(theStart) < aTol) - if (!theStartConnected) - return Standard_True; - if (aPoint.Distance(theEnd) < aTol) + if ( aPoint.Distance(theStart) < aTol && !theStartConnected ) + return Standard_True; + if (aPoint.Distance(theEnd) < aTol * 200) return Standard_True; if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) return Standard_True; @@ -345,7 +344,7 @@ void GEOMImpl_Fillet1d::performNewton(GEOMImpl_Fillet1dPoint* theLeft, } Standard_Real aDX = theRight->GetParam() - theLeft->GetParam(); - if (aDX < gp::Resolution()/*Precision::Confusion() / 1000000.*/) + if ( aDX < Precision::Confusion() / 1000000.) { a = theRight->HasSolution(myRadius); if (a) @@ -361,11 +360,14 @@ void GEOMImpl_Fillet1d::performNewton(GEOMImpl_Fillet1dPoint* theLeft, { Standard_Integer aNear = theLeft->GetNear(a); - Standard_Real aA = (theRight->GetDiff(aNear) - theLeft->GetDiff(a)) / aDX; + Standard_Real aA = (theRight->GetDiff(aNear) - theLeft->GetDiff(a)) / aDX; Standard_Real aB = theLeft->GetDiff(a) - aA * theLeft->GetParam(); Standard_Real aC = theLeft->GetValue(a) - theLeft->GetDiff(a) * theLeft->GetParam() + aA * theLeft->GetParam() * theLeft->GetParam() / 2.0; Standard_Real aDet = aB * aB - 2.0 * aA * aC; + + if ( fabs(aDet) < gp::Resolution() ) + continue; if (fabs(aA) < Precision::Confusion()) { // linear case @@ -573,10 +575,10 @@ Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoin for(a = 1; a <= myV.Length(); a++) { aDY = thePoint->myV.Value(a) - myV.Value(a); - if (aDiffsSet) - myD.SetValue(a, aDY / aDX); - else - myD.Append(aDY / aDX); + if ( aDiffsSet ) + myD.SetValue(a, fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0); + else + myD.Append( fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0); } return Standard_True; } @@ -591,12 +593,14 @@ Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoin } if (aDiffsSet) { - if (fabs(aDY / aDX) < fabs(myD.Value(a))) + if ( fabs(aDX) > gp::Resolution() && fabs(aDY / aDX) < fabs(myD.Value(a))) myD.SetValue(a, aDY / aDX); + else + myD.SetValue(a, 0); } else { - myD.Append(aDY / aDX); + myD.Append( fabs(aDX) > gp::Resolution() ? aDY/aDX : 0); } } @@ -664,7 +668,7 @@ void GEOMImpl_Fillet1dPoint::FilterPoints(GEOMImpl_Fillet1dPoint* thePoint) if (aNear) { - if (fabs(aDiff / aDX) > 1.e+7) + if ( fabs(aDX) < gp::Resolution() || fabs(aDiff / aDX) > 1.e+7) { aNear = 0; } diff --git a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx index 83947d4ba..19b6b2d7a 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx @@ -155,6 +155,8 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aRefShape = aCI.GetShape(); TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) + return 0; if (aShape.ShapeType() != TopAbs_WIRE) Standard_ConstructionError::Raise("Wrong arguments: polyline as wire must be given"); @@ -162,6 +164,9 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const double rad = aCI.GetR(); + if ( rad < Precision::Confusion()) + return 0; + // collect vertices for make fillet TopTools_ListOfShape aVertexList; TopTools_MapOfShape mapShape; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index d180b5e94..aaa39fdee 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -276,7 +276,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire pd << ", " << (*it++); } } - pd << "])"; + pd << "], " << theTolerance << ")"; SetErrorCode(OK); return aWire; -- 2.30.2