mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027048: BSpline cache is always wrong outside of surface
1. Disable recalculation of B-spline cache when the parameter is out of surface boundary but near the cached span. 2. Rebuild cache each time a curve/surface is loaded into adaptor (B-spline knots may be re-parametrized outside adaptor without changing base curve) 3. Test cases.
This commit is contained in:
@@ -73,7 +73,8 @@ Standard_Boolean BSplCLib_Cache::IsCacheValid(Standard_Real theParameter) const
|
||||
PeriodicNormalization(myFlatKnots->Array1(), aNewParam);
|
||||
|
||||
Standard_Real aDelta = aNewParam - mySpanStart;
|
||||
return (aDelta >= 0.0 && (aDelta < mySpanLength || mySpanIndex == mySpanIndexMax));
|
||||
return ((aDelta >= 0.0 || mySpanIndex == mySpanIndexMin) &&
|
||||
(aDelta < mySpanLength || mySpanIndex == mySpanIndexMax));
|
||||
}
|
||||
|
||||
void BSplCLib_Cache::PeriodicNormalization(const TColStd_Array1OfReal& theFlatKnots,
|
||||
@@ -126,6 +127,7 @@ void BSplCLib_Cache::BuildCache(const Standard_Real& theParameter,
|
||||
aNewParam, thePeriodic, mySpanIndex, aNewParam);
|
||||
mySpanStart = theFlatKnots.Value(mySpanIndex);
|
||||
mySpanLength = theFlatKnots.Value(mySpanIndex + 1) - mySpanStart;
|
||||
mySpanIndexMin = thePeriodic ? 0 : myDegree + 1;
|
||||
mySpanIndexMax = theFlatKnots.Length() - 1 - theDegree;
|
||||
|
||||
// Calculate new cache data
|
||||
@@ -164,6 +166,7 @@ void BSplCLib_Cache::BuildCache(const Standard_Real& theParameter,
|
||||
aNewParam, thePeriodic, mySpanIndex, aNewParam);
|
||||
mySpanStart = theFlatKnots.Value(mySpanIndex);
|
||||
mySpanLength = theFlatKnots.Value(mySpanIndex + 1) - mySpanStart;
|
||||
mySpanIndexMin = thePeriodic ? 0 : myDegree + 1;
|
||||
mySpanIndexMax = theFlatKnots.Length() - 1 - theDegree;
|
||||
|
||||
// Calculate new cache data
|
||||
|
@@ -167,6 +167,7 @@ private:
|
||||
Standard_Real mySpanStart; ///< parameter for the first point of the span
|
||||
Standard_Real mySpanLength; ///< length of the span
|
||||
Standard_Integer mySpanIndex; ///< index of the span on Bezier/B-spline curve
|
||||
Standard_Integer mySpanIndexMin; ///< minimal index of span on Bezier/B-spline curve
|
||||
Standard_Integer mySpanIndexMax; ///< maximal number of spans on Bezier/B-spline curve
|
||||
Standard_Integer myDegree; ///< degree of Bezier/B-spline
|
||||
Handle(TColStd_HArray1OfReal) myFlatKnots; ///< knots of Bezier/B-spline (used for periodic normalization of parameters, exists only for periodical splines)
|
||||
|
Reference in New Issue
Block a user