File indexing completed on 2025-01-18 10:03:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _BSplCLib_CacheParams_Headerfile
0015 #define _BSplCLib_CacheParams_Headerfile
0016
0017 #include <BSplCLib.hxx>
0018
0019
0020
0021
0022 struct BSplCLib_CacheParams
0023 {
0024 const Standard_Integer Degree;
0025 const Standard_Boolean IsPeriodic;
0026 const Standard_Real FirstParameter;
0027 const Standard_Real LastParameter;
0028
0029 const Standard_Integer SpanIndexMin;
0030 const Standard_Integer SpanIndexMax;
0031
0032 Standard_Real SpanStart;
0033 Standard_Real SpanLength;
0034 Standard_Integer SpanIndex;
0035
0036
0037
0038
0039
0040 BSplCLib_CacheParams (Standard_Integer theDegree, Standard_Boolean thePeriodic,
0041 const TColStd_Array1OfReal& theFlatKnots)
0042 : Degree(theDegree),
0043 IsPeriodic(thePeriodic),
0044 FirstParameter(theFlatKnots.Value(theFlatKnots.Lower() + theDegree)),
0045 LastParameter(theFlatKnots.Value(theFlatKnots.Upper() - theDegree)),
0046 SpanIndexMin(theFlatKnots.Lower() + theDegree),
0047 SpanIndexMax(theFlatKnots.Upper() - theDegree - 1),
0048 SpanStart(0.),
0049 SpanLength(0.),
0050 SpanIndex(0)
0051 {}
0052
0053
0054
0055 Standard_Real PeriodicNormalization (Standard_Real theParameter) const
0056 {
0057 if (IsPeriodic)
0058 {
0059 if (theParameter < FirstParameter)
0060 {
0061 Standard_Real aPeriod = LastParameter - FirstParameter;
0062 Standard_Real aScale = IntegerPart ((FirstParameter - theParameter) / aPeriod);
0063 return theParameter + aPeriod * (aScale + 1.0);
0064 }
0065 if (theParameter > LastParameter)
0066 {
0067 Standard_Real aPeriod = LastParameter - FirstParameter;
0068 Standard_Real aScale = IntegerPart ((theParameter - LastParameter) / aPeriod);
0069 return theParameter - aPeriod * (aScale + 1.0);
0070 }
0071 }
0072 return theParameter;
0073 }
0074
0075
0076
0077 Standard_Boolean IsCacheValid (Standard_Real theParameter) const
0078 {
0079 Standard_Real aNewParam = PeriodicNormalization (theParameter);
0080 Standard_Real aDelta = aNewParam - SpanStart;
0081 return ((aDelta >= 0.0 || SpanIndex == SpanIndexMin) &&
0082 (aDelta < SpanLength || SpanIndex == SpanIndexMax));
0083 }
0084
0085
0086
0087
0088 void LocateParameter (Standard_Real& theParameter, const TColStd_Array1OfReal& theFlatKnots)
0089 {
0090 SpanIndex = 0;
0091 BSplCLib::LocateParameter (Degree, theFlatKnots, BSplCLib::NoMults(),
0092 theParameter, IsPeriodic, SpanIndex, theParameter);
0093 SpanStart = theFlatKnots.Value(SpanIndex);
0094 SpanLength = theFlatKnots.Value(SpanIndex + 1) - SpanStart;
0095 }
0096
0097 private:
0098
0099 BSplCLib_CacheParams (const BSplCLib_CacheParams&);
0100 void operator = (const BSplCLib_CacheParams&);
0101 };
0102
0103 #endif