1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

# cosmetics

This commit is contained in:
emv
2020-05-28 11:41:34 +03:00
parent 03a1dbbdf2
commit c3db2cba33
4 changed files with 52 additions and 50 deletions

View File

@@ -57,8 +57,8 @@ void Extrema_FuncPSNorm::Initialize(const Adaptor3d_Surface& S)
{
myS = (Adaptor3d_SurfacePtr)&S;
mySinit = Standard_True;
myPoint.Clear();
mySqDist.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());
myPoint.Clear();
mySqDist.Clear();
myPoints.Clear();
mySqDistances.Clear();
}
//=============================================================================
@@ -149,51 +149,52 @@ Standard_Integer Extrema_FuncPSNorm::GetStateNumber()
// Comparison of solution with previous solutions
Standard_Real tol2d = Precision::SquarePConfusion();
Standard_Integer i = 1, nbSol = mySqDist.Length();
for (; i <= nbSol; i++)
Standard_Integer i = 0, nbSol = mySqDistances.Length();
for (; i < nbSol; i++)
{
Standard_Real aU, aV;
myPoint (i).Parameter (aU, aV);
Extrema_POnSurf& aPOnSurf = myPoints (i);
aPOnSurf.Parameter (aU, aV);
if (((myU - aU) * (myU - aU) + (myV - aV) * (myV - aV)) <= tol2d)
{
// The points are almost the same in the parametric space.
if (myTarget != Extrema_ExtFlag_MINMAX)
{
// Check if new solution gives better distance than the existing solution.
Standard_Real& anOldSqDist = mySqDist (i);
Standard_Real& anOldSqDist = mySqDistances (i);
if ((myTarget == Extrema_ExtFlag_MIN && aNewSqDist < anOldSqDist) ||
(myTarget == Extrema_ExtFlag_MAX && aNewSqDist > anOldSqDist))
{
myPoint (i) = Extrema_POnSurf (myU, myV, myPs);
aPOnSurf.SetParameters (myU, myV, myPs);
anOldSqDist = aNewSqDist;
}
}
break;
}
}
if (i <= nbSol)
if (i < nbSol)
return 0;
mySqDist.Append (aNewSqDist);
myPoint.Append (Extrema_POnSurf (myU, myV, myPs));
mySqDistances.Append (aNewSqDist);
myPoints.Append (Extrema_POnSurf (myU, myV, myPs));
return 0;
}
//=============================================================================
Standard_Integer Extrema_FuncPSNorm::NbExt () const
{
return mySqDist.Length();
return mySqDistances.Length();
}
//=============================================================================
Standard_Real Extrema_FuncPSNorm::SquareDistance (const Standard_Integer N) const
{
if (!myPinit || !mySinit) throw Standard_TypeMismatch();
return mySqDist.Value(N);
return mySqDistances (N - 1);
}
//=============================================================================
const Extrema_POnSurf& Extrema_FuncPSNorm::Point (const Standard_Integer N) const
{
if (!myPinit || !mySinit) throw Standard_TypeMismatch();
return myPoint.Value(N);
return myPoints (N - 1);
}

View File

@@ -30,6 +30,7 @@
#include <math_FunctionSetWithDerivatives.hxx>
#include <Standard_Integer.hxx>
#include <math_Vector.hxx>
#include <NCollection_Vector.hxx>
class Standard_OutOfRange;
class gp_Pnt;
class Adaptor3d_Surface;
@@ -122,8 +123,8 @@ private:
Standard_Real myU;
Standard_Real myV;
gp_Pnt myPs;
TColStd_SequenceOfReal mySqDist;
Extrema_SequenceOfPOnSurf myPoint;
NCollection_Vector<Standard_Real> mySqDistances;
NCollection_Vector<Extrema_POnSurf> myPoints;
Standard_Boolean myPinit;
Standard_Boolean mySinit;
Extrema_ExtFlag myTarget;

View File

