0020763: EDF 1313 GEOM : Fillet 1D can crash the application and the MakeWire tolerance is not dumped

This commit is contained in:
dmv 2010-03-16 09:38:51 +00:00
parent 7780c41f49
commit 72e616511b
3 changed files with 23 additions and 14 deletions

View File

@ -117,10 +117,9 @@ static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve
for(a = anInter.NbPoints(); a > 0; a--) for(a = anInter.NbPoints(); a > 0; a--)
{ {
aPoint = anInter.Point(a); aPoint = anInter.Point(a);
if (aPoint.Distance(theStart) < aTol) if ( aPoint.Distance(theStart) < aTol && !theStartConnected )
if (!theStartConnected)
return Standard_True; return Standard_True;
if (aPoint.Distance(theEnd) < aTol) if (aPoint.Distance(theEnd) < aTol * 200)
return Standard_True; return Standard_True;
if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol))
return Standard_True; return Standard_True;
@ -345,7 +344,7 @@ void GEOMImpl_Fillet1d::performNewton(GEOMImpl_Fillet1dPoint* theLeft,
} }
Standard_Real aDX = theRight->GetParam() - theLeft->GetParam(); Standard_Real aDX = theRight->GetParam() - theLeft->GetParam();
if (aDX < gp::Resolution()/*Precision::Confusion() / 1000000.*/) if ( aDX < Precision::Confusion() / 1000000.)
{ {
a = theRight->HasSolution(myRadius); a = theRight->HasSolution(myRadius);
if (a) if (a)
@ -367,6 +366,9 @@ void GEOMImpl_Fillet1d::performNewton(GEOMImpl_Fillet1dPoint* theLeft,
aA * theLeft->GetParam() * theLeft->GetParam() / 2.0; aA * theLeft->GetParam() * theLeft->GetParam() / 2.0;
Standard_Real aDet = aB * aB - 2.0 * aA * aC; Standard_Real aDet = aB * aB - 2.0 * aA * aC;
if ( fabs(aDet) < gp::Resolution() )
continue;
if (fabs(aA) < Precision::Confusion()) if (fabs(aA) < Precision::Confusion())
{ // linear case { // linear case
if (fabs(aB) > 10e-20) if (fabs(aB) > 10e-20)
@ -574,9 +576,9 @@ Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoin
{ {
aDY = thePoint->myV.Value(a) - myV.Value(a); aDY = thePoint->myV.Value(a) - myV.Value(a);
if ( aDiffsSet ) if ( aDiffsSet )
myD.SetValue(a, aDY / aDX); myD.SetValue(a, fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0);
else else
myD.Append(aDY / aDX); myD.Append( fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0);
} }
return Standard_True; return Standard_True;
} }
@ -591,12 +593,14 @@ Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoin
} }
if (aDiffsSet) 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); myD.SetValue(a, aDY / aDX);
else
myD.SetValue(a, 0);
} }
else 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 (aNear)
{ {
if (fabs(aDiff / aDX) > 1.e+7) if ( fabs(aDX) < gp::Resolution() || fabs(aDiff / aDX) > 1.e+7)
{ {
aNear = 0; aNear = 0;
} }

View File

@ -155,6 +155,8 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const
Handle(GEOM_Function) aRefShape = aCI.GetShape(); Handle(GEOM_Function) aRefShape = aCI.GetShape();
TopoDS_Shape aShape = aRefShape->GetValue(); TopoDS_Shape aShape = aRefShape->GetValue();
if (aShape.IsNull())
return 0;
if (aShape.ShapeType() != TopAbs_WIRE) if (aShape.ShapeType() != TopAbs_WIRE)
Standard_ConstructionError::Raise("Wrong arguments: polyline as wire must be given"); 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(); double rad = aCI.GetR();
if ( rad < Precision::Confusion())
return 0;
// collect vertices for make fillet // collect vertices for make fillet
TopTools_ListOfShape aVertexList; TopTools_ListOfShape aVertexList;
TopTools_MapOfShape mapShape; TopTools_MapOfShape mapShape;

View File

@ -276,7 +276,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire
pd << ", " << (*it++); pd << ", " << (*it++);
} }
} }
pd << "])"; pd << "], " << theTolerance << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aWire; return aWire;