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

Computes the abscissa and parallel transport normal along a centerline. More...

#include <vtkvmtkCenterlineAttributesFilter.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCenterlineAttributesFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetAbscissasArrayName (const char *)
virtual char * GetAbscissasArrayName ()
virtual void SetParallelTransportNormalsArrayName (const char *)
virtual char * GetParallelTransportNormalsArrayName ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkCenterlineAttributesFilter ()
 ~vtkvmtkCenterlineAttributesFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void ComputeAbscissas (vtkPolyData *input, vtkDoubleArray *abscissasArray)
void ComputeParallelTransportNormals (vtkPolyData *input, vtkDoubleArray *parallelTransportNormalsArray)

Protected Attributes

char * AbscissasArrayName
char * ParallelTransportNormalsArrayName

Detailed Description

Computes the abscissa and parallel transport normal along a centerline.

Abscissas are easy to define: they measure the distances along a line. This class generates abscissas relative to the starting point of the centerline and can be offset to a different location at a later time.

Parallel Transport Normals are used to help construct an osculating reference system along a centerline. We generate a pair of arbitrary normal and binormal orthogonal vectors are generated for the first point along the centerline. The reference system created by the orthogonal normal, binormal, and tangent vectors is propagated down the centerline by rotating it (in the osculating plane) by an amount equal to the change in orientation of the line tangent between neighboring pairs of points.

This is the filter behind the vmtkcenterlineattributes pype script; its output (abscissas and parallel transport normals) is a required input for centerline-based surface mapping/patching (e.g. vtkvmtkPolyDataStretchMappingFilter).

See also
vtkvmtkCenterlineGeometry, vtkvmtkPolyDataStretchMappingFilter

Definition at line 43 of file vtkvmtkCenterlineAttributesFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkCenterlineAttributesFilter::Superclass

Definition at line 46 of file vtkvmtkCenterlineAttributesFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkCenterlineAttributesFilter()

vtkvmtkCenterlineAttributesFilter::vtkvmtkCenterlineAttributesFilter ( )
protected

◆ ~vtkvmtkCenterlineAttributesFilter()

vtkvmtkCenterlineAttributesFilter::~vtkvmtkCenterlineAttributesFilter ( )
protected

Definition at line 43 of file vtkvmtkCenterlineAttributesFilter.cxx.

44{
45 if (this->AbscissasArrayName)
46 {
47 delete[] this->AbscissasArrayName;
48 this->AbscissasArrayName = NULL;
49 }
50
52 {
55 }
56}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCenterlineAttributesFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCenterlineAttributesFilter * vtkvmtkCenterlineAttributesFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 268 of file vtkvmtkCenterlineAttributesFilter.cxx.

269{
270 this->Superclass::PrintSelf(os,indent);
271}

◆ New()

vtkvmtkCenterlineAttributesFilter * vtkvmtkCenterlineAttributesFilter::New ( )
static

◆ SetAbscissasArrayName()

virtual void vtkvmtkCenterlineAttributesFilter::SetAbscissasArrayName ( const char * )
virtual