@@ -85,12 +85,12 @@ namespace
//function : fillSqDist
//purpose :
//=======================================================================
static void fillSqDist (Extrema_POnSurfParams& theParams,
const gp_Pnt& thePoint)
{
if (theParams.GetSqrDistance() < -0.5)
theParams.SetSqrDistance (theParams.Value().SquareDistance (thePoint));
}
//static void fillSqDist (Extrema_POnSurfParams& theParams,
// const gp_Pnt& thePoint)
//{
// if (theParams.GetSqrDistance() < -0.5)
// theParams.SetSqrDistance (theParams.Value().SquareDistance (thePoint));
//}
}
@@ -282,8 +282,6 @@ void Extrema_GenExtPS::Perform (const gp_Pnt& thePoint,
{
for (int iV = 0; iV <= myNbVSamples + 1; ++iV)
{
myPoints->ChangeValue (iU, iV).SetSqrDistance (-1.);
if (iU <= myNbUSamples && iV <= myNbVSamples)
myFacePntParams->ChangeValue (iU, iV).SetSqrDistance (-1.);
@@ -386,6 +384,7 @@ void Extrema_GenExtPS::BuildGrid()
}
myPoints = new Extrema_HArray2OfPOnSurfParams (0, myNbUSamples + 1, 0, myNbVSamples + 1);
gp_Pnt aPoint (myPoint.x(), myPoint.y(), myPoint.z());
for (int iU = 1; iU <= myNbUSamples; iU++)
: myumin(0.0),
@@ -406,7 +405,7 @@ void Extrema_GenExtPS::BuildGrid()
Extrema_POnSurfParams aParam (U, V, aP);
aParam.SetElementType (Extrema_Node);
aParam.SetIndices (iU, iV);
aParam.SetSqrDistance (-1.);
aParam.SetSqrDistance (aP.SquareDistance (aPoint));
myPoints->SetValue (iU, iV, aParam);
}
}
@@ -532,12 +531,6 @@ void Extrema_GenExtPS::BuildTree()
aGridBox.Enlarge (gp_Lin (aPMin.Value(), aDir).Distance (aPMid));
}
}
else
{
// grid of a single point (myNbUSamples, myNbVSamples)
//Standard_Real anAvSqExt = aSetBox.SquareExtent() / (aGridSet->Size() - 1);
//aGridBox.Enlarge (Sqrt (anAvSqExt));
}
aGridSet.CellBoxSet->UpdateBox (iCell, Bnd_Tools::Bnd2BVH (aGridBox));
aSetBox.Add (aGridBox);
@@ -725,8 +718,6 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
{
// Fill corner points with square distance to myPoint
Extrema_POnSurfParams& aParam00 = myPoints->ChangeValue (theNU, theNV);
Extrema_POnSurfParams& aParam01 = myPoints->ChangeValue (theNU, theNV + 1);
Extrema_POnSurfParams& aParam10 = myPoints->ChangeValue (theNU + 1, theNV);
Extrema_POnSurfParams& aParam11 = myPoints->ChangeValue (theNU + 1, theNV + 1);
{
@@ -740,14 +731,9 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
gp_Pnt aPoint (myPoint.x(), myPoint.y(), myPoint.z());
fillSqDist (aParam00, aPoint);
fillSqDist (aParam01, aPoint);
fillSqDist (aParam10, aPoint);
fillSqDist (aParam11, aPoint);
Standard_Boolean isFound = Standard_False;
if (theNU != myNbUSamples && theNV != myNbVSamples &&
(theTarget == Extrema_ExtFlag_MIN || theTarget == Extrema_ExtFlag_MINMAX))
if (theTarget == Extrema_ExtFlag_MIN &&
theNU != myNbUSamples && theNV != myNbVSamples)
{
// Find minimum
@@ -844,7 +830,7 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
}
}
if (theTarget == Extrema_ExtFlag_MAX || theTarget == Extrema_ExtFlag_MINMAX)
if (theTarget == Extrema_ExtFlag_MAX)
{
// Find maximum
Extrema_POnSurfParams &aParam1 = myPoints->ChangeValue (theNU - 1, theNV - 1);
@@ -856,11 +842,17 @@ Standard_Boolean Extrema_GenExtPS::FindSolution (const Standard_Integer theNU,
Extrema_POnSurfParams &aParam7 = myPoints->ChangeValue (theNU + 1, theNV);
Extrema_POnSurfParams &aParam8 = myPoints->ChangeValue (theNU + 1, theNV + 1);
fillSqDist (aParam1, aPoint);
fillSqDist (aParam2, aPoint);
fillSqDist (aParam3, aPoint);
fillSqDist (aParam4, aPoint);
fillSqDist (aParam6, aPoint);
//if (myTarget != Extrema_ExtFlag_MINMAX)
//{
// fillSqDist (aParam1, aPoint);
// fillSqDist (aParam2, aPoint);
// fillSqDist (aParam3, aPoint);
// fillSqDist (aParam4, aPoint);
// fillSqDist (aParam5, aPoint);
// fillSqDist (aParam6, aPoint);
// fillSqDist (aParam7, aPoint);
// fillSqDist (aParam8, aPoint);
//}
Standard_Real aDist = aParam00.GetSqrDistance();
@@ -939,8 +931,8 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
Extrema_POnSurfParams& anEdgeParams = anEdgeParamsArr->ChangeValue (iU, iV);
if (anEdgeParams.GetSqrDistance() < 0.0)
{
fillSqDist (theParam0, thePoint);
fillSqDist (theParam1, thePoint);
//fillSqDist (theParam0, thePoint);
//fillSqDist (theParam1, thePoint);
const Standard_Real aSqrDist01 =
theParam0.Value().SquareDistance (theParam1.Value());
@@ -1025,6 +1017,14 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
Extrema_POnSurfParams& aParam10 = myPoints->ChangeValue (theU + 1, theV);
Extrema_POnSurfParams& aParam11 = myPoints->ChangeValue (theU + 1, theV + 1);
//if (myTarget != Extrema_ExtFlag_MINMAX)
//{
// fillSqDist (aParam00, thePoint);
// fillSqDist (aParam01, thePoint);
// fillSqDist (aParam10, thePoint);
// fillSqDist (aParam11, thePoint);
//}
const Extrema_POnSurfParams &aUE0 =
ComputeEdgeParameters (Standard_True, aParam00, aParam10, thePoint, aDiffTol);
const Extrema_POnSurfParams &aUE1 =

View File

@@ -454,9 +454,9 @@ static gp_Pnt2d Function_Value(const Standard_Real theU,
}
}
gp_Pnt2d pnt;
// Perform search on the whole parametric space using preinitialized extrema.
theData.myGlobExtPS.Perform (p, uInfLi, uSupLi, vInfLi, vSupLi);
gp_Pnt2d pnt;
if (checkSolution (theData.myGlobExtPS, theData.mySurf, uperiod, vperiod, decalU, decalV,
p, theData.mySqProjOrtTol, aSurfPntDist, pnt))
{