]> OCCT Git - occt-copy.git/commitdiff
# use std::vector in Extrema_FuncPSNorm CR30892_1
authoremv <emv@opencascade.com>
Thu, 27 Aug 2020 09:30:45 +0000 (12:30 +0300)
committeremv <emv@opencascade.com>
Thu, 27 Aug 2020 13:48:00 +0000 (16:48 +0300)
# Minimize the grid cell bounding box

src/Extrema/Extrema_FuncPSNorm.cxx
src/Extrema/Extrema_FuncPSNorm.hxx
src/Extrema/Extrema_GenExtPS.cxx

index de92b61a0bd5670903780b28b835072630e8f2ae..023becee1d22a7435b72ed91beb93f1d97e8a23d 100644 (file)
@@ -57,8 +57,8 @@ void Extrema_FuncPSNorm::Initialize(const Adaptor3d_Surface& S)
 {
   myS = (Adaptor3d_SurfacePtr)&S;
   mySinit = Standard_True;
-  myPoints.Clear();
-  mySqDistances.Clear();
+  myPoints.clear();
+  mySqDistances.clear();
   myTarget = Extrema_ExtFlag_MINMAX;
   myBestSqDistance = -1;
 }
@@ -72,8 +72,8 @@ void Extrema_FuncPSNorm::SetPoint (const gp_Pnt& P,
   myPinit = Standard_True;
   myTarget = theTarget;
   myBestSqDistance = (myTarget == Extrema_ExtFlag_MIN ? RealLast() : RealFirst());
-  myPoints.Clear();
-  mySqDistances.Clear();
+  myPoints.clear();
+  mySqDistances.clear();
 }
 
 //=============================================================================
@@ -149,11 +149,11 @@ Standard_Integer Extrema_FuncPSNorm::GetStateNumber()
 
   // Comparison of solution with previous solutions
   Standard_Real tol2d = Precision::SquarePConfusion();
-  Standard_Integer i = 0, nbSol = mySqDistances.Length();
+  std::size_t i = 0, nbSol = mySqDistances.size();
   for (; i < nbSol; i++)
   {
     Standard_Real aU, aV;
-    Extrema_POnSurf& aPOnSurf = myPoints (i);
+    Extrema_POnSurf& aPOnSurf = myPoints[i];
     aPOnSurf.Parameter (aU, aV);
     if (((myU - aU) * (myU - aU) + (myV - aV) * (myV - aV)) <= tol2d)
     {
@@ -161,7 +161,7 @@ Standard_Integer Extrema_FuncPSNorm::GetStateNumber()
       if (myTarget != Extrema_ExtFlag_MINMAX)
       {
         // Check if new solution gives better distance than the existing solution.
-        Standard_Real& anOldSqDist = mySqDistances (i);
+        Standard_Real& anOldSqDist = mySqDistances[i];
         if ((myTarget == Extrema_ExtFlag_MIN && aNewSqDist < anOldSqDist) ||
             (myTarget == Extrema_ExtFlag_MAX && aNewSqDist > anOldSqDist))
         {
@@ -174,27 +174,27 @@ Standard_Integer Extrema_FuncPSNorm::GetStateNumber()
   }
   if (i < nbSol)
     return 0;
-  mySqDistances.Append (aNewSqDist);
-  myPoints.Append (Extrema_POnSurf (myU, myV, myPs));
+  mySqDistances.push_back (aNewSqDist);
+  myPoints.push_back (Extrema_POnSurf (myU, myV, myPs));
   return 0;
 }
 //=============================================================================
 
 Standard_Integer Extrema_FuncPSNorm::NbExt () const
 {
-  return mySqDistances.Length();
+  return static_cast<Standard_Integer>(mySqDistances.size());
 }
 //=============================================================================
 
 Standard_Real Extrema_FuncPSNorm::SquareDistance (const Standard_Integer N) const
 {
   if (!myPinit || !mySinit) throw Standard_TypeMismatch();
-  return mySqDistances (N - 1);
+  return mySqDistances [N - 1];
 }
 //=============================================================================
 
 const Extrema_POnSurf& Extrema_FuncPSNorm::Point (const Standard_Integer N) const
 {
   if (!myPinit || !mySinit) throw Standard_TypeMismatch();
-  return myPoints (N - 1);
+  return myPoints [N - 1];
 }
index 9fef7eb9ae649f6a2b061c9acc2e984859639a1d..c7513fcaa10103090f8691d0495e80a2f4f94c5e 100644 (file)
 #include <gp_Pnt.hxx>
 #include <Adaptor3d_SurfacePtr.hxx>
 #include <Standard_Real.hxx>
-#include <TColStd_SequenceOfReal.hxx>
-#include <Extrema_SequenceOfPOnSurf.hxx>
 #include <Extrema_ExtFlag.hxx>
 #include <Standard_Boolean.hxx>
 #include <math_FunctionSetWithDerivatives.hxx>
 #include <Standard_Integer.hxx>
 #include <math_Vector.hxx>
-#include <NCollection_Vector.hxx>
+#include <vector>
 class Standard_OutOfRange;
 class gp_Pnt;
 class Adaptor3d_Surface;
@@ -123,8 +121,8 @@ private:
   Standard_Real myU;
   Standard_Real myV;
   gp_Pnt myPs;
-  NCollection_Vector<Standard_Real> mySqDistances;
-  NCollection_Vector<Extrema_POnSurf> myPoints;
+  std::vector<Standard_Real> mySqDistances;
+  std::vector<Extrema_POnSurf> myPoints;
   Standard_Boolean myPinit;
   Standard_Boolean mySinit;
   Extrema_ExtFlag myTarget;
index 7b5d924db6088eb3613c69009bb57d29b14f6f39..96da9d12dd70681a9c8acd62f47dce5f21b0f740 100644 (file)
@@ -479,13 +479,22 @@ void Extrema_GenExtPS::BuildTree()
         if (U1 != U2 || V1 != V2)
         {
           gp_Pnt aPMid = myS->Value ((U1 + U2) * 0.5, (V1 + V2) * 0.5);
-          aGridBox.Add (aPMid);
 
           gp_Vec aDir (aPMin.Value(), aPMax.Value());
-          if (aDir.SquareMagnitude() > gp::Resolution())
+          Standard_Real diag = aDir.SquareMagnitude();
+          if (diag > gp::Resolution())
           {
+            //aDir /= Sqrt (diag);
+            //gp_XYZ aPL = aPMin.Value().XYZ() + ((aPMid.XYZ() - aPMin.Value().XYZ()).Dot (aDir.XYZ())) * aDir.XYZ();
+            //gp_XYZ aVMid (aPL - aPMid.XYZ());
+            //aGridBox.Add (gp_Pnt (aPL - 1.1 * aVMid));
+            //aGridBox.Add (gp_Pnt (aPL + 1.1 * aVMid));
             aGridBox.Enlarge (gp_Lin (aPMin.Value(), aDir).Distance (aPMid));
           }
+          else
+          {
+            aGridBox.Add (aPMid);
+          }
         }
         aGridSet.CellBoxSet->UpdateBox (iCell, Bnd_Tools::Bnd2BVH (aGridBox));