diff --git a/src/Adaptor3d/Adaptor3d_Curve.cxx b/src/Adaptor3d/Adaptor3d_Curve.cxx index 487dd59a0d..4825344378 100644 --- a/src/Adaptor3d/Adaptor3d_Curve.cxx +++ b/src/Adaptor3d/Adaptor3d_Curve.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -376,3 +377,14 @@ Handle(Geom_BSplineCurve) Adaptor3d_Curve::BSpline() const Standard_NotImplemented::Raise("Adaptor3d_Curve::BSpline"); return Handle(Geom_BSplineCurve)(); } + +//======================================================================= +//function : BasisCurve +//purpose : +//======================================================================= + +Handle(Geom_OffsetCurve) Adaptor3d_Curve::OffsetCurve() const +{ + Standard_NotImplemented::Raise("Adaptor3d_Curve::OffsetCurve"); + return Handle(Geom_OffsetCurve)(); +} diff --git a/src/Adaptor3d/Adaptor3d_Curve.hxx b/src/Adaptor3d/Adaptor3d_Curve.hxx index 647cf03d71..de882dc430 100644 --- a/src/Adaptor3d/Adaptor3d_Curve.hxx +++ b/src/Adaptor3d/Adaptor3d_Curve.hxx @@ -40,6 +40,7 @@ class gp_Hypr; class gp_Parab; class Geom_BezierCurve; class Geom_BSplineCurve; +class Geom_OffsetCurve; //! Root class for 3D curves on which geometric @@ -155,6 +156,9 @@ public: Standard_EXPORT virtual Handle(Geom_BezierCurve) Bezier() const; Standard_EXPORT virtual Handle(Geom_BSplineCurve) BSpline() const; + + Standard_EXPORT virtual Handle(Geom_OffsetCurve) OffsetCurve() const; + Standard_EXPORT virtual ~Adaptor3d_Curve(); diff --git a/src/Adaptor3d/Adaptor3d_HCurve.hxx b/src/Adaptor3d/Adaptor3d_HCurve.hxx index 2ca8d2522d..be29b50bd6 100644 --- a/src/Adaptor3d/Adaptor3d_HCurve.hxx +++ b/src/Adaptor3d/Adaptor3d_HCurve.hxx @@ -42,6 +42,7 @@ class gp_Pnt; class gp_Vec; class Geom_BezierCurve; class Geom_BSplineCurve; +class Geom_OffsetCurve; class Adaptor3d_HCurve; @@ -134,7 +135,7 @@ public: Handle(Geom_BSplineCurve) BSpline() const; - + Handle(Geom_OffsetCurve) OffsetCurve() const; DEFINE_STANDARD_RTTIEXT(Adaptor3d_HCurve,MMgt_TShared) diff --git a/src/Adaptor3d/Adaptor3d_HCurve.lxx b/src/Adaptor3d/Adaptor3d_HCurve.lxx index 8a81896fd0..48b2d8d0d3 100644 --- a/src/Adaptor3d/Adaptor3d_HCurve.lxx +++ b/src/Adaptor3d/Adaptor3d_HCurve.lxx @@ -293,3 +293,12 @@ inline Standard_Integer Adaptor3d_HCurve::NbKnots() const return Curve().BSpline(); } +//======================================================================= +//function : BasisCurve +//purpose : +//======================================================================= + + inline Handle(Geom_OffsetCurve) Adaptor3d_HCurve::OffsetCurve() const +{ + return Curve().OffsetCurve(); +} diff --git a/src/ApproxInt/ApproxInt_KnotTools.cxx b/src/ApproxInt/ApproxInt_KnotTools.cxx index 0fa2043704..7d7a77d021 100644 --- a/src/ApproxInt/ApproxInt_KnotTools.cxx +++ b/src/ApproxInt/ApproxInt_KnotTools.cxx @@ -28,10 +28,10 @@ #include // (Sqrt(5.0) - 1.0) / 4.0 -static const Standard_Real aSinCoeff = 0.30901699437494742410229341718282; +//static const Standard_Real aSinCoeff = 0.30901699437494742410229341718282; +static const Standard_Real aSinCoeff2 = 0.09549150281252627; // aSinCoeff^2 = (3. - Sqrt(5.)) / 8. static const Standard_Integer aMaxPntCoeff = 15; - //======================================================================= //function : EvalCurv //purpose : Evaluate curvature in dim-dimension point. @@ -238,7 +238,6 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray aSinCoeff) + if(mp > aSinCoeff2 * m1 * m2) // Sqrt (mp/(m1*m2)) > aSinCoeff { //Insert new knots Standard_Real d1 = Abs(aCurv(anInd) - aCurv(anIndPrev)); @@ -494,7 +491,6 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI, { if(ChkCurv) { - Standard_Real sina; Standard_Integer ici = (anInd - theCurv.Lower()) * theDim, ici1 = (anInd1 - theCurv.Lower()) * theDim, icm = (mid - theCurv.Lower()) * theDim; @@ -519,10 +515,8 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI, } //mp *= 2.; //P(j,i) = -P(i,j); // - sina = mp/(m1*m2); - sina = Sqrt(sina); - if(sina > aSinCoeff) + if (mp > aSinCoeff2 * m1 * m2) // Sqrt (mp / m1m2) > aSinCoeff { theInds.InsertBefore(theI, mid); return Standard_True; diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index c3b5b1a201..b6730c0a30 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -1258,7 +1258,7 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 : (!aBoxSp.IsOut(aBoxP2) ? 1 : 0); if (iFlag1 && iFlag2) { - Standard_Real aDist; + Standard_Real aDist = 0.; const Standard_Real aRealTol = myDS->IsCommonBlock(aPB) ? Max(aTolV1, aTolV2) : theTolR3D; @@ -1275,13 +1275,13 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock // if (iFlag1 == 1) { iFlag1 = !myContext->ComputePE(aP1, aRealTol, aSp, aTx, aDist); - if (theTolNew < aDist) + if (iFlag1 && theTolNew < aDist) theTolNew = aDist; } // if (iFlag2 == 1) { iFlag2 = !myContext->ComputePE(aP2, aRealTol, aSp, aTx, aDist); - if (theTolNew < aDist) + if (iFlag2 && theTolNew < aDist) theTolNew = aDist; } // diff --git a/src/BRepAdaptor/BRepAdaptor_Curve.cxx b/src/BRepAdaptor/BRepAdaptor_Curve.cxx index ca986abac3..c1b07510c0 100644 --- a/src/BRepAdaptor/BRepAdaptor_Curve.cxx +++ b/src/BRepAdaptor/BRepAdaptor_Curve.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,8 @@ #include #include #include +#include +#include //======================================================================= //function : BRepAdaptor_Curve @@ -649,3 +652,18 @@ Handle(Geom_BSplineCurve) BRepAdaptor_Curve::BSpline() const return myTrsf.Form() == gp_Identity ? BS : Handle(Geom_BSplineCurve)::DownCast(BS->Transformed(myTrsf)); } + +//======================================================================= +//function : BasisCurve +//purpose : +//======================================================================= + +Handle(Geom_OffsetCurve) BRepAdaptor_Curve::OffsetCurve() const +{ + if ( !Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve) + Standard_NoSuchObject::Raise("BRepAdaptor_Curve::OffsetCurve"); + + Handle(Geom_OffsetCurve) anOffC = myCurve.OffsetCurve(); + return myTrsf.Form() == gp_Identity + ? anOffC : Handle(Geom_OffsetCurve)::DownCast(anOffC->Transformed(myTrsf)); +} diff --git a/src/BRepAdaptor/BRepAdaptor_Curve.hxx b/src/BRepAdaptor/BRepAdaptor_Curve.hxx index 7440175f84..96a87a73a6 100644 --- a/src/BRepAdaptor/BRepAdaptor_Curve.hxx +++ b/src/BRepAdaptor/BRepAdaptor_Curve.hxx @@ -51,6 +51,7 @@ class gp_Hypr; class gp_Parab; class Geom_BezierCurve; class Geom_BSplineCurve; +class Geom_OffsetCurve; //! The Curve from BRepAdaptor allows to use an Edge @@ -220,6 +221,7 @@ public: //! using this method Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE; + Standard_EXPORT Handle(Geom_OffsetCurve) OffsetCurve() const Standard_OVERRIDE; diff --git a/src/BRepCheck/BRepCheck_Edge.cxx b/src/BRepCheck/BRepCheck_Edge.cxx index 0c192748a7..e0261a065f 100644 --- a/src/BRepCheck/BRepCheck_Edge.cxx +++ b/src/BRepCheck/BRepCheck_Edge.cxx @@ -555,8 +555,18 @@ Standard_Real BRepCheck_Edge::Tolerance() prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1); tol2=dist2=0.; center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm); + if(Precision::IsInfinite(center.X()) || Precision::IsInfinite(center.Y()) + || Precision::IsInfinite(center.Z())) + { + return Precision::Infinite(); + } for (iRep=2; iRep<=nbRep; iRep++) { othP=(*(Handle(Adaptor3d_HCurve)*)&theRep(iRep))->Value(prm); + if(Precision::IsInfinite(othP.X()) || Precision::IsInfinite(othP.Y()) + || Precision::IsInfinite(othP.Z())) + { + return Precision::Infinite(); + } dist2=center.SquareDistance(othP); if (dist2>tolCal) tolCal=dist2; } diff --git a/src/BRepClass3d/BRepClass3d_SClassifier.cxx b/src/BRepClass3d/BRepClass3d_SClassifier.cxx index 6a68919587..16e0bf8495 100644 --- a/src/BRepClass3d/BRepClass3d_SClassifier.cxx +++ b/src/BRepClass3d/BRepClass3d_SClassifier.cxx @@ -579,7 +579,7 @@ static Standard_Integer GetTransi(const TopoDS_Face& f1, return -1; } - if (nf1.IsEqual(nf2, Precision::Angular())) + if (nf1.IsParallel(nf2, Precision::Angular())) { Standard_Real angD = nf1.Dot(LDir); if (Abs(angD) < Precision::Angular()) diff --git a/src/BRepGProp/BRepGProp_Face.cxx b/src/BRepGProp/BRepGProp_Face.cxx index 0ce1303e6a..4484d214b1 100644 --- a/src/BRepGProp/BRepGProp_Face.cxx +++ b/src/BRepGProp/BRepGProp_Face.cxx @@ -34,6 +34,8 @@ #include #include +static const Standard_Real Epsilon1 = Epsilon(1.); + //======================================================================= //function : UIntegrationOrder //purpose : @@ -389,7 +391,8 @@ Standard_Integer BRepGProp_Face::LIntOrder(const Standard_Real Eps) const Standard_Real aVmin = mySurface.FirstVParameter(); Standard_Real aVmax = mySurface.LastVParameter(); - Standard_Real anR = Min((aYmax-aYmin)/(aVmax-aVmin), 1.); + Standard_Real dv = (aVmax-aVmin); + Standard_Real anR = (dv > Epsilon1 ? Min ((aYmax - aYmin) / dv, 1.) : 1.); // Standard_Integer anRInt = Max(RealToInt(Ceiling(SVIntSubs()*anR)), 2); Standard_Integer anRInt = RealToInt(Ceiling(SVIntSubs()*anR)); diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index aced41ccb7..3d42110453 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -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()); diff --git a/src/BRepMesh/BRepMesh_FastDiscretFace.cxx b/src/BRepMesh/BRepMesh_FastDiscretFace.cxx index 80df07b20f..89cbc89540 100644 --- a/src/BRepMesh/BRepMesh_FastDiscretFace.cxx +++ b/src/BRepMesh/BRepMesh_FastDiscretFace.cxx @@ -1011,7 +1011,9 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther( if (aDist < aDefFace) { // Lets check parameters for angular deflection. - if (aPrevVec2.Angle(aNextVec) < myAngle) + if (aPrevVec2.SquareMagnitude() > gp::Resolution() && + aNextVec.SquareMagnitude() > gp::Resolution() && + aPrevVec2.Angle(aNextVec) < myAngle) { // For current Iso line we can remove this parameter. #ifdef DEBUG_InsertInternal diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx index 356ae06a02..0874a2310c 100644 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -1039,7 +1039,10 @@ static void ReconstructPCurves(const TopoDS_Edge& anEdge) (theSurf->Transformed(theLoc.Transformation())); Handle(Geom2d_Curve) ProjPCurve = GeomProjLib::Curve2d( C3d, f, l, theSurf ); - CurveRep->PCurve( ProjPCurve ); + if(!ProjPCurve.IsNull()) + { + CurveRep->PCurve( ProjPCurve ); + } } } } diff --git a/src/BRepTest/BRepTest_FeatureCommands.cxx b/src/BRepTest/BRepTest_FeatureCommands.cxx index 28e8094bd7..79bf466e1a 100644 --- a/src/BRepTest/BRepTest_FeatureCommands.cxx +++ b/src/BRepTest/BRepTest_FeatureCommands.cxx @@ -1009,7 +1009,7 @@ Standard_Integer offsetparameter(Draw_Interpretor& di, Standard_Integer n, const char** a) { if ( n == 1 ) { - di << " OffsetParameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k) RemoveInvalidFaces(r/k)]\n"; + di << " offsetparameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k) RemoveInvalidFaces(r/k)]\n"; di << " Current Values\n"; di << " --> Tolerance : " << TheTolerance << "\n"; di << " --> TheInter : "; @@ -2327,7 +2327,7 @@ void BRepTest::FeatureCommands (Draw_Interpretor& theCommands) __FILE__,offsetshape,g); theCommands.Add("offsetparameter", - "offsetparameter tol inter(a/i) join(a/i)", + "offsetparameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k) RemoveInvalidFaces(r/k)]", __FILE__,offsetparameter); theCommands.Add("offsetload", diff --git a/src/CSLib/CSLib_NormalPolyDef.cxx b/src/CSLib/CSLib_NormalPolyDef.cxx index 909c5eea78..5104fbca9c 100644 --- a/src/CSLib/CSLib_NormalPolyDef.cxx +++ b/src/CSLib/CSLib_NormalPolyDef.cxx @@ -39,6 +39,11 @@ Standard_Boolean CSLib_NormalPolyDef::Value(const Standard_Real X, co=cos(X); si=sin(X); + if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall()) + { + F = 0.; + return Standard_True; + } for(Standard_Integer i=0;i<=myK0;i++){ F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i); } @@ -54,6 +59,11 @@ Standard_Boolean CSLib_NormalPolyDef::Derivative(const Standard_Real X, Standard_Real co,si; co=cos(X); si=sin(X); + if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall()) + { + D = 0.; + return Standard_True; + } for(Standard_Integer i=0;i<=myK0;i++){ D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*pow(si,(myK0-i-1))*(myK0*co*co-i); } @@ -71,6 +81,12 @@ Standard_Boolean CSLib_NormalPolyDef::Values(const Standard_Real X, Standard_Real co,si; co=cos(X); si=sin(X); + if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall()) + { + F = 0.; + D = 0.; + return Standard_True; + } for(Standard_Integer i=0;i<=myK0;i++){ F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i); D=D+PLib::Bin(myK0,i)*pow(co,(i-1))* diff --git a/src/Draw/Draw_BasicCommands.cxx b/src/Draw/Draw_BasicCommands.cxx index 0fda933618..7c9487db10 100644 --- a/src/Draw/Draw_BasicCommands.cxx +++ b/src/Draw/Draw_BasicCommands.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -740,6 +741,31 @@ static int dperf (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char return 0; } +//============================================================================== +//function : dsetsignal +//purpose : +//============================================================================== + +static int dsetsignal (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec) +{ + // arm FPE handler if argument is provided and its first symbol is not '0' + // or if environment variable CSF_FPE is set and its first symbol is not '0' + bool setFPE = false; + if (theArgNb > 1) + { + setFPE = (theArgVec[1][0] == '1' || theArgVec[1][0] == 't'); + } + else + { + OSD_Environment aEnv ("CSF_FPE"); + TCollection_AsciiString aEnvStr = aEnv.Value(); + setFPE = (! aEnvStr.IsEmpty() && aEnvStr.Value(1) != '0'); + } + OSD::SetSignal (setFPE); + theDI << "Signal handlers are set, with FPE " << (setFPE ? "armed" : "disarmed"); + return 0; +} + //============================================================================== //function : dtracelevel //purpose : @@ -864,6 +890,8 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands) __FILE__, dmeminfo, g); theCommands.Add("dperf","dperf [reset] -- show performance counters, reset if argument is provided", __FILE__,dperf,g); + theCommands.Add("dsetsignal","dsetsignal [fpe=0] -- set OSD signal handler, with FPE option if argument is given", + __FILE__,dsetsignal,g); // Logging commands; note that their names are hard-coded in the code // of Draw_Interpretor, thus should not be changed without update of that code! diff --git a/src/DrawResources/DrawDefault b/src/DrawResources/DrawDefault index bb37408e5a..d5973b8283 100755 --- a/src/DrawResources/DrawDefault +++ b/src/DrawResources/DrawDefault @@ -125,5 +125,8 @@ if { $tcl_platform(platform) == "windows" && ! [catch {dgetenv PATH}] } { _update_c_env env "" "unset" } +# arm signal handler with default FPE setting +dsetsignal + # silent return from the script return diff --git a/src/ElCLib/ElCLib.cxx b/src/ElCLib/ElCLib.cxx index 170dd2d6d9..6bfb2de05a 100644 --- a/src/ElCLib/ElCLib.cxx +++ b/src/ElCLib/ElCLib.cxx @@ -154,8 +154,8 @@ gp_Pnt ElCLib::HyperbolaValue (const Standard_Real U, const gp_XYZ& XDir = Pos.XDirection().XYZ(); const gp_XYZ& YDir = Pos.YDirection().XYZ(); const gp_XYZ& PLoc = Pos.Location ().XYZ(); - Standard_Real A1 = MajorRadius * cosh(U); - Standard_Real A2 = MinorRadius * sinh(U); + Standard_Real A1 = MajorRadius * Cosh(U); + Standard_Real A2 = MinorRadius * Sinh(U); return gp_Pnt(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(), A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y(), A1 * XDir.Z() + A2 * YDir.Z() + PLoc.Z()); @@ -382,8 +382,8 @@ void ElCLib::HyperbolaD2 (const Standard_Real U, gp_Vec& V1, gp_Vec& V2) { - Standard_Real Xc = cosh(U); - Standard_Real Yc = sinh(U); + Standard_Real Xc = Cosh(U); + Standard_Real Yc = Sinh(U); gp_XYZ Coord0; gp_XYZ Coord1 (Pos.XDirection().XYZ()); gp_XYZ Coord2 (Pos.YDirection().XYZ()); @@ -514,8 +514,8 @@ void ElCLib::HyperbolaD3 (const Standard_Real U, gp_Vec& V2, gp_Vec& V3) { - Standard_Real Xc = cosh(U); - Standard_Real Yc = sinh(U); + Standard_Real Xc = Cosh(U); + Standard_Real Yc = Sinh(U); gp_XYZ Coord0; gp_XYZ Coord1 (Pos.XDirection().XYZ()); gp_XYZ Coord2 (Pos.YDirection().XYZ()); @@ -594,8 +594,8 @@ gp_Pnt2d ElCLib::HyperbolaValue (const Standard_Real U, const gp_XY& XDir = Pos.XDirection().XY(); const gp_XY& YDir = Pos.YDirection().XY(); const gp_XY& PLoc = Pos.Location ().XY(); - Standard_Real A1 = MajorRadius * cosh(U); - Standard_Real A2 = MinorRadius * sinh(U); + Standard_Real A1 = MajorRadius * Cosh(U); + Standard_Real A2 = MinorRadius * Sinh(U); return gp_Pnt2d(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(), A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y()); } @@ -706,8 +706,8 @@ void ElCLib::HyperbolaD1 (const Standard_Real U, gp_XY Vxy; gp_XY Xdir ((Pos.XDirection()).XY()); gp_XY Ydir ((Pos.YDirection()).XY()); - Standard_Real Xc = cosh(U); - Standard_Real Yc = sinh(U); + Standard_Real Xc = Cosh(U); + Standard_Real Yc = Sinh(U); //Point courant : Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir, @@ -825,8 +825,8 @@ void ElCLib::HyperbolaD2 (const Standard_Real U, gp_XY Vxy; gp_XY Xdir (Pos.XDirection().XY()); gp_XY Ydir (Pos.YDirection().XY()); - Standard_Real Xc = cosh(U); - Standard_Real Yc = sinh(U); + Standard_Real Xc = Cosh(U); + Standard_Real Yc = Sinh(U); //V2 : Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir); @@ -964,8 +964,8 @@ void ElCLib::HyperbolaD3 (const Standard_Real U, gp_XY Vxy; gp_XY Xdir (Pos.XDirection().XY()); gp_XY Ydir (Pos.YDirection().XY()); - Standard_Real Xc = cosh(U); - Standard_Real Yc = sinh(U); + Standard_Real Xc = Cosh(U); + Standard_Real Yc = Sinh(U); //V2 : Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir); @@ -1082,12 +1082,12 @@ gp_Vec ElCLib::HyperbolaDN (const Standard_Real U, { Standard_Real Xc=0, Yc=0; if (IsOdd (N)) { - Xc = MajorRadius * sinh(U); - Yc = MinorRadius * cosh(U); + Xc = MajorRadius * Sinh(U); + Yc = MinorRadius * Cosh(U); } else if (IsEven (N)) { - Xc = MajorRadius * cosh(U); - Yc = MinorRadius * sinh(U); + Xc = MajorRadius * Cosh(U); + Yc = MinorRadius * Sinh(U); } gp_XYZ Coord1 (Pos.XDirection().XYZ()); Coord1.SetLinearForm (Xc, Coord1, Yc, Pos.YDirection().XYZ()); @@ -1230,12 +1230,12 @@ gp_Vec2d ElCLib::HyperbolaDN (const Standard_Real U, { Standard_Real Xc=0, Yc=0; if (IsOdd (N)) { - Xc = MajorRadius * sinh(U); - Yc = MinorRadius * cosh(U); + Xc = MajorRadius * Sinh(U); + Yc = MinorRadius * Cosh(U); } else if (IsEven (N)) { - Xc = MajorRadius * cosh(U); - Yc = MinorRadius * sinh(U); + Xc = MajorRadius * Cosh(U); + Yc = MinorRadius * Sinh(U); } gp_XY Xdir (Pos.XDirection().XY()); gp_XY Ydir (Pos.YDirection().XY()); diff --git a/src/Extrema/Extrema_FuncExtPC.gxx b/src/Extrema/Extrema_FuncExtPC.gxx index a79915df84..8d83e39eac 100644 --- a/src/Extrema/Extrema_FuncExtPC.gxx +++ b/src/Extrema/Extrema_FuncExtPC.gxx @@ -55,6 +55,12 @@ Standard_Real Extrema_FuncExtPC::SearchOfTolerance() Pnt Ptemp; //empty point (is not used below) Vec VDer; // 1st derivative vector Tool::D1(*((Curve*)myC), u, Ptemp, VDer); + + if(Precision::IsInfinite(VDer.X()) || Precision::IsInfinite(VDer.Y())) + { + continue; + } + Standard_Real vm = VDer.Magnitude(); if(vm > aMax) aMax = vm; @@ -160,6 +166,13 @@ Standard_Boolean Extrema_FuncExtPC::Value (const Standard_Real U, Standard_Real& myU = U; Vec D1c; Tool::D1(*((Curve*)myC),myU,myPc,D1c); + + if(Precision::IsInfinite(D1c.X()) || Precision::IsInfinite(D1c.Y())) + { + F = Precision::Infinite(); + return Standard_False; + } + Standard_Real Ndu = D1c.Magnitude(); if(myMaxDerivOrder != 0) diff --git a/src/Extrema/Extrema_GExtPC.gxx b/src/Extrema/Extrema_GExtPC.gxx index a61234cb9f..2ed746dac7 100644 --- a/src/Extrema/Extrema_GExtPC.gxx +++ b/src/Extrema/Extrema_GExtPC.gxx @@ -204,7 +204,7 @@ void Extrema_GExtPC::Perform(const ThePoint& P) } // Solve on the first and last intervals. - if (mydist1 > Precision::SquareConfusion()) + if (mydist1 > Precision::SquareConfusion() && !Precision::IsPositiveInfinite(mydist1)) { ThePoint aP1, aP2; TheVector aV1, aV2; @@ -213,21 +213,23 @@ void Extrema_GExtPC::Perform(const ThePoint& P) TheVector aBase1(P, aP1), aBase2(P, aP2); Standard_Real aVal1 = aV1.Dot(aBase1); // Derivative of (C(u) - P)^2 Standard_Real aVal2 = aV2.Dot(aBase2); // Derivative of (C(u) - P)^2 - - // Derivatives have opposite signs - min or max inside of interval (sufficient condition). - // Necessary condition - when point lies on curve. - // Necessary condition - when derivative of point is too small. - if(aVal1 * aVal2 <= 0.0 || - aBase1.Dot(aBase2) <= 0.0 || - 2.0 * Abs(aVal1) < Precision::Confusion() ) + if(!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2))) { - myintuinf = aParam(aVal.Lower()); - myintusup = aParam(aVal.Lower() + 1); - IntervalPerform(P); + // Derivatives have opposite signs - min or max inside of interval (sufficient condition). + // Necessary condition - when point lies on curve. + // Necessary condition - when derivative of point is too small. + if(aVal1 * aVal2 <= 0.0 || + aBase1.Dot(aBase2) <= 0.0 || + 2.0 * Abs(aVal1) < Precision::Confusion() ) + { + myintuinf = aParam(aVal.Lower()); + myintusup = aParam(aVal.Lower() + 1); + IntervalPerform(P); + } } } - if (mydist2 > Precision::SquareConfusion()) + if (mydist2 > Precision::SquareConfusion() && !Precision::IsPositiveInfinite(mydist2)) { ThePoint aP1, aP2; TheVector aV1, aV2; @@ -237,16 +239,19 @@ void Extrema_GExtPC::Perform(const ThePoint& P) Standard_Real aVal1 = aV1.Dot(aBase1); // Derivative of (C(u) - P)^2 Standard_Real aVal2 = aV2.Dot(aBase2); // Derivative of (C(u) - P)^2 - // Derivatives have opposite signs - min or max inside of interval (sufficient condition). - // Necessary condition - when point lies on curve. - // Necessary condition - when derivative of point is too small. - if(aVal1 * aVal2 <= 0.0 || - aBase1.Dot(aBase2) <= 0.0 || - 2.0 * Abs(aVal2) < Precision::Confusion() ) + if(!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2))) { - myintuinf = aParam(aVal.Upper() - 1); - myintusup = aParam(aVal.Upper()); - IntervalPerform(P); + // Derivatives have opposite signs - min or max inside of interval (sufficient condition). + // Necessary condition - when point lies on curve. + // Necessary condition - when derivative of point is too small. + if(aVal1 * aVal2 <= 0.0 || + aBase1.Dot(aBase2) <= 0.0 || + 2.0 * Abs(aVal2) < Precision::Confusion() ) + { + myintuinf = aParam(aVal.Upper() - 1); + myintusup = aParam(aVal.Upper()); + IntervalPerform(P); + } } } diff --git a/src/Extrema/Extrema_GLocateExtPC.gxx b/src/Extrema/Extrema_GLocateExtPC.gxx index 5f9a911f44..3f5eb2ea10 100644 --- a/src/Extrema/Extrema_GLocateExtPC.gxx +++ b/src/Extrema/Extrema_GLocateExtPC.gxx @@ -187,6 +187,10 @@ void Extrema_GLocateExtPC::Perform(const ThePoint& P, { TheCurveTool::D1(*((TheCurve*)myC), myintuinf, P1, V1); s2sup = (TheVector(P, P1)*V1); + if(Precision::IsInfinite(s2sup) || Precision::IsInfinite(s1sup)) + { + break; + } if (s1sup*s2sup <= RealEpsilon()) { // extremum: @@ -220,6 +224,10 @@ void Extrema_GLocateExtPC::Perform(const ThePoint& P, { TheCurveTool::D1(*((TheCurve*)myC), myintusup, P1, V1); s1inf = (TheVector(P, P1)*V1); + if(Precision::IsInfinite(s2inf) || Precision::IsInfinite(s1inf)) + { + break; + } if (s1inf*s2inf <= RealEpsilon()) { // extremum: diff --git a/src/Extrema/Extrema_GenExtCS.cxx b/src/Extrema/Extrema_GenExtCS.cxx index dca7a2ac22..edf02474a6 100644 --- a/src/Extrema/Extrema_GenExtCS.cxx +++ b/src/Extrema/Extrema_GenExtCS.cxx @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -35,9 +37,53 @@ #include #include #include +#include +#include -const Standard_Real aMaxParamVal = 1.0e+10; +const Standard_Real MaxParamVal = 1.0e+10; const Standard_Real aBorderDivisor = 1.0e+4; +const Standard_Real HyperbolaLimit = 23.; //ln(MaxParamVal) + +// restrict maximal parameter on hyperbola to avoid FPE +static Standard_Real GetCurvMaxParamVal (const Adaptor3d_Curve& theC) +{ + if (theC.GetType() == GeomAbs_Hyperbola) + { + return HyperbolaLimit; + } + if (theC.GetType() == GeomAbs_OffsetCurve) + { + Handle(Geom_Curve) aBC (theC.OffsetCurve()->BasisCurve()); + Handle(Geom_TrimmedCurve) aTC = Handle(Geom_TrimmedCurve)::DownCast (aBC); + if (! aTC.IsNull()) + { + aBC = aTC->BasisCurve(); + } + if (aBC->IsKind (STANDARD_TYPE(Geom_Hyperbola))) + return HyperbolaLimit; + } + return MaxParamVal; +} + +// restrict maximal parameter on surfaces based on hyperbola to avoid FPE +static void GetSurfMaxParamVals (const Adaptor3d_Surface& theS, + Standard_Real& theUmax, Standard_Real& theVmax) +{ + theUmax = theVmax = MaxParamVal; + + if (theS.GetType() == GeomAbs_SurfaceOfExtrusion) + { + theUmax = GetCurvMaxParamVal (theS.BasisCurve()->Curve()); + } + else if (theS.GetType() == GeomAbs_SurfaceOfRevolution) + { + theVmax = GetCurvMaxParamVal (theS.BasisCurve()->Curve()); + } + else if (theS.GetType() == GeomAbs_OffsetSurface) + { + GetSurfMaxParamVals (theS.BasisSurface()->Surface(), theUmax, theVmax); + } +} //======================================================================= //function : Extrema_GenExtCS @@ -126,15 +172,32 @@ void Extrema_GenExtCS::Initialize (const Adaptor3d_Surface& S, myvsup = Vsup; mytol2 = Tol2; - const Standard_Real aTrimMaxU = Precision::IsInfinite (myusup) ? aMaxParamVal : myusup; - const Standard_Real aTrimMinU = Precision::IsInfinite (myumin) ? -aMaxParamVal : myumin; - const Standard_Real aTrimMaxV = Precision::IsInfinite (myvsup) ? aMaxParamVal : myvsup; - const Standard_Real aTrimMinV = Precision::IsInfinite (myvmin) ? -aMaxParamVal : myvmin; + Standard_Real umaxpar, vmaxpar; + GetSurfMaxParamVals(*myS, umaxpar, vmaxpar); - const Standard_Real aMinU = aTrimMinU + (aTrimMaxU - aTrimMinU) / aBorderDivisor; - const Standard_Real aMinV = aTrimMinV + (aTrimMaxV - aTrimMinV) / aBorderDivisor; - const Standard_Real aMaxU = aTrimMaxU - (aTrimMaxU - aTrimMinU) / aBorderDivisor; - const Standard_Real aMaxV = aTrimMaxV - (aTrimMaxV - aTrimMinV) / aBorderDivisor; + if(Precision::IsInfinite (myusup)) + { + myusup = umaxpar; + } + if(Precision::IsInfinite (myumin)) + { + myumin = -umaxpar; + } + if(Precision::IsInfinite (myvsup)) + { + myvsup = vmaxpar; + } + if(Precision::IsInfinite (myvmin)) + { + myvmin = -vmaxpar; + } + + Standard_Real du = (myusup - myumin) / aBorderDivisor; + Standard_Real dv = (myvsup - myvmin) / aBorderDivisor; + const Standard_Real aMinU = myumin + du; + const Standard_Real aMinV = myvmin + dv; + const Standard_Real aMaxU = myusup - du; + const Standard_Real aMaxV = myvsup - dv; const Standard_Real aStepSU = (aMaxU - aMinU) / myusample; const Standard_Real aStepSV = (aMaxV - aMinV) / myvsample; @@ -184,17 +247,12 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C, // Modif de lvt pour trimer la surface non pas aux infinis mais a +/- 10000 Standard_Real trimusup = myusup, trimumin = myumin,trimvsup = myvsup,trimvmin = myvmin; - if (Precision::IsInfinite(trimusup)){ - trimusup = aMaxParamVal; + Standard_Real aCMaxVal = GetCurvMaxParamVal (C); + if (Precision::IsInfinite(mytsup)){ + mytsup = aCMaxVal; } - if (Precision::IsInfinite(trimvsup)){ - trimvsup = aMaxParamVal; - } - if (Precision::IsInfinite(trimumin)){ - trimumin = -aMaxParamVal; - } - if (Precision::IsInfinite(trimvmin)){ - trimvmin = -aMaxParamVal; + if (Precision::IsInfinite(mytmin)){ + mytmin = -aCMaxVal; } // math_Vector Tol(1, 3); diff --git a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx index 3c0a921d4e..f5441214d9 100644 --- a/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx +++ b/src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx @@ -95,7 +95,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -180,7 +180,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , math_Vector tol(1,4); Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1); Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2); - Umin(3) = RealFirst(); + Umin(3) = RealFirst(); Umin(4) = 0.; Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1); Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2); @@ -197,7 +197,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -210,6 +210,10 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , gp_Pnt2d point3new(OnLine.Location().XY()+Ufirst(3)*Tan3.XY()); Standard_Real dist1 = point3new.Distance(point1); Standard_Real dist2 = point3new.Distance(point2); + if((dist1+dist2)/2. < Tol) + { + return; + } if ( Abs(dist1-dist2)/2. <= Tol) { cirsol = gp_Circ2d(gp_Ax2d(point3new,dirx),(dist1+dist2)/2.); Standard_Real normetan1 = Tan1.Magnitude(); @@ -294,7 +298,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); gp_Pnt2d point3 = ElCLib::Value(Param2,OnLine); Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Ufirst(3)); + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Max(Ufirst(3), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -388,7 +392,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -496,7 +500,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -601,7 +605,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -706,7 +710,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , Standard_Real R1 = OnCirc.Radius(); gp_Pnt2d point3(OnCirc.Location().XY()+R1*gp_XY(Cos(Param3),Sin(Param3))); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -807,7 +811,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); gp_Pnt2d point3 = ElCLib::Value(Param2,OnCirc); Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Ufirst(3)); + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Max(Ufirst(3), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -901,7 +905,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,Param3); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -1007,7 +1011,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -1109,7 +1113,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin& Qualified1 , gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2); gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn); Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Ufirst(4)); + Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Max(Ufirst(4), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); @@ -1201,7 +1205,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 , gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1); gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn); Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.; - Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Ufirst(3)); + Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Max(Ufirst(3), Tol)); math_FunctionSetRoot Root(Func, tol); Root.Perform(Func, Ufirst, Umin, Umax); Func.Value(Ufirst,Umin); diff --git a/src/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx b/src/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx index cdeca87d10..d9c7adec21 100644 --- a/src/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx +++ b/src/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx @@ -22,28 +22,32 @@ #include #include #include +#include //============================================================ Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C, - const Standard_Real U0, - const Standard_Real U1) + const Standard_Real U0, + const Standard_Real U1) { GeomAbs_CurveType typC = C.GetType(); Standard_Integer nbs = C.NbSamples(); if(typC == GeomAbs_BSplineCurve) { - Standard_Real t = C.LastParameter() - C.FirstParameter(); - Standard_Real t1 = U1 - U0; - if(t1 < 0.0) t1 = -t1; - nbs = C.NbKnots(); - nbs*= C.Degree(); - Standard_Real anb = t1 / t * nbs; - nbs = (Standard_Integer)anb; + Standard_Real t=C.LastParameter()-C.FirstParameter(); + if(t > Precision::PConfusion()) + { + Standard_Real t1 = U1 - U0; + if(t1 < 0.0) t1 = -t1; + nbs = C.NbKnots(); + nbs*= C.Degree(); + Standard_Real anb = t1 / t * nbs; + nbs = (Standard_Integer)anb; - Standard_Integer aMinPntNb = Max(C.Degree() + 1, 4); - if(nbs < aMinPntNb) - nbs = aMinPntNb; + Standard_Integer aMinPntNb = Max(C.Degree() + 1, 4); + if(nbs < aMinPntNb) + nbs = aMinPntNb; + } } else if (typC == GeomAbs_Circle) { diff --git a/src/GeomAdaptor/GeomAdaptor_Curve.cxx b/src/GeomAdaptor/GeomAdaptor_Curve.cxx index 5be1665b1d..90f9214919 100644 --- a/src/GeomAdaptor/GeomAdaptor_Curve.cxx +++ b/src/GeomAdaptor/GeomAdaptor_Curve.cxx @@ -142,7 +142,7 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C, myCurve = C; myNestedEvaluator.Nullify(); myBSplineCurve.Nullify(); - + const Handle(Standard_Type)& TheType = C->DynamicType(); if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) { Load(Handle(Geom_TrimmedCurve)::DownCast (C)->BasisCurve(),UFirst,ULast); @@ -540,10 +540,10 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const myCurveCache = new BSplCLib_Cache(aDeg, aBezier->IsPeriodic(), aFlatKnots, aBezier->Poles(), aBezier->Weights()); myCurveCache->BuildCache(theParameter, aDeg, aBezier->IsPeriodic(), aFlatKnots, - aBezier->Poles(), aBezier->Weights()); - } + aBezier->Poles(), aBezier->Weights()); +} else if (myTypeCurve == GeomAbs_BSplineCurve) - { +{ // Create cache for B-spline if (myCurveCache.IsNull()) myCurveCache = new BSplCLib_Cache(myBSplineCurve->Degree(), myBSplineCurve->IsPeriodic(), @@ -551,7 +551,7 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const myCurveCache->BuildCache(theParameter, myBSplineCurve->Degree(), myBSplineCurve->IsPeriodic(), myBSplineCurve->KnotSequence(), myBSplineCurve->Poles(), myBSplineCurve->Weights()); - } +} } //======================================================================= @@ -583,7 +583,7 @@ Standard_Boolean GeomAdaptor_Curve::IsBoundary(const Standard_Real theU, return Standard_True; } return Standard_False; -} + } //======================================================================= //function : Value @@ -605,7 +605,7 @@ gp_Pnt GeomAdaptor_Curve::Value(const Standard_Real U) const void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const { switch (myTypeCurve) - { +{ case GeomAbs_BezierCurve: case GeomAbs_BSplineCurve: { @@ -615,14 +615,14 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const myBSplineCurve->LocalD0(U, aStart, aFinish, P); } else - { + { // use cached data if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U)) RebuildCache(U); myCurveCache->D0(U, P); - } - break; } + break; +} case GeomAbs_OffsetCurve: myNestedEvaluator->D0(U, P); @@ -630,7 +630,7 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const default: myCurve->D0(U, P); - } +} } //======================================================================= @@ -641,7 +641,7 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const { switch (myTypeCurve) - { +{ case GeomAbs_BezierCurve: case GeomAbs_BSplineCurve: { @@ -651,14 +651,14 @@ void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const myBSplineCurve->LocalD1(U, aStart, aFinish, P, V); } else - { + { // use cached data if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U)) RebuildCache(U); myCurveCache->D1(U, P, V); - } - break; } + break; +} case GeomAbs_OffsetCurve: myNestedEvaluator->D1(U, P, V); @@ -666,7 +666,7 @@ void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const default: myCurve->D1(U, P, V); - } +} } //======================================================================= @@ -678,7 +678,7 @@ void GeomAdaptor_Curve::D2(const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const { switch (myTypeCurve) - { +{ case GeomAbs_BezierCurve: case GeomAbs_BSplineCurve: { @@ -688,14 +688,14 @@ void GeomAdaptor_Curve::D2(const Standard_Real U, myBSplineCurve->LocalD2(U, aStart, aFinish, P, V1, V2); } else - { + { // use cached data if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U)) RebuildCache(U); myCurveCache->D2(U, P, V1, V2); - } - break; } + break; +} case GeomAbs_OffsetCurve: myNestedEvaluator->D2(U, P, V1, V2); @@ -703,7 +703,7 @@ void GeomAdaptor_Curve::D2(const Standard_Real U, default: myCurve->D2(U, P, V1, V2); - } +} } //======================================================================= @@ -716,7 +716,7 @@ void GeomAdaptor_Curve::D3(const Standard_Real U, gp_Vec& V2, gp_Vec& V3) const { switch (myTypeCurve) - { +{ case GeomAbs_BezierCurve: case GeomAbs_BSplineCurve: { @@ -726,14 +726,14 @@ void GeomAdaptor_Curve::D3(const Standard_Real U, myBSplineCurve->LocalD3(U, aStart, aFinish, P, V1, V2, V3); } else - { + { // use cached data if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U)) RebuildCache(U); myCurveCache->D3(U, P, V1, V2, V3); - } - break; } + break; +} case GeomAbs_OffsetCurve: myNestedEvaluator->D3(U, P, V1, V2, V3); @@ -741,7 +741,7 @@ void GeomAdaptor_Curve::D3(const Standard_Real U, default: myCurve->D3(U, P, V1, V2, V3); - } +} } //======================================================================= @@ -753,7 +753,7 @@ gp_Vec GeomAdaptor_Curve::DN(const Standard_Real U, const Standard_Integer N) const { switch (myTypeCurve) - { +{ case GeomAbs_BezierCurve: case GeomAbs_BSplineCurve: { @@ -763,9 +763,9 @@ gp_Vec GeomAdaptor_Curve::DN(const Standard_Real U, return myBSplineCurve->LocalDN(U, aStart, aFinish, N); } else - return myCurve->DN(U, N); + return myCurve->DN( U, N); break; - } +} case GeomAbs_OffsetCurve: return myNestedEvaluator->DN(U, N); @@ -959,3 +959,15 @@ Handle(Geom_BSplineCurve) GeomAdaptor_Curve::BSpline() const return myBSplineCurve; } + +//======================================================================= +//function : BasisCurve +//purpose : +//======================================================================= + +Handle(Geom_OffsetCurve) GeomAdaptor_Curve::OffsetCurve() const +{ + if ( myTypeCurve != GeomAbs_OffsetCurve) + Standard_NoSuchObject::Raise("GeomAdaptor_Curve::OffsetCurve"); + return Handle(Geom_OffsetCurve)::DownCast(myCurve); +} diff --git a/src/GeomAdaptor/GeomAdaptor_Curve.hxx b/src/GeomAdaptor/GeomAdaptor_Curve.hxx index 1cc735c78f..690480906c 100644 --- a/src/GeomAdaptor/GeomAdaptor_Curve.hxx +++ b/src/GeomAdaptor/GeomAdaptor_Curve.hxx @@ -47,6 +47,7 @@ class gp_Hypr; class gp_Parab; class Geom_BezierCurve; class Geom_BSplineCurve; +class Geom_OffsetCurve; //! This class provides an interface between the services provided by any @@ -207,6 +208,7 @@ public: //! myFirst/Last. Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE; + Standard_EXPORT Handle(Geom_OffsetCurve) OffsetCurve() const Standard_OVERRIDE; friend class GeomAdaptor_Surface; diff --git a/src/HLRAlgo/HLRAlgo_PolyData.cxx b/src/HLRAlgo/HLRAlgo_PolyData.cxx index 108c109412..759d60fe52 100644 --- a/src/HLRAlgo/HLRAlgo_PolyData.cxx +++ b/src/HLRAlgo/HLRAlgo_PolyData.cxx @@ -415,7 +415,7 @@ void HLRAlgo_PolyData::hideByOneTriangle (const Standard_Address Coordinates, if (m[l]) { OutSideP = Standard_True; - if (o[l] != (Standard_Boolean)(n1 == -1)) { + if (o[l] != (n1 == -1)) { if (l == 0 && npi == 1) { p[0] = p[1]; o[0] = o[1]; @@ -434,7 +434,7 @@ void HLRAlgo_PolyData::hideByOneTriangle (const Standard_Address Coordinates, for (l = 0; l <= npi; l++) { if (m[l]) { OutSideP = Standard_True; - if (o[l] != (Standard_Boolean)(n1 == -1)) { + if (o[l] != (n1 == -1)) { if (l == 0 && npi == 1) { p[0] = p[1]; o[0] = o[1]; @@ -560,7 +560,7 @@ void HLRAlgo_PolyData::hideByOneTriangle (const Standard_Address Coordinates, for (l = 0; l <= npi; l++) { if (m[l]) { OutSideP = Standard_True; - if (o[l] != (Standard_Boolean)(n1 == -1)) { + if (o[l] != (n1 == -1)) { if (l == 0 && npi == 1) { p[0] = p[1]; o[0] = o[1]; @@ -579,7 +579,7 @@ void HLRAlgo_PolyData::hideByOneTriangle (const Standard_Address Coordinates, for (l = 0; l <= npi; l++) { if (m[l]) { OutSideP = Standard_True; - if (o[l] != (Standard_Boolean)(n1 == -1)) { + if (o[l] != (n1 == -1)) { if (l == 0 && npi == 1) { p[0] = p[1]; o[0] = o[1]; @@ -705,7 +705,7 @@ void HLRAlgo_PolyData::hideByOneTriangle (const Standard_Address Coordinates, for (l = 0; l <= npi; l++) { if (m[l]) { OutSideP = Standard_True; - if (o[l] != (Standard_Boolean)(n1 == -1)) { + if (o[l] != (n1 == -1)) { if (l == 0 && npi == 1) { p[0] = p[1]; o[0] = o[1]; @@ -724,7 +724,7 @@ void HLRAlgo_PolyData::hideByOneTriangle (const Standard_Address Coordinates, for (l = 0; l <= npi; l++) { if (m[l]) { OutSideP = Standard_True; - if (o[l] != (Standard_Boolean)(n1 == -1)) { + if (o[l] != (n1 == -1)) { if (l == 0 && npi == 1) { p[0] = p[1]; o[0] = o[1]; diff --git a/src/HLRAlgo/HLRAlgo_PolyInternalData.cxx b/src/HLRAlgo/HLRAlgo_PolyInternalData.cxx index f174de72f6..69c26a2ca0 100644 --- a/src/HLRAlgo/HLRAlgo_PolyInternalData.cxx +++ b/src/HLRAlgo/HLRAlgo_PolyInternalData.cxx @@ -25,12 +25,12 @@ IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData,MMgt_TShared) #define Tri1Node1 ((Standard_Integer*)Tri1Indices)[0] #define Tri1Node2 ((Standard_Integer*)Tri1Indices)[1] #define Tri1Node3 ((Standard_Integer*)Tri1Indices)[2] -#define Tri1Flags ((Standard_Boolean*)Tri1Indices)[3] +#define Tri1Flags ((Standard_Integer*)Tri1Indices)[3] #define Tri2Node1 ((Standard_Integer*)Tri2Indices)[0] #define Tri2Node2 ((Standard_Integer*)Tri2Indices)[1] #define Tri2Node3 ((Standard_Integer*)Tri2Indices)[2] -#define Tri2Flags ((Standard_Boolean*)Tri2Indices)[3] +#define Tri2Flags ((Standard_Integer*)Tri2Indices)[3] #define Seg1LstSg1 ((Standard_Integer*)Seg1Indices)[0] #define Seg1LstSg2 ((Standard_Integer*)Seg1Indices)[1] @@ -47,9 +47,9 @@ IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData,MMgt_TShared) #define Seg2Conex2 ((Standard_Integer*)Seg2Indices)[5] #define Nod1NdSg ((Standard_Integer*)Nod1Indices)[0] -#define Nod1Flag ((Standard_Boolean*)Nod1Indices)[1] -#define Nod1Edg1 ((Standard_Boolean*)Nod1Indices)[2] -#define Nod1Edg2 ((Standard_Boolean*)Nod1Indices)[3] +#define Nod1Flag ((Standard_Integer*)Nod1Indices)[1] +#define Nod1Edg1 ((Standard_Integer*)Nod1Indices)[2] +#define Nod1Edg2 ((Standard_Integer*)Nod1Indices)[3] #define Nod1PntX ((Standard_Real*)Nod1RValues)[ 0] #define Nod1PntY ((Standard_Real*)Nod1RValues)[ 1] @@ -64,9 +64,9 @@ IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData,MMgt_TShared) #define Nod1Scal ((Standard_Real*)Nod1RValues)[10] #define Nod2NdSg ((Standard_Integer*)Nod2Indices)[0] -#define Nod2Flag ((Standard_Boolean*)Nod2Indices)[1] -#define Nod2Edg1 ((Standard_Boolean*)Nod2Indices)[2] -#define Nod2Edg2 ((Standard_Boolean*)Nod2Indices)[3] +#define Nod2Flag ((Standard_Integer*)Nod2Indices)[1] +#define Nod2Edg1 ((Standard_Integer*)Nod2Indices)[2] +#define Nod2Edg2 ((Standard_Integer*)Nod2Indices)[3] #define Nod2PntX ((Standard_Real*)Nod2RValues)[ 0] #define Nod2PntY ((Standard_Real*)Nod2RValues)[ 1] @@ -81,9 +81,9 @@ IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData,MMgt_TShared) #define Nod2Scal ((Standard_Real*)Nod2RValues)[10] #define Nod3NdSg ((Standard_Integer*)Nod3Indices)[0] -#define Nod3Flag ((Standard_Boolean*)Nod3Indices)[1] -#define Nod3Edg1 ((Standard_Boolean*)Nod3Indices)[2] -#define Nod3Edg2 ((Standard_Boolean*)Nod3Indices)[3] +#define Nod3Flag ((Standard_Integer*)Nod3Indices)[1] +#define Nod3Edg1 ((Standard_Integer*)Nod3Indices)[2] +#define Nod3Edg2 ((Standard_Integer*)Nod3Indices)[3] #define Nod3PntX ((Standard_Real*)Nod3RValues)[ 0] #define Nod3PntY ((Standard_Real*)Nod3RValues)[ 1] @@ -98,9 +98,9 @@ IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData,MMgt_TShared) #define Nod3Scal ((Standard_Real*)Nod3RValues)[10] #define Nod4NdSg ((Standard_Integer*)Nod4Indices)[0] -#define Nod4Flag ((Standard_Boolean*)Nod4Indices)[1] -#define Nod4Edg1 ((Standard_Boolean*)Nod4Indices)[2] -#define Nod4Edg2 ((Standard_Boolean*)Nod4Indices)[3] +#define Nod4Flag ((Standard_Integer*)Nod4Indices)[1] +#define Nod4Edg1 ((Standard_Integer*)Nod4Indices)[2] +#define Nod4Edg2 ((Standard_Integer*)Nod4Indices)[3] #define Nod4PntX ((Standard_Real*)Nod4RValues)[ 0] #define Nod4PntY ((Standard_Real*)Nod4RValues)[ 1] diff --git a/src/HLRBRep/HLRBRep_BiPnt2D.hxx b/src/HLRBRep/HLRBRep_BiPnt2D.hxx index b85d1283fa..6b1fc43a1b 100644 --- a/src/HLRBRep/HLRBRep_BiPnt2D.hxx +++ b/src/HLRBRep/HLRBRep_BiPnt2D.hxx @@ -77,11 +77,10 @@ private: gp_Pnt2d myP1; gp_Pnt2d myP2; TopoDS_Shape myShape; - bool myRg1Line; - bool myRgNLine; - bool myOutLine; - bool myIntLine; - + Standard_Boolean myRg1Line; + Standard_Boolean myRgNLine; + Standard_Boolean myOutLine; + Standard_Boolean myIntLine; }; #endif // _HLRBRep_BiPnt2D_HeaderFile diff --git a/src/IntPolyh/IntPolyh_MaillageAffinage.cxx b/src/IntPolyh/IntPolyh_MaillageAffinage.cxx index 78ee8bd73c..5f851793aa 100644 --- a/src/IntPolyh/IntPolyh_MaillageAffinage.cxx +++ b/src/IntPolyh/IntPolyh_MaillageAffinage.cxx @@ -2193,7 +2193,7 @@ void CalculPtsInterTriEdgeCoplanaires2(const Standard_Integer TriSurfID, Standard_Real p2p = Per.Dot(PE2); Standard_Real p0p = Per.Dot(PT1); ///The edge are PT1 are projected on the perpendicular of the side in the plane of the triangle - if ( ( (p1p>=p0p)&&(p0p>=p2p) )||( (p1p<=p0p)&&(p0p<=p2p) ) ) { + if ( ( ((p1p>=p0p)&&(p0p>=p2p) )||( (p1p<=p0p)&&(p0p<=p2p) )) && (Abs(p1p-p2p) > MyConfusionPrecision)) { Standard_Real lambda=(p1p-p0p)/(p1p-p2p); if (lambda<-MyConfusionPrecision) { diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 6029068aaf..2c1d49d2db 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -2408,7 +2408,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co di << "\n"; Standard_Integer res, a =4, b = 0 ; res = a / b; - di << " 4 / 0 = " << res << " Does not Caught... KO\n"; + di << "Error: 4 / 0 = " << res << " - no exception is raised!\n"; Succes = Standard_False; } #if defined(SOLARIS) || defined(_WIN32) @@ -2417,10 +2417,9 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co catch(Standard_NumericError) #endif { - di << " Ok\n"; + di << "Caught, OK\n"; } catch(Standard_Failure) { - //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl; di << " Caught ("; di << Standard_Failure::Caught()->GetMessageString(); di << ")... KO\n"; @@ -2444,17 +2443,16 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co di << "\n"; Standard_Real res, a= 4.0, b=0.0; res = a / b; - di << " 4.0 / 0.0 = " << res << " Does not Caught... OK\n"; + di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n"; + Succes = Standard_False; } catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2 { - di << " KO\n"; - Succes = Standard_False; + di << "Caught, OK\n"; } catch(Standard_NumericError) // Linux, Windows with SSE2 { - di << " KO\n"; - Succes = Standard_False; + di << "Exception is caught, OK\n"; } catch(Standard_Failure) { //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl; @@ -2476,10 +2474,10 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co res = i + 1; //++++ cout << " -- "< Epsilon(myAC3d.LastParameter()) ) { alpha = ( firstPar - myAC3d.FirstParameter() ) / fact; @@ -305,7 +317,19 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, } else { p1 = myCurve->Value(firstPar); + if(Precision::IsInfinite(p1.X()) || Precision::IsInfinite(p1.Y()) || + Precision::IsInfinite(p1.Z())) + { + B.SameRange(newEdge, Standard_False); + return; + } p2 = myCurve->Value(lastPar); + if(Precision::IsInfinite(p2.X()) || Precision::IsInfinite(p2.Y()) || + Precision::IsInfinite(p2.Z())) + { + B.SameRange(newEdge, Standard_False); + return; + } Standard_Real fact = myLast - myFirst; if( fact > Epsilon(myLast) ) { alpha = ( firstPar - myFirst ) / fact; diff --git a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx index 9de76014e6..a49c025d36 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx @@ -1762,6 +1762,10 @@ Standard_Boolean ShapeAnalysis_Wire::CheckSmallArea(const TopoDS_Wire& theWire) myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2); return Standard_False; } + if (Precision::IsInfinite(aF) || Precision::IsInfinite(aL)) + { + continue; + } Standard_Integer aBegin = 0; if (j == 1) diff --git a/src/ShapeFix/ShapeFix_EdgeProjAux.cxx b/src/ShapeFix/ShapeFix_EdgeProjAux.cxx index 08b0065445..e19cd9b7d3 100644 --- a/src/ShapeFix/ShapeFix_EdgeProjAux.cxx +++ b/src/ShapeFix/ShapeFix_EdgeProjAux.cxx @@ -43,6 +43,8 @@ #include #include #include +#include +#include IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_EdgeProjAux,MMgt_TShared) @@ -281,8 +283,26 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci) if(theCurve2d->IsKind(STANDARD_TYPE(Geom2d_Line))) { Standard_Real uf,ul,vf,vl; theSurface->Bounds(uf,ul,vf,vl); + //Correct surface limits for extrusion/revolution surfaces based on hyperbola + //23 is ln(1.0e+10) + if(SA.GetType() == GeomAbs_SurfaceOfExtrusion) + { + if(SA.BasisCurve()->GetType() == GeomAbs_Hyperbola) + { + uf = Max(uf, -23.); + ul = Min(ul, 23.); + } + } + if(SA.GetType() == GeomAbs_SurfaceOfRevolution) + { + if(SA.BasisCurve()->GetType() == GeomAbs_Hyperbola) + { + vf = Max(vf, -23.); + vl = Min(vl, 23.); + } + } if(!Precision::IsInfinite(uf)&&!Precision::IsInfinite(ul)&& - !Precision::IsInfinite(vf)&&!Precision::IsInfinite(vl)) { + !Precision::IsInfinite(vf)&&!Precision::IsInfinite(vl)) { Standard_Real cfi,cli; Handle(Geom2d_Line) lin = Handle(Geom2d_Line)::DownCast(theCurve2d); gp_Pnt2d pnt = lin->Location(); @@ -343,6 +363,17 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci) //pdn not linear case not managed cf=-10000; cl= 10000; + if(theCurve2d->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) + { + //Try to reparametrize (CASE dxf read bug25899) + Handle(Geom2d_BSplineCurve) aBspl = Handle(Geom2d_BSplineCurve)::DownCast(theCurve2d->Copy()); + TColStd_Array1OfReal aNewKnots(1, aBspl->NbKnots()); + aBspl->Knots(aNewKnots); + BSplCLib::Reparametrize(cf, cl, aNewKnots); + aBspl->SetKnots(aNewKnots); + theCurve2d = aBspl; + } + #ifdef OCCT_DEBUG cout<<"Some infinite curve"< 0.71047586007394394e+03 ){ + Standard_NumericError::Raise("Result of Cosh exceeds the maximum value Standard_Real"); +#ifdef OCCT_DEBUG + cout << "Result of Cosh exceeds the maximum value Standard_Real" << endl ; +#endif + } + return cosh(Value); +} + +//------------------------------------------------------------------- +// Sinh : Returns the hyperbolicsine of a real +//------------------------------------------------------------------- +Standard_Real Sinh (const Standard_Real Value) +{ + if ( Abs(Value) > 0.71047586007394394e+03 ){ + Standard_NumericError::Raise("Result of Sinh exceeds the maximum value Standard_Real"); +#ifdef OCCT_DEBUG + cout << "Result of Sinh exceeds the maximum value Standard_Real" << endl ; +#endif + } + return sinh(Value); +} + //------------------------------------------------------------------- // Log : Returns the naturaOPl logarithm of a real //------------------------------------------------------------------- diff --git a/src/Standard/Standard_Real.hxx b/src/Standard/Standard_Real.hxx index 6ce243eebd..84e84e0832 100644 --- a/src/Standard/Standard_Real.hxx +++ b/src/Standard/Standard_Real.hxx @@ -40,6 +40,8 @@ __Standard_API Standard_Real NextAfter (const Standard_Real , const Standar __Standard_API Standard_Real Sign (const Standard_Real , const Standard_Real ); __Standard_API Standard_Real ATanh (const Standard_Real ); __Standard_API Standard_Real ACosh (const Standard_Real ); +__Standard_API Standard_Real Sinh (const Standard_Real ); +__Standard_API Standard_Real Cosh (const Standard_Real ); __Standard_API Standard_Real Log (const Standard_Real ); __Standard_API Standard_Real Sqrt (const Standard_Real ); @@ -161,12 +163,6 @@ inline Standard_Real Ceiling (const Standard_Real Value) inline Standard_Real Cos (const Standard_Real Value) { return cos(Value); } -//------------------------------------------------------------------- -// Cosh : Returns the hyperbolic cosine of a real -//------------------------------------------------------------------- -inline Standard_Real Cosh (const Standard_Real Value) -{ return cosh(Value); } - //------------------------------------------------------------------- // Epsilon : The function returns absolute value of difference @@ -285,11 +281,6 @@ inline Standard_Real Round (const Standard_Real Value) inline Standard_Real Sin (const Standard_Real Value) { return sin(Value); } -//------------------------------------------------------------------- -// Sinh : Returns the hyperbolic sine of a real -//------------------------------------------------------------------- -inline Standard_Real Sinh(const Standard_Real Value) -{ return sinh(Value); } //------------------------------------------------------------------- // ASinh : Returns the hyperbolic arc sine of a real diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index bcc5c64caa..43e5d31787 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -959,18 +959,30 @@ static Standard_Integer meshvectors( Draw_Interpretor& di, Standard_Integer aNbNodes; MeshVS_EntityType aEntType; + TColStd_Array1OfReal aCoords(1, 3); + aCoords.Init (0.); TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs ); for ( ; anIter.More(); anIter.Next() ) { - TColStd_Array1OfReal aCoords(1, 3); + Standard_Boolean IsValidData = Standard_False; if (anIsElement) - aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3)); + IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3)); else - aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType); + IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType); - gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); - if( !aNorm.Magnitude() ) + gp_Vec aNorm; + if(IsValidData) + { + aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); + if(aNorm.Magnitude() < gp::Resolution()) + { + aNorm = gp_Vec(0,0,1); //method GetGeom(...) returns coordinates of nodes + } + } + else + { aNorm = gp_Vec(0,0,1); + } aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized()); } diff --git a/src/math/math_FunctionRoots.cxx b/src/math/math_FunctionRoots.cxx index 43903ba4d6..7e19758b51 100644 --- a/src/math/math_FunctionRoots.cxx +++ b/src/math/math_FunctionRoots.cxx @@ -934,7 +934,7 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, else { AA = Fyu-Fxu;} if (!Sol.IsEmpty()) { if (Abs(Sol.Last() - U) > 5.*EpsX - || OldDF*AA < 0. ) { + || (OldDF != RealLast() && OldDF*AA < 0.) ) { Sol.Append(U); NbStateSol.Append(F.GetStateNumber()); } diff --git a/src/math/math_FunctionSetRoot.cxx b/src/math/math_FunctionSetRoot.cxx index aa41d3dadb..7e2f7a1afb 100644 --- a/src/math/math_FunctionSetRoot.cxx +++ b/src/math/math_FunctionSetRoot.cxx @@ -254,6 +254,10 @@ static Standard_Boolean MinimizeDirection(const math_Vector& P, //---------------------------------------------------------------------- { + if(Precision::IsInfinite(PValue) || Precision::IsInfinite(PDirValue)) + { + return Standard_False; + } // (0) Evaluation d'un tolerance parametrique 1D Standard_Boolean good = Standard_False; Standard_Real Eps = 1.e-20; @@ -716,9 +720,9 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F, math_Vector InvLengthMax(1, Ninc); // Pour bloquer les pas a 1/4 du domaine math_IntegerVector aConstraints(1, Ninc); // Pour savoir sur quels bord on se trouve for (i = 1; i <= Ninc ; i++) { - // modified by NIZHNY-MKK Mon Oct 3 18:03:50 2005 - // InvLengthMax(i) = 1. / Max(Abs(SupBound(i) - InfBound(i))/4, 1.e-9); - InvLengthMax(i) = 1. / Max((theSupBound(i) - theInfBound(i))/4, 1.e-9); + const Standard_Real aSupBound = Min (theSupBound(i), Precision::Infinite()); + const Standard_Real anInfBound = Max (theInfBound(i), -Precision::Infinite()); + InvLengthMax(i) = 1. / Max((aSupBound - anInfBound)/4, 1.e-9); } MyDirFunction F_Dir(Temp1, Temp2, Temp3, Temp4, F); diff --git a/tests/bugs/fclasses/bug6143 b/tests/bugs/fclasses/bug6143 index 3e1ffff6e9..a3bbb06c77 100644 --- a/tests/bugs/fclasses/bug6143 +++ b/tests/bugs/fclasses/bug6143 @@ -1,4 +1,6 @@ puts "TODO OCC24156 MacOS: Faulty OCC6143" +puts "TODO OCC27713 Linux: Faulty OCC6143" +puts "TODO OCC27713 Linux: Error" puts "================" puts "OCC1723" @@ -16,14 +18,15 @@ pload QAcommands set BugNumber OCC6143 -set OK_string "TestExcept: Successfull completion\n" +dsetsignal 1 set IsDone [catch {set aResult [OCC6143]} result] +dsetsignal if { ${IsDone} != 0 } { puts "result = ${result}" puts "Faulty ${BugNumber}" } else { - if { [string first ${OK_string} ${aResult} ] != -1 } { + if { [string first "TestExcept: Successfull completion" ${aResult} ] != -1 } { puts "OK ${BugNumber}" } else { puts "Faulty ${BugNumber}" diff --git a/tests/bugs/moddata_1/bug22759 b/tests/bugs/moddata_1/bug22759 index ee0042c42d..c9d306eb31 100755 --- a/tests/bugs/moddata_1/bug22759 +++ b/tests/bugs/moddata_1/bug22759 @@ -31,4 +31,4 @@ vfit vsetdispmode 1 checkview -screenshot -3d -path ${imagedir}/${test_image}.png -checkprops result -s 9951.34 +checkprops result -s 9994.76 diff --git a/tests/bugs/vis/bug23226 b/tests/bugs/vis/bug23226 index 5cdf5d42ec..fdf76f443d 100755 --- a/tests/bugs/vis/bug23226 +++ b/tests/bugs/vis/bug23226 @@ -319,6 +319,7 @@ for {set vbo_enable 0} {$vbo_enable < 2} {incr vbo_enable} { # # 4: vertices, bounds and edges # + generate_points -140 0 0 $colorG_R $colorG_G $colorG_B eval vdrawparray poly04 polygons $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 ( b 5 ( e 4 e 2 e 1 e 3 e 6 )), ( b 3 ( e 6 e 3 e 5 )) @@ -326,8 +327,9 @@ for {set vbo_enable 0} {$vbo_enable < 2} {incr vbo_enable} { vfit # dump resulted image - if { $vbo_enable == 0 } { vfeedback; vdump ${imagedir}/$ImageName1 } - if { $vbo_enable == 1 } { vfeedback; vdump ${imagedir}/$ImageName2 } +# vfeedback ;# fails on Intel HD 4600 with FPE signals armed + if { $vbo_enable == 0 } { vdump ${imagedir}/$ImageName1 } + if { $vbo_enable == 1 } { vdump ${imagedir}/$ImageName2 } } diff --git a/tests/offset/with_intersect_20/J9 b/tests/offset/with_intersect_20/J9 index 55246c9a3b..3be5c693f3 100644 --- a/tests/offset/with_intersect_20/J9 +++ b/tests/offset/with_intersect_20/J9 @@ -1,5 +1,8 @@ -puts "TODO OCC26577 All: Error : is WRONG because number of EDGE entities in shape" -puts "TODO OCC26577 All: Error : is WRONG because number of SHELL entities in shape" +#puts "TODO OCC26577 All: Error : is WRONG because number of EDGE entities in shape" +#puts "TODO OCC26577 All: Error : is WRONG because number of SHELL entities in shape" +puts "TODO 26329 All: Standard_ConstructionError: BRepOffset_MakeOffset::TrimEdge no projection" +puts "TODO 26329 All: TEST INCOMPLETE" + restore [locate_data_file bug26663_test_offset_J9.brep] s OFFSETSHAPE ${off_param} {} ${calcul} ${type} checknbshapes result -ref [lrange [nbshapes s] 8 19] diff --git a/tests/offset/with_intersect_80/J9 b/tests/offset/with_intersect_80/J9 index 5c5f4e7904..4db409e01e 100644 --- a/tests/offset/with_intersect_80/J9 +++ b/tests/offset/with_intersect_80/J9 @@ -1,6 +1,9 @@ -puts "TODO OCC26578 All:An exception was caught" -puts "TODO OCC26578 All:\\*\\* Exception \\*\\*" -puts "TODO OCC26578 All:TEST INCOMPLETE" +#puts "TODO OCC26578 All:An exception was caught" +#puts "TODO OCC26578 All:\\*\\* Exception \\*\\*" +#puts "TODO OCC26578 All:TEST INCOMPLETE" +puts "TODO OCC26578 All: Error : is WRONG because number of EDGE" +puts "TODO OCC26578 All: Error : is WRONG because number of SHELL" +#puts "TODO OCC26578 All: Faulty shapes in variables faulty_1" restore [locate_data_file bug26663_test_offset_J9.brep] s OFFSETSHAPE ${off_param} {} ${calcul} ${type} checknbshapes result -ref [lrange [nbshapes s] 8 19] diff --git a/tests/offset/with_intersect_80/K8 b/tests/offset/with_intersect_80/K8 index c7b86dc3dd..d3cbc902b3 100644 --- a/tests/offset/with_intersect_80/K8 +++ b/tests/offset/with_intersect_80/K8 @@ -1,6 +1,8 @@ -puts "TODO OCC26578 All:An exception was caught" -puts "TODO OCC26578 All:\\*\\* Exception \\*\\*" -puts "TODO OCC26578 All:TEST INCOMPLETE" +#puts "TODO OCC26578 All:An exception was caught" +#puts "TODO OCC26578 All:\\*\\* Exception \\*\\*" +puts "TODO OCC26578 All:is WRONG" +puts "TODO OCC26578 All:Faulty shapes in variables faulty_1 to faulty_" +# restore [locate_data_file bug26663_test_offset_K8.brep] s OFFSETSHAPE ${off_param} {} ${calcul} ${type} checknbshapes result -ref [lrange [nbshapes s] 8 19] diff --git a/tests/v3d/mesh/B7 b/tests/v3d/mesh/B7 index afd1f7ac0b..17c86a4335 100644 --- a/tests/v3d/mesh/B7 +++ b/tests/v3d/mesh/B7 @@ -5,7 +5,7 @@ vrotate 0 0.5 0 meshtext m vsetdispmode m 33 vdump $::imagedir/${::casename}_txt.png -meshvectors m -mode elem -maxlen 10 -color green -arrowpart 0.5 -issipmle 0 +meshvectors m -mode elem -maxlen 10 -color green -arrowpart 0.5 -issimple 0 vsetdispmode m 5 vdump $::imagedir/${::casename}_vct1.png meshvectors m -mode nodal -maxlen 20 -color white -issimple 1