From 278d35bf7040224e0b0b9c981d53a0e34e33ba7a Mon Sep 17 00:00:00 2001 From: abv Date: Sat, 13 Aug 2016 09:59:00 +0300 Subject: [PATCH] // minor --- src/Extrema/Extrema_GenExtCS.cxx | 99 ++++++++++---------------------- 1 file changed, 30 insertions(+), 69 deletions(-) diff --git a/src/Extrema/Extrema_GenExtCS.cxx b/src/Extrema/Extrema_GenExtCS.cxx index ce19e79d32..edf02474a6 100644 --- a/src/Extrema/Extrema_GenExtCS.cxx +++ b/src/Extrema/Extrema_GenExtCS.cxx @@ -38,92 +38,53 @@ #include #include #include +#include -const Standard_Real UMaxParamVal = 1.0e+10; -const Standard_Real VMaxParamVal = 1.0e+10; -const Standard_Real CMaxParamVal = 1.0e+10; +const Standard_Real MaxParamVal = 1.0e+10; const Standard_Real aBorderDivisor = 1.0e+4; -const Standard_Real HyperbolaLimit = 23.; //ln(UMaxParamVal) +const Standard_Real HyperbolaLimit = 23.; //ln(MaxParamVal) -static void GetSurfMaxParamVals(const Adaptor3d_SurfacePtr theS, - Standard_Real& theUmax, Standard_Real& theVmax) +// restrict maximal parameter on hyperbola to avoid FPE +static Standard_Real GetCurvMaxParamVal (const Adaptor3d_Curve& theC) { - // determine if the surface is extrusion or revolution - // and its basis curve is hyperbola - theUmax = UMaxParamVal; - theVmax = VMaxParamVal; - Handle(Adaptor3d_HCurve) aBC; - GeomAbs_SurfaceType aST = GeomAbs_OtherSurface; - if(theS->GetType() == GeomAbs_OffsetSurface) + if (theC.GetType() == GeomAbs_Hyperbola) { - Handle(Adaptor3d_HSurface) aBS = theS->BasisSurface(); - if(aBS->GetType() == GeomAbs_SurfaceOfExtrusion || - aBS->GetType() == GeomAbs_SurfaceOfRevolution) - { - aST = aBS->GetType(); - aBC = aBS->BasisCurve(); - } - else - { - return; - } - } - else if(theS->GetType() == GeomAbs_SurfaceOfExtrusion || - theS->GetType() == GeomAbs_SurfaceOfRevolution) - { - aST = theS->GetType(); - aBC = theS->BasisCurve(); - } - else - { - return; - } - // - Standard_Boolean isHypebola = (aBC->GetType() == GeomAbs_Hyperbola); - if(!isHypebola && aBC->GetType() == GeomAbs_OffsetCurve) - { - isHypebola = aBC->OffsetCurve()->BasisCurve()->IsKind(STANDARD_TYPE(Geom_Hyperbola)); + return HyperbolaLimit; } - - if (isHypebola) + if (theC.GetType() == GeomAbs_OffsetCurve) { - if(aST == GeomAbs_SurfaceOfExtrusion) - { - theUmax = HyperbolaLimit; - } - else + Handle(Geom_Curve) aBC (theC.OffsetCurve()->BasisCurve()); + Handle(Geom_TrimmedCurve) aTC = Handle(Geom_TrimmedCurve)::DownCast (aBC); + if (! aTC.IsNull()) { - theVmax = HyperbolaLimit; + aBC = aTC->BasisCurve(); } + if (aBC->IsKind (STANDARD_TYPE(Geom_Hyperbola))) + return HyperbolaLimit; } - return; + return MaxParamVal; } -// -static Standard_Real GetCurvMaxParamVal(const Adaptor3d_Curve& theC) + +// restrict maximal parameter on surfaces based on hyperbola to avoid FPE +static void GetSurfMaxParamVals (const Adaptor3d_Surface& theS, + Standard_Real& theUmax, Standard_Real& theVmax) { - if(theC.GetType() == GeomAbs_OffsetCurve) + theUmax = theVmax = MaxParamVal; + + if (theS.GetType() == GeomAbs_SurfaceOfExtrusion) { - Standard_Boolean isHypebola = - theC.OffsetCurve()->BasisCurve()->IsKind(STANDARD_TYPE(Geom_Hyperbola)); - if (isHypebola) - { - return HyperbolaLimit; - } - else - { - return CMaxParamVal; - } + theUmax = GetCurvMaxParamVal (theS.BasisCurve()->Curve()); } - else if(theC.GetType() == GeomAbs_Hyperbola) + else if (theS.GetType() == GeomAbs_SurfaceOfRevolution) { - return HyperbolaLimit; + theVmax = GetCurvMaxParamVal (theS.BasisCurve()->Curve()); } - else + else if (theS.GetType() == GeomAbs_OffsetSurface) { - return CMaxParamVal; + GetSurfMaxParamVals (theS.BasisSurface()->Surface(), theUmax, theVmax); } - // } + //======================================================================= //function : Extrema_GenExtCS //purpose : @@ -212,7 +173,7 @@ void Extrema_GenExtCS::Initialize (const Adaptor3d_Surface& S, mytol2 = Tol2; Standard_Real umaxpar, vmaxpar; - GetSurfMaxParamVals(myS, umaxpar, vmaxpar); + GetSurfMaxParamVals(*myS, umaxpar, vmaxpar); if(Precision::IsInfinite (myusup)) { @@ -286,7 +247,7 @@ 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; - Standard_Real aCMaxVal = GetCurvMaxParamVal(C); + Standard_Real aCMaxVal = GetCurvMaxParamVal (C); if (Precision::IsInfinite(mytsup)){ mytsup = aCMaxVal; } -- 2.39.5