1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

# avoid multiple queries from array.

This commit is contained in:
emv
2020-05-19 08:57:49 +03:00
parent 448ecf7bd5
commit 29376f7703

View File

@@ -307,9 +307,9 @@ void Extrema_GenExtPS::Perform (const gp_Pnt& thePoint)
for (Standard_Integer iTarget = 0; iTarget < 2; ++iTarget) for (Standard_Integer iTarget = 0; iTarget < 2; ++iTarget)
{ {
const Extrema_ExtFlag aTarget = static_cast<Extrema_ExtFlag> (iTarget); const Extrema_ExtFlag aTarget = static_cast<Extrema_ExtFlag> (iTarget);
for (int iU = 1; iU <= myNbUSamples; iU++) for (Standard_Integer iU = 1; iU <= myNbUSamples; iU++)
{ {
for (int iV = 1; iV <= myNbVSamples; iV++) for (Standard_Integer iV = 1; iV <= myNbVSamples; iV++)
{ {
FindSolution (iU, iV, aTarget); FindSolution (iU, iV, aTarget);
} }
@@ -324,6 +324,8 @@ void Extrema_GenExtPS::Perform (const gp_Pnt& thePoint)
} }
else else
{ {
// Indicator for high-level BVH traverse
SetBVHSet (NULL);
Select (myGridBoxSet->BVH()); Select (myGridBoxSet->BVH());
} }
@@ -390,7 +392,7 @@ void Extrema_GenExtPS::BuildTree()
new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle)); new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle));
// create hierarchy of BVH trees // create hierarchy of BVH trees
const Standard_Integer aCoeff = static_cast<Standard_Integer> (Sqrt (Min (myNbUSamples, myNbVSamples))); const Standard_Integer aCoeff = static_cast<Standard_Integer>(Ceiling (Sqrt (Min (myNbUSamples, myNbVSamples))));
const Standard_Integer aNbUT = myNbUSamples / aCoeff; const Standard_Integer aNbUT = myNbUSamples / aCoeff;
const Standard_Integer aNbVT = myNbVSamples / aCoeff; const Standard_Integer aNbVT = myNbVSamples / aCoeff;
const Standard_Integer aNbU = myNbUSamples / aNbUT; const Standard_Integer aNbU = myNbUSamples / aNbUT;
@@ -855,10 +857,11 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
const gp_Pnt &thePoint, const gp_Pnt &thePoint,
const Standard_Real theDiffTol) const Standard_Real theDiffTol)
{ {
const Handle (Extrema_HArray2OfPOnSurfParams)& anEdgeParams = IsUEdge ? myUEdgePntParams : myVEdgePntParams; const Handle (Extrema_HArray2OfPOnSurfParams)& anEdgeParamsArr = IsUEdge ? myUEdgePntParams : myVEdgePntParams;
Standard_Integer iU, iV; Standard_Integer iU, iV;
theParam0.GetIndices (iU, iV); theParam0.GetIndices (iU, iV);
if (anEdgeParams->Value (iU, iV).GetSqrDistance() < 0) Extrema_POnSurfParams& anEdgeParams = anEdgeParamsArr->ChangeValue (iU, iV);
if (anEdgeParams.GetSqrDistance() < 0.0)
{ {
fillSqDist (theParam0, thePoint); fillSqDist (theParam0, thePoint);
fillSqDist (theParam1, thePoint); fillSqDist (theParam1, thePoint);
@@ -869,7 +872,7 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
if (aSqrDist01 <= theDiffTol) if (aSqrDist01 <= theDiffTol)
{ {
// The points are confused. Get the first point and change its type. // The points are confused. Get the first point and change its type.
anEdgeParams->SetValue (iU, iV, theParam0); anEdgeParams = theParam0;
} }
else else
{ {
@@ -882,12 +885,12 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
if (theParam0.GetSqrDistance() > theParam1.GetSqrDistance()) if (theParam0.GetSqrDistance() > theParam1.GetSqrDistance())
{ {
// The shortest distance is the point 1. // The shortest distance is the point 1.
anEdgeParams->SetValue (iU, iV, theParam1); anEdgeParams = theParam1;
} }
else else
{ {
// The shortest distance is the point 0. // The shortest distance is the point 0.
anEdgeParams->SetValue (iU, iV, theParam0); anEdgeParams = theParam0;
} }
} }
else else
@@ -914,18 +917,15 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
aVPar += aRatio*(aV[1] - aV[0]); aVPar += aRatio*(aV[1] - aV[0]);
} }
Extrema_POnSurfParams aParams; anEdgeParams.SetParameters (aUPar, aVPar, myS->Value (aUPar, aVPar));
aParams.SetParameters (aUPar, aVPar, myS->Value (aUPar, aVPar)); anEdgeParams.SetElementType (IsUEdge ? Extrema_UIsoEdge : Extrema_VIsoEdge);
anEdgeParams.SetSqrDistance (thePoint.SquareDistance (anEdgeParams.Value()));
aParams.SetElementType (IsUEdge ? Extrema_UIsoEdge : Extrema_VIsoEdge); anEdgeParams.SetIndices (iU, iV);
aParams.SetSqrDistance (thePoint.SquareDistance (aParams.Value()));
aParams.SetIndices (iU, iV);
anEdgeParams->SetValue (iU, iV, aParams);
} }
} }
} }
return anEdgeParams->Value (iU, iV); return anEdgeParams;
} }
//======================================================================= //=======================================================================
@@ -937,7 +937,8 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
const Standard_Integer theV, const Standard_Integer theV,
const gp_Pnt& thePoint) const gp_Pnt& thePoint)
{ {
if (myFacePntParams->Value (theU, theV).GetSqrDistance() < 0) Extrema_POnSurfParams& aFaceParams = myFacePntParams->ChangeValue (theU, theV);
if (aFaceParams.GetSqrDistance() < 0.0)
{ {
// This is the tolerance of difference of squared values. // This is the tolerance of difference of squared values.
// No need to set it too small. // No need to set it too small.
@@ -989,7 +990,7 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
const Extrema_POnSurfParams &aEMin = const Extrema_POnSurfParams &aEMin =
aUEMin.GetSqrDistance() < aVEMin.GetSqrDistance() ? aUEMin : aVEMin; aUEMin.GetSqrDistance() < aVEMin.GetSqrDistance() ? aUEMin : aVEMin;
myFacePntParams->SetValue (theU, theV, aEMin); aFaceParams = aEMin;
} }
else else
{ {
@@ -1008,16 +1009,14 @@ const Extrema_POnSurfParams& Extrema_GenExtPS::
aVE1.Parameter (aU[1], aV[1]); aVE1.Parameter (aU[1], aV[1]);
aVPar = 0.5*(aV[0] + aV[1]); aVPar = 0.5*(aV[0] + aV[1]);
Extrema_POnSurfParams aParam (aUPar, aVPar, myS->Value (aUPar, aVPar)); aFaceParams.SetParameters (aUPar, aVPar, myS->Value (aUPar, aVPar));
aFaceParams.SetElementType (Extrema_Face);
aParam.SetElementType (Extrema_Face); aFaceParams.SetSqrDistance (thePoint.SquareDistance (aFaceParams.Value()));
aParam.SetSqrDistance (thePoint.SquareDistance (aParam.Value())); aFaceParams.SetIndices (theU, theV);
aParam.SetIndices (theU, theV);
myFacePntParams->SetValue (theU, theV, aParam);
} }
} }
return myFacePntParams->Value (theU, theV); return aFaceParams;
} }
//======================================================================= //=======================================================================