1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026329: Restore floating point signals handling in DRAW

Added DRAW command dsetsignal, resetting OSD signal handler with either armed or disabled FPE handler, according to an option.
If called without arguments, it sets FPE handler only if environment variable OSD_FPE is defined (with value different from 0).
On start, DRAW calls dsetsignal to set FPE signal if CSF_FPE is defined.
Test bugs fclasses bug6143 uses dsetsignal to set FPE handler unconditionally before the test command, and resets it to default at the end.

A number of changes in the code have been done in order to fix floating point exceptions that became generated after enabling signals:

- Global functions Sinh() and Cosh() defined in Standard_Real.hxx are improved to raise Standard_NumericError exception if argument is too big (greater than 710.47586), instead of relying on system treatment of floating point overflow. These functions are used instead of sinh and cosh in ElCLib.cxx.

- Maximal value of parameter on hyperbola is restricted by 23 (corresponding to ~1e10 in 3d) in order to avoid FP overflow in Extrema_GenExtCS.cxx, ShapeFix_EdgeProjAux.cxx.

- Interface of the root curve adaptor class Adaptor3d_Curve has been updated to add new virtual methods BasisCurve and OffsetValue. They complement the adaptor for the case of offset curves. These methods are used in Extrema_GenExtCS.cxx to restrict domain search in the case of offset of hyperbola, in order to get rid of floating point overflow. All classes inheriting Adaptor3d_Curve have been changed to implement the new virtual methods.

- Protection against division by zero has been implemented in ApproxInt_KnotTools.cxx, BRepClass3d_SClassifier.cxx, BRepGProp_Face.cxx, BRepMesh_FastDiscretFace.cxx, Geom2dGcc_Circ2d2TanOnIter.cxx, Geom2dInt_Geom2dCurveTool.cxx, IntPolyh_MaillageAffinage.cxx.

- Protection against calling of math functions of infinite arguments has been added in BRepCheck_Edge.cxx, BRepLib.cxx, CSLib_NormalPolyDef.cxx, Extrema_FuncExtPC.gxx, Extrema_GExtPC.gxx, Extrema_GLocateExtPC.gxx, Intf_InterferencePolygonPolyhedron.gxx, ShapeAnalysis_Surface.cxx, ShapeAnalysis_TransferParametersProj.cxx, ShapeAnalysis_Wire.cxx, math_FunctionSetRoot.cxx.

- Proper initialization of local variables is done in BOPAlgo_PaveFiller_6.cxx, XSDRAWSTLVRML.cxx.

- Inconsistent usage of Standard_Boolean* to access integer data in HLR (caused by #27772) is corrected

Some test cases have been updated to actual state.
This commit is contained in:
ifv
2016-08-09 20:12:59 +03:00
committed by kgv
parent 73594f7248
commit f4dee9bb20
48 changed files with 595 additions and 228 deletions

View File

@@ -905,19 +905,53 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d,
TColStd_Array1OfReal dist(1,nbp+10);
dist.Init(-1.);
Adaptor3d_CurveOnSurface cons(c2d,surf);
//Adaptor3d_CurveOnSurface cons(c2d,surf);
Standard_Real uf = surf->FirstUParameter(), ul = surf->LastUParameter(),
vf = surf->FirstVParameter(), vl = surf->LastVParameter();
Standard_Real du = 0.01 * (ul - uf), dv = 0.01 * (vl - vf);
Standard_Boolean isUPeriodic = surf->IsUPeriodic(), isVPeriodic = surf->IsVPeriodic();
Standard_Real DSdu = 1./surf->UResolution(1.), DSdv = 1./surf->VResolution(1.);
Standard_Real d2 = 0.;
Standard_Real first = c3d->FirstParameter();
Standard_Real last = c3d->LastParameter();
Standard_Real dapp = -1.;
Standard_Integer i = 0;
for(i = 0; i <= nbp; i++){
const Standard_Real t = IntToReal(i)/IntToReal(nbp);
const Standard_Real u = first*(1.-t) + last*t;
gp_Pnt Pc3d = c3d->Value(u);
gp_Pnt Pcons = cons.Value(u);
gp_Pnt2d Puv = c2d->Value(u);
if(!isUPeriodic)
{
if(Puv.X() < uf - du)
{
dapp = Max(dapp, DSdu * (uf - Puv.X()));
continue;
}
else if(Puv.X() > ul + du)
{
dapp = Max(dapp, DSdu * (Puv.X() - ul));
continue;
}
}
if(!isVPeriodic)
{
if(Puv.Y() < vf - dv)
{
dapp = Max(dapp, DSdv * (vf - Puv.Y()));
continue;
}
else if(Puv.Y() > vl + dv)
{
dapp = Max(dapp, DSdv * (Puv.Y() - vl));
continue;
}
}
gp_Pnt Pcons = surf->Value(Puv.X(), Puv.Y());
if (Precision::IsInfinite(Pcons.X()) ||
Precision::IsInfinite(Pcons.Y()) ||
Precision::IsInfinite(Pcons.Z())) {
Precision::IsInfinite(Pcons.Y()) ||
Precision::IsInfinite(Pcons.Z()))
{
d2=Precision::Infinite();
break;
}
@@ -930,6 +964,16 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d,
if(temp > d2) d2 = temp;
}
if(Precision::IsInfinite(d2))
{
return d2;
}
d2 = Sqrt(d2);
if(dapp > d2)
{
return dapp;
}
Standard_Boolean ana = Standard_False;
Standard_Real D2 = 0;
@@ -952,7 +996,7 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d,
}
//d2 = 1.5*sqrt(d2);
d2 = (!ana) ? 1.5*sqrt(d2) : 1.5*sqrt(D2);
d2 = (!ana) ? 1.5 * d2 : 1.5*sqrt(D2);
if(d2<1.e-7) d2 = 1.e-7;
return d2;
@@ -1032,6 +1076,7 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge,
// Modified by skv - Thu Jun 3 12:39:20 2004 OCC5898 End
Standard_Boolean SameRange = BRep_Tool::SameRange(AnEdge);
Standard_Boolean YaPCu = Standard_False;
const Standard_Real BigError = 1.e10;
It.Initialize(CList);
while (It.More()) {
@@ -1075,6 +1120,12 @@ void BRepLib::SameParameter(const TopoDS_Edge& AnEdge,
Standard_Real error = ComputeTol(HC, HC2d, HS, NCONTROL);
if(error > BigError)
{
maxdist = error;
break;
}
if(GAC2d.GetType() == GeomAbs_BSplineCurve &&
GAC2d.Continuity() == GeomAbs_C0) {
Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline();
@@ -1416,6 +1467,7 @@ void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape,
}
//Vertices are processed
const Standard_Real BigTol = 1.e10;
parents.Clear();
TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, parents);
TColStd_MapOfTransient Initialized;
@@ -1432,6 +1484,7 @@ void BRepLib::UpdateTolerances(const TopoDS_Shape& aShape,
const TopoDS_Edge& E = TopoDS::Edge(lConx.Value());
if(!Done.Add(E)) continue;
tol=Max(tol, BRep_Tool::Tolerance(E));
if(tol > BigTol) continue;
if(!BRep_Tool::SameRange(E)) continue;
Standard_Real par = BRep_Tool::Parameter(V,E);
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());