From: abv Date: Sat, 13 Aug 2016 06:00:50 +0000 (+0300) Subject: Minor optimizations X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=a3fe556cead5a90ccb9994c82df4fc5c9e6ab6cb;p=occt-copy.git Minor optimizations --- diff --git a/src/ApproxInt/ApproxInt_KnotTools.cxx b/src/ApproxInt/ApproxInt_KnotTools.cxx index 980a58fb2d..eb0e5bc55a 100644 --- a/src/ApproxInt/ApproxInt_KnotTools.cxx +++ b/src/ApproxInt/ApproxInt_KnotTools.cxx @@ -30,7 +30,7 @@ // (Sqrt(5.0) - 1.0) / 4.0 static const Standard_Real aSinCoeff = 0.30901699437494742410229341718282; static const Standard_Integer aMaxPntCoeff = 15; - +static const Standard_Real Epsilon1 = Epsilon(1.); //======================================================================= //function : EvalCurv @@ -439,7 +439,6 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI, NCollection_Sequence& theInds, const Standard_Boolean ChkCurv) { - const Standard_Real eps = Epsilon(1.); Standard_Integer anInd1 = theInds(theI); Standard_Integer anInd = theInds(theI - 1); // @@ -521,16 +520,7 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI, //mp *= 2.; //P(j,i) = -P(i,j); // Standard_Real m1m2 = m1*m2; - if(m1m2 > eps) - { - sina = mp/m1m2; - } - else - { - sina = 0.; - } - sina = Sqrt(sina); - + sina = (m1m2 > Epsilon1 ? Sqrt (mp / m1m2) : 0.); if(sina > aSinCoeff) { theInds.InsertBefore(theI, mid); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 36971a06f6..b6730c0a30 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -1275,20 +1275,14 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock // if (iFlag1 == 1) { iFlag1 = !myContext->ComputePE(aP1, aRealTol, aSp, aTx, aDist); - if(iFlag1) - { - if (theTolNew < aDist) - theTolNew = aDist; - } + if (iFlag1 && theTolNew < aDist) + theTolNew = aDist; } // if (iFlag2 == 1) { iFlag2 = !myContext->ComputePE(aP2, aRealTol, aSp, aTx, aDist); - if(iFlag2) - { - if (theTolNew < aDist) - theTolNew = aDist; - } + if (iFlag2 && theTolNew < aDist) + theTolNew = aDist; } // if (iFlag1 && iFlag2) { diff --git a/src/BRepGProp/BRepGProp_Face.cxx b/src/BRepGProp/BRepGProp_Face.cxx index 235c316571..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 : @@ -382,7 +384,6 @@ void BRepGProp_Face::VKnots(TColStd_Array1OfReal& Knots) const Standard_Integer BRepGProp_Face::LIntOrder(const Standard_Real Eps) const { Bnd_Box2d aBox; - const Standard_Real eps = Epsilon(1.); BndLib_Add2dCurve::Add(myCurve, 1.e-7, aBox); Standard_Real aXmin, aXmax, aYmin, aYmax; @@ -391,12 +392,7 @@ Standard_Integer BRepGProp_Face::LIntOrder(const Standard_Real Eps) const Standard_Real aVmax = mySurface.LastVParameter(); Standard_Real dv = (aVmax-aVmin); - Standard_Real anR = 1.; - if(dv > eps) - { - anR = (aYmax-aYmin) / dv; - anR = Min(anR, 1.); - } + 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/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx b/src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx index d3403f982e..3cf48a864c 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx @@ -299,16 +299,14 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, if(Precision::IsInfinite(p1.X()) || Precision::IsInfinite(p1.Y()) || Precision::IsInfinite(p1.Z())) { - samerange = Standard_False; - B.SameRange(newEdge, samerange); + B.SameRange(newEdge, Standard_False); return; } p2 = myAC3d.Value(lastPar).Transformed(myLocation); if(Precision::IsInfinite(p2.X()) || Precision::IsInfinite(p2.Y()) || Precision::IsInfinite(p2.Z())) { - samerange = Standard_False; - B.SameRange(newEdge, samerange); + B.SameRange(newEdge, Standard_False); return; } Standard_Real fact = myAC3d.LastParameter() - myAC3d.FirstParameter(); @@ -322,16 +320,14 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge, if(Precision::IsInfinite(p1.X()) || Precision::IsInfinite(p1.Y()) || Precision::IsInfinite(p1.Z())) { - samerange = Standard_False; - B.SameRange(newEdge, samerange); + B.SameRange(newEdge, Standard_False); return; } p2 = myCurve->Value(lastPar); if(Precision::IsInfinite(p2.X()) || Precision::IsInfinite(p2.Y()) || Precision::IsInfinite(p2.Z())) { - samerange = Standard_False; - B.SameRange(newEdge, samerange); + B.SameRange(newEdge, Standard_False); return; } Standard_Real fact = myLast - myFirst; diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index 5667014178..733c70919a 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -959,13 +959,11 @@ 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); - aCoords(1) = 0.; - aCoords(2) = 0.; - aCoords(3) = 0.; Standard_Boolean IsValidData = Standard_False; if (anIsElement) IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3)); diff --git a/src/math/math_FunctionSetRoot.cxx b/src/math/math_FunctionSetRoot.cxx index d2d6a6783e..f234924bbe 100644 --- a/src/math/math_FunctionSetRoot.cxx +++ b/src/math/math_FunctionSetRoot.cxx @@ -720,26 +720,8 @@ 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); - Standard_Real SupBound = theSupBound(i), InfBound = theInfBound(i); - if(Precision::IsNegativeInfinite(SupBound)) - { - SupBound = -Precision::Infinite(); - } - else if(Precision::IsPositiveInfinite(SupBound)) - { - SupBound = Precision::Infinite(); - } - if(Precision::IsNegativeInfinite(InfBound)) - { - InfBound = -Precision::Infinite(); - } - else if(Precision::IsPositiveInfinite(InfBound)) - { - InfBound = Precision::Infinite(); - } - + Standard_Real SupBound = Min (theSupBound(i), Precision::Infinite()); + Standard_Real InfBound = Max (theInfBound(i), -Precision::Infinite()); InvLengthMax(i) = 1. / Max((SupBound - InfBound)/4, 1.e-9); }