VMTK
Loading...
Searching...
No Matches
vtkvmtkCardinalSpline Class Reference

Extends vtkCardinalSpline with methods to evaluate the spline's first derivative, second derivative, and value-plus-derivatives at a parametric coordinate. More...

#include <vtkvmtkCardinalSpline.h>

Inheritance diagram for vtkvmtkCardinalSpline:
[legend]
Collaboration diagram for vtkvmtkCardinalSpline:
[legend]

Public Types

typedef vtkCardinalSpline Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCardinalSpline * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual double EvaluateDerivative (double t)
virtual double EvaluateSecondDerivative (double t)
virtual void EvaluateValueAndDerivatives (double t, double valueAndDerivatives[3])

Static Public Member Functions

static vtkvmtkCardinalSpline * New ()
static int IsTypeOf (const char *type)
static vtkvmtkCardinalSpline * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkCardinalSpline ()
 ~vtkvmtkCardinalSpline ()

Detailed Description

Extends vtkCardinalSpline with methods to evaluate the spline's first derivative, second derivative, and value-plus-derivatives at a parametric coordinate.

vtkvmtkCardinalSpline extends vtkCardinalSpline, which only evaluates the spline's value at a parametric coordinate, with methods to also evaluate its first and second derivatives (and all three at once) at a given parametric coordinate t, using the same cubic piecewise coefficients computed by the base class's Compute(). This is used, for instance, by vtkvmtkActiveTubeFilter to obtain tangent and curvature-like information (needed for internal stiffness forces) along a spline fit through a centerline's points and radii.

See also
vtkvmtkActiveTubeFilter

Definition at line 43 of file vtkvmtkCardinalSpline.h.

Member Typedef Documentation

◆ Superclass

typedef vtkCardinalSpline vtkvmtkCardinalSpline::Superclass

Definition at line 48 of file vtkvmtkCardinalSpline.h.

Constructor & Destructor Documentation

◆ vtkvmtkCardinalSpline()

vtkvmtkCardinalSpline::vtkvmtkCardinalSpline ( )
protected

Definition at line 35 of file vtkvmtkCardinalSpline.cxx.

36{
37}

◆ ~vtkvmtkCardinalSpline()

vtkvmtkCardinalSpline::~vtkvmtkCardinalSpline ( )
inlineprotected

Definition at line 75 of file vtkvmtkCardinalSpline.h.

75{}

Member Function Documentation

◆ New()

vtkvmtkCardinalSpline * vtkvmtkCardinalSpline::New ( )
static

◆ IsTypeOf()

int vtkvmtkCardinalSpline::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkCardinalSpline::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkCardinalSpline * vtkvmtkCardinalSpline::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCardinalSpline::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCardinalSpline * vtkvmtkCardinalSpline::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkCardinalSpline::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 178 of file vtkvmtkCardinalSpline.cxx.

179{
180 this->Superclass::PrintSelf(os,indent);
181}

◆ EvaluateDerivative()

double vtkvmtkCardinalSpline::EvaluateDerivative ( double t)
virtual

Evaluate the first derivative of the spline at parametric coordinate t. Recomputes the spline coefficients first if the spline's control points have changed since the last computation. t is clamped to the spline's parametric range; returns 0.0 if fewer than 2 points have been added.

Definition at line 39 of file vtkvmtkCardinalSpline.cxx.

40{
41 int index;
42 double *intervals;
43 double *coefficients;
44
45 if (this->ComputeTime < this->GetMTime())
46 {
47 this->Compute();
48 }
49
50 int size = this->PiecewiseFunction->GetSize();
51 if (size < 2)
52 {
53 return 0.0;
54 }
55
56 intervals = this->Intervals;
57 coefficients = this->Coefficients;
58
59 if (this->Closed)
60 {
61 size = size + 1;
62 }
63
64 if (t < intervals[0])
65 {
66 t = intervals[0];
67 }
68 if (t > intervals[size - 1])
69 {
70 t = intervals[size - 1];
71 }
72
73 index = this->FindIndex(size,t);
74
75 t = (t - intervals[index]);
76
77 return 3 * t * t * *(coefficients + index * 4 + 3) +
78 2 * t * *(coefficients + index * 4 + 2) +
79 + *(coefficients + index * 4 + 1);
80}

◆ EvaluateSecondDerivative()

double vtkvmtkCardinalSpline::EvaluateSecondDerivative ( double t)
virtual

Evaluate the second derivative of the spline at parametric coordinate t. Recomputes the spline coefficients first if the spline's control points have changed since the last computation. t is clamped to the spline's parametric range; returns 0.0 if fewer than 2 points have been added.

Definition at line 82 of file vtkvmtkCardinalSpline.cxx.

83{
84 int index;
85 double *intervals;
86 double *coefficients;
87
88 if (this->ComputeTime < this->GetMTime())
89 {
90 this->Compute();
91 }
92
93 int size = this->PiecewiseFunction->GetSize();
94 if (size < 2)
95 {
96 return 0.0;
97 }
98
99 intervals = this->Intervals;
100 coefficients = this->Coefficients;
101
102 if (this->Closed)
103 {
104 size = size + 1;
105 }
106
107 if (t < intervals[0])
108 {
109 t = intervals[0];
110 }
111 if (t > intervals[size - 1])
112 {
113 t = intervals[size - 1];
114 }
115
116 index = this->FindIndex(size,t);
117
118 t = (t - intervals[index]);
119
120 return 6 * t * *(coefficients + index * 4 + 3) +
121 2 * *(coefficients + index * 4 + 2);
122}

◆ EvaluateValueAndDerivatives()

void vtkvmtkCardinalSpline::EvaluateValueAndDerivatives ( double t,
double valueAndDerivatives[3] )
virtual

Evaluate the spline's value, first derivative, and second derivative at parametric coordinate t in a single call, storing them respectively in valueAndDerivatives[0], [1], and [2]. Equivalent to (but more efficient than) calling Evaluate(), EvaluateDerivative(), and EvaluateSecondDerivative() separately.

Definition at line 124 of file vtkvmtkCardinalSpline.cxx.

125{
126 int index;
127 double *intervals;
128 double *coefficients;
129
130 if (this->ComputeTime < this->GetMTime())
131 {
132 this->Compute();
133 }
134
135 int size = this->PiecewiseFunction->GetSize();
136 if (size < 2)
137 {
138 valueAndDerivatives[0] = 0.0;
139 valueAndDerivatives[1] = 0.0;
140 valueAndDerivatives[2] = 0.0;
141 return;
142 }
143
144 intervals = this->Intervals;
145 coefficients = this->Coefficients;
146
147 if (this->Closed)
148 {
149 size = size + 1;
150 }
151
152 if (t < intervals[0])
153 {
154 t = intervals[0];
155 }
156 if (t > intervals[size - 1])
157 {
158 t = intervals[size - 1];
159 }
160
161 index = this->FindIndex(size,t);
162
163 t = (t - intervals[index]);
164
165 valueAndDerivatives[0] = (t * (t * (t * *(coefficients + index * 4 + 3)
166 + *(coefficients + index * 4 + 2))
167 + *(coefficients + index * 4 + 1))
168 + *(coefficients + index * 4));
169
170 valueAndDerivatives[1] = 3 * t * t * *(coefficients + index * 4 + 3) +
171 2 * t * *(coefficients + index * 4 + 2) +
172 + *(coefficients + index * 4 + 1);
173
174 valueAndDerivatives[2] = 6 * t * *(coefficients + index * 4 + 3) +
175 2 * *(coefficients + index * 4 + 2);
176}

The documentation for this class was generated from the following files: