mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +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:
parent
737e9a8da4
commit
437ef7713e
@ -73,31 +73,40 @@ public:
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void BSplCLib::Hunt (const Array1OfReal& XX,
|
void BSplCLib::Hunt (const TColStd_Array1OfReal& theArray,
|
||||||
const Standard_Real X,
|
const Standard_Real theX,
|
||||||
Standard_Integer& Ilc)
|
Standard_Integer& theXPos)
|
||||||
{
|
{
|
||||||
// replaced by simple dichotomy (RLE)
|
// replaced by simple dichotomy (RLE)
|
||||||
Ilc = XX.Lower();
|
if (theArray.First() > theX)
|
||||||
if (XX.Length() <= 1) return;
|
{
|
||||||
const Standard_Real *px = &XX(Ilc);
|
theXPos = theArray.Lower() - 1;
|
||||||
px -= Ilc;
|
|
||||||
|
|
||||||
if (X < px[Ilc]) {
|
|
||||||
Ilc--;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Standard_Integer Ihi = XX.Upper();
|
else if (theArray.Last() < theX)
|
||||||
if (X > px[Ihi]) {
|
{
|
||||||
Ilc = Ihi + 1;
|
theXPos = theArray.Upper() + 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Standard_Integer Im;
|
|
||||||
|
|
||||||
while (Ihi - Ilc != 1) {
|
theXPos = theArray.Lower();
|
||||||
Im = (Ihi + Ilc) >> 1;
|
if (theArray.Length() <= 1)
|
||||||
if (X > px[Im]) Ilc = Im;
|
{
|
||||||
else Ihi = Im;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,23 +124,16 @@ public:
|
|||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
|
||||||
|
|
||||||
//! This routine searches the position of the real
|
//! This routine searches the position of the real value theX
|
||||||
//! value X in the ordered set of real values XX.
|
//! in the monotonically increasing set of real values theArray using bisection algorithm.
|
||||||
//!
|
//!
|
||||||
//! The elements in the table XX are either
|
//! If the given value is out of range or array values, algorithm returns either
|
||||||
//! monotonically increasing or monotonically
|
//! theArray.Lower()-1 or theArray.Upper()+1 depending on theX position in the ordered set.
|
||||||
//! decreasing.
|
|
||||||
//!
|
//!
|
||||||
//! The input value Iloc is used to initialize the
|
//! This routine is used to locate a knot value in a set of knots.
|
||||||
//! algorithm : if Iloc is outside of the bounds
|
Standard_EXPORT static void Hunt (const TColStd_Array1OfReal& theArray,
|
||||||
//! [XX.Lower(), -- XX.Upper()] the bisection algorithm
|
const Standard_Real theX,
|
||||||
//! is used else the routine searches from a previous
|
Standard_Integer& theXPos);
|
||||||
//! 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);
|
|
||||||
|
|
||||||
//! Computes the index of the knots value which gives
|
//! Computes the index of the knots value which gives
|
||||||
//! the start point of the curve.
|
//! the start point of the curve.
|
||||||
|
@ -215,7 +215,9 @@ static Standard_Boolean PerformComposite (TColStd_SequenceOfReal& Parameters,
|
|||||||
Standard_Real Ua = U1;
|
Standard_Real Ua = U1;
|
||||||
for (Standard_Integer Index = PIndex;;)
|
for (Standard_Integer Index = PIndex;;)
|
||||||
{
|
{
|
||||||
Standard_Real Ub = Min (U2, TI (Index + 1));
|
Standard_Real Ub = Index + 1 <= TI.Upper()
|
||||||
|
? Min (U2, TI (Index + 1))
|
||||||
|
: U2;
|
||||||
if (!PerformCurve (Parameters, Points, C, Deflection,
|
if (!PerformCurve (Parameters, Points, C, Deflection,
|
||||||
Ua, Ub, EPSILON, Continuity))
|
Ua, Ub, EPSILON, Continuity))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
@ -174,7 +174,9 @@ static Standard_Boolean PerformComposite (TColStd_SequenceOfReal& Parameters,
|
|||||||
Standard_Real Ua = U1;
|
Standard_Real Ua = U1;
|
||||||
for (Standard_Integer Index = PIndex;;)
|
for (Standard_Integer Index = PIndex;;)
|
||||||
{
|
{
|
||||||
Standard_Real Ub = Min (U2, TI (Index + 1));
|
Standard_Real Ub = Index + 1 <= TI.Upper()
|
||||||
|
? Min (U2, TI (Index + 1))
|
||||||
|
: U2;
|
||||||
if (!PerformCurve (Parameters, Points, C, Deflection,
|
if (!PerformCurve (Parameters, Points, C, Deflection,
|
||||||
Ua, Ub, EPSILON, WithControl))
|
Ua, Ub, EPSILON, WithControl))
|
||||||
{
|
{
|
||||||
|
@ -14,14 +14,6 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
// 03-02-97 : pmn ->LocateU sur Periodic (PRO6963),
|
|
||||||
// bon appel a LocateParameter (PRO6973) et mise en conformite avec
|
|
||||||
// le cdl de LocateU, lorsque U est un noeud (PRO6988)
|
|
||||||
|
|
||||||
#define No_Standard_OutOfRange
|
|
||||||
#define No_Standard_DimensionError
|
|
||||||
|
|
||||||
|
|
||||||
#include <BSplCLib.hxx>
|
#include <BSplCLib.hxx>
|
||||||
#include <Geom_BSplineCurve.hxx>
|
#include <Geom_BSplineCurve.hxx>
|
||||||
#include <Geom_Geometry.hxx>
|
#include <Geom_Geometry.hxx>
|
||||||
@ -809,7 +801,12 @@ void Geom_BSplineCurve::LocateU
|
|||||||
else {
|
else {
|
||||||
I1 = 1;
|
I1 = 1;
|
||||||
BSplCLib::Hunt (CKnots, NewU, I1);
|
BSplCLib::Hunt (CKnots, NewU, I1);
|
||||||
while ( Abs( CKnots(I1+1) - NewU) <= PParametricTolerance) I1++;
|
I1 = Max (Min (I1, CKnots.Upper()), CKnots.Lower());
|
||||||
|
while (I1 + 1 <= CKnots.Upper()
|
||||||
|
&& Abs (CKnots (I1 + 1) - NewU) <= PParametricTolerance)
|
||||||
|
{
|
||||||
|
I1++;
|
||||||
|
}
|
||||||
if ( Abs( CKnots(I1) - NewU) <= PParametricTolerance) {
|
if ( Abs( CKnots(I1) - NewU) <= PParametricTolerance) {
|
||||||
I2 = I1;
|
I2 = I1;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,6 @@
|
|||||||
// + bon appel a LocateParameter (PRO6973).
|
// + bon appel a LocateParameter (PRO6973).
|
||||||
// RBD : 15/10/98 ; Le cache est desormais defini sur [-1,1] (pro15537).
|
// RBD : 15/10/98 ; Le cache est desormais defini sur [-1,1] (pro15537).
|
||||||
|
|
||||||
#define No_Standard_OutOfRange
|
|
||||||
#define No_Standard_DimensionError
|
|
||||||
|
|
||||||
|
|
||||||
#include <BSplCLib.hxx>
|
#include <BSplCLib.hxx>
|
||||||
#include <BSplSLib.hxx>
|
#include <BSplSLib.hxx>
|
||||||
#include <Geom_BSplineCurve.hxx>
|
#include <Geom_BSplineCurve.hxx>
|
||||||
@ -1360,7 +1356,12 @@ void Geom_BSplineSurface::LocateU
|
|||||||
else {
|
else {
|
||||||
I1 = 1;
|
I1 = 1;
|
||||||
BSplCLib::Hunt (Knots, NewU, I1);
|
BSplCLib::Hunt (Knots, NewU, I1);
|
||||||
while ( Abs( Knots(I1+1) - NewU) <= PParametricTolerance) I1++;
|
I1 = Max (Min (I1, Knots.Upper()), Knots.Lower());
|
||||||
|
while (I1 + 1 <= Knots.Upper()
|
||||||
|
&& Abs (Knots (I1 + 1) - NewU) <= PParametricTolerance)
|
||||||
|
{
|
||||||
|
I1++;
|
||||||
|
}
|
||||||
if ( Abs( Knots(I1) - NewU) <= PParametricTolerance) {
|
if ( Abs( Knots(I1) - NewU) <= PParametricTolerance) {
|
||||||
I2 = I1;
|
I2 = I1;
|
||||||
}
|
}
|
||||||
@ -1408,7 +1409,12 @@ void Geom_BSplineSurface::LocateV
|
|||||||
else {
|
else {
|
||||||
I1 = 1;
|
I1 = 1;
|
||||||
BSplCLib::Hunt (Knots, NewV, I1);
|
BSplCLib::Hunt (Knots, NewV, I1);
|
||||||
while ( Abs( Knots(I1+1) - NewV) <= PParametricTolerance) I1++;
|
I1 = Max (Min (I1, Knots.Upper()), Knots.Lower());
|
||||||
|
while (I1 + 1 <= Knots.Upper()
|
||||||
|
&& Abs (Knots (I1 + 1) - NewV) <= PParametricTolerance)
|
||||||
|
{
|
||||||
|
I1++;
|
||||||
|
}
|
||||||
if ( Abs( Knots(I1) - NewV) <= PParametricTolerance) {
|
if ( Abs( Knots(I1) - NewV) <= PParametricTolerance) {
|
||||||
I2 = I1;
|
I2 = I1;
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,6 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
// 03-02-97 : pmn ->LocateU sur Periodic (PRO6963),
|
|
||||||
// bon appel a LocateParameter (PRO6973) et mise en conformite avec
|
|
||||||
// le cdl de LocateU, lorsque U est un noeud (PRO6988)
|
|
||||||
|
|
||||||
#define No_Standard_OutOfRange
|
|
||||||
#define No_Standard_DimensionError
|
|
||||||
|
|
||||||
|
|
||||||
#include <BSplCLib.hxx>
|
#include <BSplCLib.hxx>
|
||||||
#include <Geom2d_BSplineCurve.hxx>
|
#include <Geom2d_BSplineCurve.hxx>
|
||||||
#include <Geom2d_Geometry.hxx>
|
#include <Geom2d_Geometry.hxx>
|
||||||
@ -820,7 +812,12 @@ void Geom2d_BSplineCurve::LocateU
|
|||||||
else {
|
else {
|
||||||
I1 = 1;
|
I1 = 1;
|
||||||
BSplCLib::Hunt (CKnots, NewU, I1);
|
BSplCLib::Hunt (CKnots, NewU, I1);
|
||||||
while ( Abs( CKnots(I1+1) - NewU) <= PParametricTolerance) I1++;
|
I1 = Max (Min (I1, CKnots.Upper()), CKnots.Lower());
|
||||||
|
while (I1 + 1 <= CKnots.Upper()
|
||||||
|
&& Abs (CKnots (I1 + 1) - NewU) <= PParametricTolerance)
|
||||||
|
{
|
||||||
|
I1++;
|
||||||
|
}
|
||||||
if ( Abs( CKnots(I1) - NewU) <= PParametricTolerance) {
|
if ( Abs( CKnots(I1) - NewU) <= PParametricTolerance) {
|
||||||
I2 = I1;
|
I2 = I1;
|
||||||
}
|
}
|
||||||
|
@ -1943,7 +1943,12 @@ void Law_BSpline::LocateU
|
|||||||
else {
|
else {
|
||||||
I1 = 1;
|
I1 = 1;
|
||||||
BSplCLib::Hunt (CKnots, NewU, I1);
|
BSplCLib::Hunt (CKnots, NewU, I1);
|
||||||
while ( Abs( CKnots(I1+1) - NewU) <= Abs(ParametricTolerance)) I1++;
|
I1 = Max (Min (I1, CKnots.Upper()), CKnots.Lower());
|
||||||
|
while (I1 + 1 <= CKnots.Upper()
|
||||||
|
&& Abs (CKnots (I1 + 1) - NewU) <= Abs(ParametricTolerance))
|
||||||
|
{
|
||||||
|
I1++;
|
||||||
|
}
|
||||||
if ( Abs( CKnots(I1) - NewU) <= Abs(ParametricTolerance)) {
|
if ( Abs( CKnots(I1) - NewU) <= Abs(ParametricTolerance)) {
|
||||||
I2 = I1;
|
I2 = I1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user