mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
# use std::vector in Extrema_FuncPSNorm
# Minimize the grid cell bounding box
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
@@ -23,14 +23,12 @@
|
||||
#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;
|
||||
|
@@ -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));
|
||||
|
||||
|
Reference in New Issue
Block a user