Set/Get the name of the point data array where the abscissa (arc-length distance from the centerline's starting point) is stored for each point. Commonly named "Abscissas".

◆ GetAbscissasArrayName()

virtual char * vtkvmtkCenterlineAttributesFilter::GetAbscissasArrayName ( )
virtual

Set/Get the name of the point data array where the abscissa (arc-length distance from the centerline's starting point) is stored for each point. Commonly named "Abscissas".

◆ SetParallelTransportNormalsArrayName()

virtual void vtkvmtkCenterlineAttributesFilter::SetParallelTransportNormalsArrayName ( const char * )
virtual

Set/Get the name of the 3-component point data array where the parallel-transported normal vector is stored for each point (see class description for how it's propagated along the centerline). Commonly named "ParallelTransportNormals".

◆ GetParallelTransportNormalsArrayName()

virtual char * vtkvmtkCenterlineAttributesFilter::GetParallelTransportNormalsArrayName ( )
virtual

Set/Get the name of the 3-component point data array where the parallel-transported normal vector is stored for each point (see class description for how it's propagated along the centerline). Commonly named "ParallelTransportNormals".

◆ RequestData()

int vtkvmtkCenterlineAttributesFilter::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 58 of file vtkvmtkCenterlineAttributesFilter.cxx.

62{
63 // get the info objects
64 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
65 vtkInformation *outInfo = outputVector->GetInformationObject(0);
66
67 // get the input and output
68 vtkPolyData *input = vtkPolyData::SafeDownCast(
69 inInfo->Get(vtkDataObject::DATA_OBJECT()));
70 vtkPolyData *output = vtkPolyData::SafeDownCast(
71 outInfo->Get(vtkDataObject::DATA_OBJECT()));
72
73 if (!this->AbscissasArrayName)
74 {
75 vtkErrorMacro(<<"AbscissasArrayName not specified");
76 return 1;
77 }
78
80 {
81 vtkErrorMacro(<<"ParallelTransportNormalsArrayName not specified");
82 return 1;
83 }
84
85 output->DeepCopy(input);
86
87 vtkDoubleArray* abscissasArray = vtkDoubleArray::New();
88 abscissasArray->SetNumberOfComponents(1);
89 abscissasArray->SetName(this->AbscissasArrayName);
90
91 this->ComputeAbscissas(input,abscissasArray);
92 output->GetPointData()->AddArray(abscissasArray);
93
94 vtkDoubleArray* parallelTransportNormalsArray = vtkDoubleArray::New();
95 parallelTransportNormalsArray->SetNumberOfComponents(3);
96 parallelTransportNormalsArray->SetName(this->ParallelTransportNormalsArrayName);
97
98 this->ComputeParallelTransportNormals(input,parallelTransportNormalsArray);
99 output->GetPointData()->AddArray(parallelTransportNormalsArray);
100
101 abscissasArray->Delete();
102 parallelTransportNormalsArray->Delete();
103
104 return 1;
105}
void ComputeAbscissas(vtkPolyData *input, vtkDoubleArray *abscissasArray)
void ComputeParallelTransportNormals(vtkPolyData *input, vtkDoubleArray *parallelTransportNormalsArray)

◆ ComputeAbscissas()

void vtkvmtkCenterlineAttributesFilter::ComputeAbscissas ( vtkPolyData * input,
vtkDoubleArray * abscissasArray )
protected

Definition at line 107 of file vtkvmtkCenterlineAttributesFilter.cxx.

108{
109 int numberOfPoints = input->GetNumberOfPoints();
110
111 abscissasArray->SetNumberOfTuples(numberOfPoints);
112 abscissasArray->FillComponent(0,0.0);
113
114 double point0[3], point1[3];
115 double abscissa;
116 vtkIdType id0, id1;
117
118 int numberOfCells = input->GetNumberOfCells();
119 int numberOfPointsInCell;
120
121 for (int k=0; k<numberOfCells; k++)
122 {
123 vtkPolyLine* polyLine = vtkPolyLine::SafeDownCast(input->GetCell(k));
124
125 if (!polyLine)
126 {
127 continue;
128 }
129
130 numberOfPointsInCell = polyLine->GetNumberOfPoints();
131
132 abscissa = 0.0;
133
134 id0 = polyLine->GetPointId(0);
135 abscissasArray->SetValue(id0,abscissa);
136
137 for (int i=1; i<numberOfPointsInCell; i++)
138 {
139 id0 = polyLine->GetPointId(i-1);
140 id1 = polyLine->GetPointId(i);
141 input->GetPoint(id0,point0);
142 input->GetPoint(id1,point1);
143 abscissa += sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
144 abscissasArray->SetValue(id1,abscissa);
145 }
146 }
147}

◆ ComputeParallelTransportNormals()

void vtkvmtkCenterlineAttributesFilter::ComputeParallelTransportNormals ( vtkPolyData * input,
vtkDoubleArray * parallelTransportNormalsArray )
protected

Definition at line 149 of file vtkvmtkCenterlineAttributesFilter.cxx.

150{
151 int numberOfPoints = input->GetNumberOfPoints();
152
153 parallelTransportNormalsArray->SetNumberOfTuples(numberOfPoints);
154 parallelTransportNormalsArray->FillComponent(0,0.0);
155
156 int numberOfCells = input->GetNumberOfCells();
157 int numberOfPointsInCell;
158
159 vtkTransform* transform = vtkTransform::New();
160
161 vtkIdType id0, id1, id2;
162 double p0[3], p1[3], p2[3];
163
164 double t0[3], t1[3], v[3];
165 double dot, theta;
166 double n0[3], n1[3];
167
168 id2 = -1;
169
170 for (int k=0; k<numberOfCells; k++)
171 {
172 vtkPolyLine* polyLine = vtkPolyLine::SafeDownCast(input->GetCell(k));
173
174 if (!polyLine)
175 {
176 continue;
177 }
178
179 numberOfPointsInCell = polyLine->GetNumberOfPoints();
180
181 if (numberOfPointsInCell < 2)
182 {
183 continue;
184 }
185
186 t0[0] = t0[1] = t0[2] = 0.0;
187
188 id0 = polyLine->GetPointId(0);
189 input->GetPoint(id0,p0);
190
191 vtkIdType nextId = 1;
192 while (vtkMath::Norm(t0) < VTK_VMTK_DOUBLE_TOL)
193 {
194 id1 = polyLine->GetPointId(nextId);
195 input->GetPoint(id1,p1);
196
197 t0[0] = p1[0] - p0[0];
198 t0[1] = p1[1] - p0[1];
199 t0[2] = p1[2] - p0[2];
200
201 ++nextId;
202 }
203
204 vtkMath::Normalize(t0);
205
206 double dummy[3];
207 vtkMath::Perpendiculars(t0,n0,dummy,0.0);
208
209 parallelTransportNormalsArray->SetTuple(id0,n0);
210
211 for (int i=1; i<numberOfPointsInCell-1; i++)
212 {
213 id0 = polyLine->GetPointId(i-1);
214 id1 = polyLine->GetPointId(i);
215 id2 = polyLine->GetPointId(i+1);
216 input->GetPoint(id0,p0);
217 input->GetPoint(id1,p1);
218 input->GetPoint(id2,p2);
219
220 t0[0] = p1[0] - p0[0];
221 t0[1] = p1[1] - p0[1];
222 t0[2] = p1[2] - p0[2];
223
224 t1[0] = p2[0] - p1[0];
225 t1[1] = p2[1] - p1[1];
226 t1[2] = p2[2] - p1[2];
227
228 vtkMath::Normalize(t0);
229 vtkMath::Normalize(t1);
230
231 dot = vtkMath::Dot(t0,t1);
232
233 if (1-dot < VTK_VMTK_DOUBLE_TOL)
234 {
235 theta = 0.0;
236 }
237 else
238 {
239 theta = acos(dot) * 180.0 / vtkMath::Pi();
240 }
241
242 vtkMath::Cross(t0,t1,v);
243
244 transform->Identity();
245 transform->RotateWXYZ(theta,v);
246 transform->TransformPoint(n0,n1);
247
248 dot = vtkMath::Dot(t1,n1);
249 n1[0] -= dot * t1[0];
250 n1[1] -= dot * t1[1];
251 n1[2] -= dot * t1[2];
252
253 vtkMath::Normalize(n1);
254
255 parallelTransportNormalsArray->SetTuple(id1,n1);
256
257 n0[0] = n1[0];
258 n0[1] = n1[1];
259 n0[2] = n1[2];
260 }
261
262 parallelTransportNormalsArray->SetTuple(id2,n1);
263 }
264
265 transform->Delete();
266}
#define VTK_VMTK_DOUBLE_TOL

Member Data Documentation

◆ AbscissasArrayName

char* vtkvmtkCenterlineAttributesFilter::AbscissasArrayName
protected

Definition at line 81 of file vtkvmtkCenterlineAttributesFilter.h.

◆ ParallelTransportNormalsArrayName

char* vtkvmtkCenterlineAttributesFilter::ParallelTransportNormalsArrayName
protected

Definition at line 82 of file vtkvmtkCenterlineAttributesFilter.h.


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