@@ -189,23 +189,9 @@ void BSplCLib_Cache::calculateDerivativeLocal(double theLocalParam,
189189
190190void BSplCLib_Cache::D0 (const double & theParameter, gp_Pnt2d& thePoint) const
191191{
192- double aNewParameter = myParams.PeriodicNormalization (theParameter);
193- aNewParameter = (aNewParameter - myParams.SpanStart ) / myParams.SpanLength ;
194-
195- double * aPolesArray = const_cast <double *>(myPolesWeightsBuffer);
196- double aPoint[4 ];
197- const int aDimension = myRowLength;
198-
199- PLib::NoDerivativeEvalPolynomial (aNewParameter,
200- myParams.Degree ,
201- aDimension,
202- myParams.Degree * aDimension,
203- aPolesArray[0 ],
204- aPoint[0 ]);
205-
206- thePoint.SetCoord (aPoint[0 ], aPoint[1 ]);
207- if (myIsRational)
208- thePoint.ChangeCoord ().Divide (aPoint[2 ]);
192+ double aLocalParam = myParams.PeriodicNormalization (theParameter);
193+ aLocalParam = (aLocalParam - myParams.SpanStart ) / myParams.SpanLength ;
194+ D0Local (aLocalParam, thePoint);
209195}
210196
211197// ==================================================================================================
@@ -240,15 +226,9 @@ void BSplCLib_Cache::D0Local(double theLocalParam, gp_Pnt& thePoint) const
240226
241227void BSplCLib_Cache::D1 (const double & theParameter, gp_Pnt2d& thePoint, gp_Vec2d& theTangent) const
242228{
243- int aDimension = myRowLength;
244- double aPntDeriv[8 ]; // result storage (point and derivative coordinates)
245-
246- calculateDerivative (theParameter, 1 , aPntDeriv);
247- if (myIsRational) // the size of aPntDeriv was changed by PLib::RationalDerivative
248- aDimension -= 1 ;
249-
250- thePoint.SetCoord (aPntDeriv[0 ], aPntDeriv[1 ]);
251- theTangent.SetCoord (aPntDeriv[aDimension], aPntDeriv[aDimension + 1 ]);
229+ double aLocalParam = myParams.PeriodicNormalization (theParameter);
230+ aLocalParam = (aLocalParam - myParams.SpanStart ) / myParams.SpanLength ;
231+ D1Local (aLocalParam, thePoint, theTangent);
252232}
253233
254234void BSplCLib_Cache::D1 (const double & theParameter, gp_Pnt& thePoint, gp_Vec& theTangent) const
@@ -275,16 +255,9 @@ void BSplCLib_Cache::D2(const double& theParameter,
275255 gp_Vec2d& theTangent,
276256 gp_Vec2d& theCurvature) const
277257{
278- int aDimension = myRowLength;
279- double aPntDeriv[12 ]; // result storage (point and derivatives coordinates)
280-
281- calculateDerivative (theParameter, 2 , aPntDeriv);
282- if (myIsRational) // the size of aPntDeriv was changed by PLib::RationalDerivative
283- aDimension -= 1 ;
284-
285- thePoint.SetCoord (aPntDeriv[0 ], aPntDeriv[1 ]);
286- theTangent.SetCoord (aPntDeriv[aDimension], aPntDeriv[aDimension + 1 ]);
287- theCurvature.SetCoord (aPntDeriv[aDimension << 1 ], aPntDeriv[(aDimension << 1 ) + 1 ]);
258+ double aLocalParam = myParams.PeriodicNormalization (theParameter);
259+ aLocalParam = (aLocalParam - myParams.SpanStart ) / myParams.SpanLength ;
260+ D2Local (aLocalParam, thePoint, theTangent, theCurvature);
288261}
289262
290263void BSplCLib_Cache::D2 (const double & theParameter,
@@ -320,19 +293,9 @@ void BSplCLib_Cache::D3(const double& theParameter,
320293 gp_Vec2d& theCurvature,
321294 gp_Vec2d& theTorsion) const
322295{
323- int aDimension = myRowLength;
324- double aPntDeriv[16 ]; // result storage (point and derivatives coordinates)
325-
326- calculateDerivative (theParameter, 3 , aPntDeriv);
327- if (myIsRational) // the size of aPntDeriv was changed by PLib::RationalDerivative
328- aDimension -= 1 ;
329-
330- thePoint.SetCoord (aPntDeriv[0 ], aPntDeriv[1 ]);
331- theTangent.SetCoord (aPntDeriv[aDimension], aPntDeriv[aDimension + 1 ]);
332- int aShift = aDimension << 1 ;
333- theCurvature.SetCoord (aPntDeriv[aShift], aPntDeriv[aShift + 1 ]);
334- aShift += aDimension;
335- theTorsion.SetCoord (aPntDeriv[aShift], aPntDeriv[aShift + 1 ]);
296+ double aLocalParam = myParams.PeriodicNormalization (theParameter);
297+ aLocalParam = (aLocalParam - myParams.SpanStart ) / myParams.SpanLength ;
298+ D3Local (aLocalParam, thePoint, theTangent, theCurvature, theTorsion);
336299}
337300
338301void BSplCLib_Cache::D3 (const double & theParameter,
@@ -365,3 +328,72 @@ void BSplCLib_Cache::D3Local(double theLocalParam,
365328 theCurvature.SetCoord (aDerivArray[aShift2], aDerivArray[aShift2 + 1 ], aDerivArray[aShift2 + 2 ]);
366329 theTorsion.SetCoord (aDerivArray[aShift3], aDerivArray[aShift3 + 1 ], aDerivArray[aShift3 + 2 ]);
367330}
331+
332+ // ==================================================================================================
333+
334+ void BSplCLib_Cache::D0Local (double theLocalParam, gp_Pnt2d& thePoint) const
335+ {
336+ double aPoint[4 ];
337+
338+ PLib::NoDerivativeEvalPolynomial (theLocalParam,
339+ myParams.Degree ,
340+ myRowLength,
341+ myParams.Degree * myRowLength,
342+ myPolesWeightsBuffer[0 ],
343+ aPoint[0 ]);
344+
345+ thePoint.SetCoord (aPoint[0 ], aPoint[1 ]);
346+ if (myIsRational)
347+ {
348+ thePoint.ChangeCoord ().Divide (aPoint[2 ]);
349+ }
350+ }
351+
352+ // ==================================================================================================
353+
354+ void BSplCLib_Cache::D1Local (double theLocalParam, gp_Pnt2d& thePoint, gp_Vec2d& theTangent) const
355+ {
356+ double aDerivArray[8 ];
357+ calculateDerivativeLocal (theLocalParam, 1 , aDerivArray);
358+
359+ const int aDim = myIsRational ? myRowLength - 1 : myRowLength;
360+ thePoint.SetCoord (aDerivArray[0 ], aDerivArray[1 ]);
361+ theTangent.SetCoord (aDerivArray[aDim], aDerivArray[aDim + 1 ]);
362+ }
363+
364+ // ==================================================================================================
365+
366+ void BSplCLib_Cache::D2Local (double theLocalParam,
367+ gp_Pnt2d& thePoint,
368+ gp_Vec2d& theTangent,
369+ gp_Vec2d& theCurvature) const
370+ {
371+ double aDerivArray[12 ];
372+ calculateDerivativeLocal (theLocalParam, 2 , aDerivArray);
373+
374+ const int aDim = myIsRational ? myRowLength - 1 : myRowLength;
375+ const int aShift = aDim << 1 ;
376+ thePoint.SetCoord (aDerivArray[0 ], aDerivArray[1 ]);
377+ theTangent.SetCoord (aDerivArray[aDim], aDerivArray[aDim + 1 ]);
378+ theCurvature.SetCoord (aDerivArray[aShift], aDerivArray[aShift + 1 ]);
379+ }
380+
381+ // ==================================================================================================
382+
383+ void BSplCLib_Cache::D3Local (double theLocalParam,
384+ gp_Pnt2d& thePoint,
385+ gp_Vec2d& theTangent,
386+ gp_Vec2d& theCurvature,
387+ gp_Vec2d& theTorsion) const
388+ {
389+ double aDerivArray[16 ];
390+ calculateDerivativeLocal (theLocalParam, 3 , aDerivArray);
391+
392+ const int aDim = myIsRational ? myRowLength - 1 : myRowLength;
393+ const int aShift2 = aDim << 1 ;
394+ const int aShift3 = aShift2 + aDim;
395+ thePoint.SetCoord (aDerivArray[0 ], aDerivArray[1 ]);
396+ theTangent.SetCoord (aDerivArray[aDim], aDerivArray[aDim + 1 ]);
397+ theCurvature.SetCoord (aDerivArray[aShift2], aDerivArray[aShift2 + 1 ]);
398+ theTorsion.SetCoord (aDerivArray[aShift3], aDerivArray[aShift3 + 1 ]);
399+ }
0 commit comments