1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +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;
}
}
}

View File

@@ -124,23 +124,16 @@ public:
DEFINE_STANDARD_ALLOC
//! This routine searches the position of the real
//! value X in the ordered set of real values XX.
//! This routine searches the position of the real value theX
//! in the monotonically increasing set of real values theArray using bisection algorithm.
//!
//! The elements in the table XX are either
//! monotonically increasing or monotonically
//! decreasing.
//! If the given value is out of range or array values, algorithm returns either
//! theArray.Lower()-1 or theArray.Upper()+1 depending on theX position in the ordered set.
//!
//! The input value Iloc is used to initialize the
//! algorithm : if Iloc is outside of the bounds
//! [XX.Lower(), -- XX.Upper()] the bisection algorithm
//! is used else the routine searches from a previous
//! known position by increasing steps then converges
//! by bisection.
//!
//! This routine is used to locate a knot value in a
//! set of knots.
Standard_EXPORT static void Hunt (const TColStd_Array1OfReal& XX, const Standard_Real X, Standard_Integer& Iloc);
//! This routine is used to locate a knot value in a set of knots.
Standard_EXPORT static void Hunt (const TColStd_Array1OfReal& theArray,
const Standard_Real theX,
Standard_Integer& theXPos);
//! Computes the index of the knots value which gives
//! the start point of the curve.