SplineLengthData Class Reference

#include <c4d_baseobject.h>

Detailed Description

Helper class to obtain the length of splines and the natural position along their path.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Public Member Functions

Bool Init (SplineObject *op, Int32 segment=0, const Vector *padr=nullptr)
 
Float UniformToNatural (Float t)
 
Float GetLength ()
 
Float GetSegmentLength (Int32 a, Int32 b)
 

Private Member Functions

 SplineLengthData ()
 
 ~SplineLengthData ()
 

Alloc/Free

static SplineLengthDataAlloc ()
 
static void Free (SplineLengthData *&bl)
 

Constructor & Destructor Documentation

◆ SplineLengthData()

SplineLengthData ( )
private

◆ ~SplineLengthData()

~SplineLengthData ( )
private

Member Function Documentation

◆ Alloc()

static SplineLengthData* Alloc ( )
static

Allocates a spline length data. Destroy the allocated spline length data with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated spline length data, or nullptr if the allocation failed.

◆ Free()

static void Free ( SplineLengthData *&  bl)
static

Destructs spline length data allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]blThe spline length data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ Init()

Bool Init ( SplineObject op,
Int32  segment = 0,
const Vector padr = nullptr 
)

Initializes the spline length data.

Warning
Must be called before using UniformToNatural(), GetLength() and GetSegmentLength.
Note
Cannot be used on spline primitives. Call BaseObject::GetRealSpline() to get a real spline first.
Parameters
[in]opThe spline object to initialize. The caller owns the pointed spline object.
[in]segmentThe segment to use. Decides what spline segment the calculations in SplineLengthData methods will be performed on.
[in]padrFor speedup purposes pass a pointer to start of the specified segment in the point array. Otherwise the spline has to search its array manually.
Returns
true if the spline length data was initialized successfully, otherwise false.

◆ UniformToNatural()

Float UniformToNatural ( Float  t)

Gets the natural position along the spline, to be used in SplineObject::GetSplinePoint() and SplineObject::GetSplineTangent(), from a uniform position.
The uniform position is with respect to the actual length of the spline, where the natural position only cares about the interpolation of the curve parameter.

Warning
Call Init() before using this method.
Parameters
[in]tThe uniform position along the spline.
Returns
The natural position in the segment.

◆ GetLength()

Float GetLength ( )

Gets the length of the spline.

Warning
Call Init() before using this method.
Returns
The length of the spline.

◆ GetSegmentLength()

Float GetSegmentLength ( Int32  a,
Int32  b 
)

Gets the length of a segment.

Warning
Call Init() before using this method.
Parameters
[in]aStart segment.
[in]bEnd segment.
Returns
The segment length.