]> OCCT Git - occt-copy.git/commitdiff
Minor optimizations
authorabv <abv@opencascade.com>
Sat, 13 Aug 2016 06:00:50 +0000 (09:00 +0300)
committerabv <abv@opencascade.com>
Sat, 13 Aug 2016 06:00:50 +0000 (09:00 +0300)
src/ApproxInt/ApproxInt_KnotTools.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BRepGProp/BRepGProp_Face.cxx
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx
src/math/math_FunctionSetRoot.cxx

index 980a58fb2d3a05d6714da1b565c06fbfde6d2af7..eb0e5bc55ab710ef37c5a8d3aa78aa77fa9a6567 100644 (file)
@@ -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<Standard_Integer>& 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);
index 36971a06f661adc50961c0fe403c137f48b20e99..b6730c0a30144a7869817054a8814b3ceba1b97d 100644 (file)
@@ -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) {
index 235c3165713cbe26014fb91ba346628aa0bbfb21..4484d214b10cec624bf1c8191e5823695bdac406 100644 (file)
@@ -34,6 +34,8 @@
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 
+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));
index d3403f982e63c85e40ea8e37193ae29c024c8e19..3cf48a864c1c9777913ea81336eb7f5977d5764d 100644 (file)
@@ -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;
index 566701417897013bc3fb3f852374dff29c750d37..733c70919a2c27866a587e3ea6b038566ffbcd9f 100644 (file)
@@ -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));
index d2d6a6783ed7ea5b3e8ce3d0e62af12048082691..f234924bbef39d9c4f54c7342da1eeb447c1f96f 100644 (file)
@@ -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);
   }