1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

0030581: Modeling Data - Standard_OutOfRange within Geom_BSplineSurface::LocateV()

Geom2d_BSplineCurve::LocateU(),Geom_BSplineCurve::LocateU, Law_BSpline::LocateU()
Geom_BSplineSurface::LocateU() and Geom_BSplineSurface::LocateV()
have been corrected with missing range checks.
BSplCLib::Hunt() documentation has been corrected to reflect its actual implementation.
This commit is contained in:
kgv
2019-03-16 09:33:37 +03:00
committed by apn
parent 737e9a8da4
commit 437ef7713e
8 changed files with 71 additions and 60 deletions

View File

@@ -73,31 +73,40 @@ public:
//purpose :
//=======================================================================
void BSplCLib::Hunt (const Array1OfReal& XX,
const Standard_Real X,
Standard_Integer& Ilc)
void BSplCLib::Hunt (const TColStd_Array1OfReal& theArray,
const Standard_Real theX,
Standard_Integer& theXPos)
{
// replaced by simple dichotomy (RLE)
Ilc = XX.Lower();
if (XX.Length() <= 1) return;
const Standard_Real *px = &XX(Ilc);
px -= Ilc;
if (X < px[Ilc]) {
Ilc--;
if (theArray.First() > theX)
{
theXPos = theArray.Lower() - 1;
return;
}
Standard_Integer Ihi = XX.Upper();
if (X > px[Ihi]) {
Ilc = Ihi + 1;
else if (theArray.Last() < theX)
{
theXPos = theArray.Upper() + 1;
return;
}
Standard_Integer Im;
while (Ihi - Ilc != 1) {
Im = (Ihi + Ilc) >> 1;
if (X > px[Im]) Ilc = Im;
else Ihi = Im;
theXPos = theArray.Lower();
if (theArray.Length() <= 1)
{
return;
}
Standard_Integer aHi = theArray.Upper();
while (aHi - theXPos != 1)
{
const Standard_Integer aMid = (aHi + theXPos) / 2;
if (theArray.Value (aMid) < theX)
{
theXPos = aMid;
}
else
{
aHi = aMid;
}
}
}