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

Computes the length, curvature, torsion, and tortuosity for each branch within a split centerline. More...

#include <vtkvmtkCenterlineBranchGeometry.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCenterlineBranchGeometry * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetRadiusArrayName (const char *)
virtual char * GetRadiusArrayName ()
virtual void SetGroupIdsArrayName (const char *)
virtual char * GetGroupIdsArrayName ()
virtual void SetBlankingArrayName (const char *)
virtual char * GetBlankingArrayName ()
virtual void SetLengthArrayName (const char *)
virtual char * GetLengthArrayName ()
virtual void SetCurvatureArrayName (const char *)
virtual char * GetCurvatureArrayName ()
virtual void SetTorsionArrayName (const char *)
virtual char * GetTorsionArrayName ()
virtual void SetTortuosityArrayName (const char *)
virtual char * GetTortuosityArrayName ()
virtual void SetMinSubsamplingSpacing (double)
virtual double GetMinSubsamplingSpacing ()
virtual void SetSmoothingFactor (double)
virtual double GetSmoothingFactor ()
virtual void SetNumberOfSmoothingIterations (int)
virtual int GetNumberOfSmoothingIterations ()
virtual void SetLineSmoothing (int)
virtual int GetLineSmoothing ()
virtual void LineSmoothingOn ()
virtual void LineSmoothingOff ()
virtual void SetLineSubsampling (int)
virtual int GetLineSubsampling ()
virtual void LineSubsamplingOn ()
virtual void LineSubsamplingOff ()
virtual void SetSphereSubsampling (int)
virtual int GetSphereSubsampling ()
virtual void SphereSubsamplingOn ()
virtual void SphereSubsamplingOff ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkCenterlineBranchGeometry ()
 ~vtkvmtkCenterlineBranchGeometry ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
double ComputeGroupLength (vtkPolyData *input, int branchGroupId)
double ComputeGroupCurvature (vtkPolyData *input, int branchGroupId)
double ComputeGroupTorsion (vtkPolyData *input, int branchGroupId)
double ComputeGroupTortuosity (vtkPolyData *input, int branchGroupId, double groupLength)
void SphereSubsampleLine (vtkPolyData *input, vtkIdType cellId, vtkPoints *subsampledLinePoints)

Static Protected Member Functions

static void SubsampleLine (vtkPoints *linePoints, vtkPoints *subsampledLinePoints, double minSpacing=0.01)

Protected Attributes

char * RadiusArrayName
char * GroupIdsArrayName
char * BlankingArrayName
char * LengthArrayName
char * CurvatureArrayName
char * TorsionArrayName
char * TortuosityArrayName
int LineSubsampling
int SphereSubsampling
int LineSmoothing
double MinSubsamplingSpacing
double SmoothingFactor
int NumberOfSmoothingIterations

Detailed Description

Computes the length, curvature, torsion, and tortuosity for each branch within a split centerline.

The length, curvature, torsion, and tortuosity metrics are scalar quantities which are identical for each point / tract that makes up a branch. They are cell data which are attached to all cells in the branch.

A laplacian smoothing filter can be applied to the line if the computation appears to be unstable (as we are using second derivatives and such here).

Unlike vtkvmtkCenterlineGeometry (which computes point-wise differential geometry for raw, unsplit centerlines), this class computes one aggregate value per branch (group of cells sharing a GroupIdsArrayName value), optionally subsampling each branch's line to a coarser, more robust point spacing before computing curvature/torsion. This is the filter behind the vmtkbranchgeometry pype script, run after splitting/grouping.

See also
vtkvmtkCenterlineGeometry, vtkvmtkCenterlineSplittingAndGroupingFilter

Definition at line 48 of file vtkvmtkCenterlineBranchGeometry.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkCenterlineBranchGeometry::Superclass

Definition at line 51 of file vtkvmtkCenterlineBranchGeometry.h.

Constructor & Destructor Documentation

◆ vtkvmtkCenterlineBranchGeometry()

vtkvmtkCenterlineBranchGeometry::vtkvmtkCenterlineBranchGeometry ( )
protected

Definition at line 44 of file vtkvmtkCenterlineBranchGeometry.cxx.

45{
46 this->RadiusArrayName = NULL;
47 this->GroupIdsArrayName = NULL;
48 this->BlankingArrayName = NULL;
49
50 this->LengthArrayName = NULL;
51 this->CurvatureArrayName = NULL;
52 this->TorsionArrayName = NULL;
53 this->TortuosityArrayName = NULL;
54
55 this->MinSubsamplingSpacing = 0.1;
56 this->SmoothingFactor = 0.01;
58
59 this->LineSubsampling = 1;
60 this->SphereSubsampling = 1;
61 this->LineSmoothing = 0;
62}

◆ ~vtkvmtkCenterlineBranchGeometry()

vtkvmtkCenterlineBranchGeometry::~vtkvmtkCenterlineBranchGeometry ( )
protected

Definition at line 64 of file vtkvmtkCenterlineBranchGeometry.cxx.

65{
66 if (this->RadiusArrayName)
67 {
68 delete[] this->RadiusArrayName;
69 this->RadiusArrayName = NULL;
70 }
71
72 if (this->GroupIdsArrayName)
73 {
74 delete[] this->GroupIdsArrayName;
75 this->GroupIdsArrayName = NULL;
76 }
77
78 if (this->BlankingArrayName)
79 {
80 delete[] this->BlankingArrayName;
81 this->BlankingArrayName = NULL;
82 }
83
84 if (this->LengthArrayName)
85 {
86 delete[] this->LengthArrayName;
87 this->LengthArrayName = NULL;
88 }
89
90 if (this->CurvatureArrayName)
91 {
92 delete[] this->CurvatureArrayName;
93 this->CurvatureArrayName = NULL;
94 }
95
96 if (this->TorsionArrayName)
97 {
98 delete[] this->TorsionArrayName;
99 this->TorsionArrayName = NULL;
100 }
101
102 if (this->TortuosityArrayName)
103 {
104 delete[] this->TortuosityArrayName;
105 this->TortuosityArrayName = NULL;
106 }
107}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCenterlineBranchGeometry::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCenterlineBranchGeometry * vtkvmtkCenterlineBranchGeometry::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 584 of file vtkvmtkCenterlineBranchGeometry.cxx.

585{
586 this->Superclass::PrintSelf(os,indent);
587}

◆ New()

vtkvmtkCenterlineBranchGeometry * vtkvmtkCenterlineBranchGeometry::New ( )
static

◆ SetRadiusArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetRadiusArrayName ( const char * )
virtual

Set/Get the name of the point data array of the input centerlines holding the maximum inscribed sphere radius at each point. Required when SphereSubsampling is on. Commonly named "MaximumInscribedSphereRadius".

◆ GetRadiusArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetRadiusArrayName ( )
virtual

Set/Get the name of the point data array of the input centerlines holding the maximum inscribed sphere radius at each point. Required when SphereSubsampling is on. Commonly named "MaximumInscribedSphereRadius".

◆ SetGroupIdsArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetGroupIdsArrayName ( const char * )
virtual

Set/Get the name of the cell data array of the input centerlines holding the branch group id of each cell. Required input; see vtkvmtkCenterlineSplittingAndGroupingFilter. Commonly named "GroupIds".

◆ GetGroupIdsArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetGroupIdsArrayName ( )
virtual

Set/Get the name of the cell data array of the input centerlines holding the branch group id of each cell. Required input; see vtkvmtkCenterlineSplittingAndGroupingFilter. Commonly named "GroupIds".

◆ SetBlankingArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetBlankingArrayName ( const char * )
virtual

Set/Get the name of the cell data array of the input centerlines holding, for each cell, whether it is a "blanked" (redundant, overlapping) tract – blanked cells are excluded from the geometry computation for each branch. Commonly named "Blanking".

◆ GetBlankingArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetBlankingArrayName ( )
virtual

Set/Get the name of the cell data array of the input centerlines holding, for each cell, whether it is a "blanked" (redundant, overlapping) tract – blanked cells are excluded from the geometry computation for each branch. Commonly named "Blanking".

◆ SetLengthArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetLengthArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the arc length of each branch is stored. Commonly named "Length".

◆ GetLengthArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetLengthArrayName ( )
virtual

Set/Get the name of the output cell data array where the arc length of each branch is stored. Commonly named "Length".

◆ SetCurvatureArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetCurvatureArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the (length-weighted average) curvature of each branch is stored. Commonly named "Curvature".

◆ GetCurvatureArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetCurvatureArrayName ( )
virtual

Set/Get the name of the output cell data array where the (length-weighted average) curvature of each branch is stored. Commonly named "Curvature".

◆ SetTorsionArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetTorsionArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the (length-weighted average) torsion of each branch is stored. Commonly named "Torsion".

◆ GetTorsionArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetTorsionArrayName ( )
virtual

Set/Get the name of the output cell data array where the (length-weighted average) torsion of each branch is stored. Commonly named "Torsion".

◆ SetTortuosityArrayName()

virtual void vtkvmtkCenterlineBranchGeometry::SetTortuosityArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the tortuosity of each branch is stored, computed as (branch length / chord length) - 1. Commonly named "Tortuosity".

◆ GetTortuosityArrayName()

virtual char * vtkvmtkCenterlineBranchGeometry::GetTortuosityArrayName ( )
virtual

Set/Get the name of the output cell data array where the tortuosity of each branch is stored, computed as (branch length / chord length) - 1. Commonly named "Tortuosity".

◆ SetMinSubsamplingSpacing()

virtual void vtkvmtkCenterlineBranchGeometry::SetMinSubsamplingSpacing ( double )
virtual

Set/Get the minimum point spacing enforced when LineSubsampling is on: points closer together than this along a branch are merged before computing curvature/torsion, to stabilize the second-derivative estimates. Default: 0.1.

◆ GetMinSubsamplingSpacing()

virtual double vtkvmtkCenterlineBranchGeometry::GetMinSubsamplingSpacing ( )
virtual

Set/Get the minimum point spacing enforced when LineSubsampling is on: points closer together than this along a branch are merged before computing curvature/torsion, to stabilize the second-derivative estimates. Default: 0.1.

◆ SetSmoothingFactor()

virtual void vtkvmtkCenterlineBranchGeometry::SetSmoothingFactor ( double )
virtual

Set/Get the relaxation factor used by the optional Laplacian smoothing pass applied to each branch's points before curvature/torsion are computed (see LineSmoothing). Default: 0.01.

◆ GetSmoothingFactor()

virtual double vtkvmtkCenterlineBranchGeometry::GetSmoothingFactor ( )
virtual

Set/Get the relaxation factor used by the optional Laplacian smoothing pass applied to each branch's points before curvature/torsion are computed (see LineSmoothing). Default: 0.01.

◆ SetNumberOfSmoothingIterations()

virtual void vtkvmtkCenterlineBranchGeometry::SetNumberOfSmoothingIterations ( int )
virtual

Set/Get the number of Laplacian smoothing iterations applied to each branch's points before curvature/torsion are computed (see LineSmoothing). Default: 100.

◆ GetNumberOfSmoothingIterations()

virtual int vtkvmtkCenterlineBranchGeometry::GetNumberOfSmoothingIterations ( )
virtual

Set/Get the number of Laplacian smoothing iterations applied to each branch's points before curvature/torsion are computed (see LineSmoothing). Default: 100.

◆ SetLineSmoothing()

virtual void vtkvmtkCenterlineBranchGeometry::SetLineSmoothing ( int )
virtual

Toggle Laplacian smoothing of each branch's points prior to computing curvature and torsion, to stabilize the second-derivative estimates on noisy or piecewise-linear centerlines. Default: off.

◆ GetLineSmoothing()

virtual int vtkvmtkCenterlineBranchGeometry::GetLineSmoothing ( )
virtual

Toggle Laplacian smoothing of each branch's points prior to computing curvature and torsion, to stabilize the second-derivative estimates on noisy or piecewise-linear centerlines. Default: off.

◆ LineSmoothingOn()

virtual void vtkvmtkCenterlineBranchGeometry::LineSmoothingOn ( )
virtual

Toggle Laplacian smoothing of each branch's points prior to computing curvature and torsion, to stabilize the second-derivative estimates on noisy or piecewise-linear centerlines. Default: off.

◆ LineSmoothingOff()

virtual void vtkvmtkCenterlineBranchGeometry::LineSmoothingOff ( )
virtual

Toggle Laplacian smoothing of each branch's points prior to computing curvature and torsion, to stabilize the second-derivative estimates on noisy or piecewise-linear centerlines. Default: off.

◆ SetLineSubsampling()

virtual void vtkvmtkCenterlineBranchGeometry::SetLineSubsampling ( int )
virtual

Toggle subsampling of each branch's points to (approximately) MinSubsamplingSpacing before the geometry computation. Default: on.

◆ GetLineSubsampling()

virtual int vtkvmtkCenterlineBranchGeometry::GetLineSubsampling ( )
virtual

Toggle subsampling of each branch's points to (approximately) MinSubsamplingSpacing before the geometry computation. Default: on.

◆ LineSubsamplingOn()

virtual void vtkvmtkCenterlineBranchGeometry::LineSubsamplingOn ( )
virtual

Toggle subsampling of each branch's points to (approximately) MinSubsamplingSpacing before the geometry computation. Default: on.

◆ LineSubsamplingOff()

virtual void vtkvmtkCenterlineBranchGeometry::LineSubsamplingOff ( )
virtual

Toggle subsampling of each branch's points to (approximately) MinSubsamplingSpacing before the geometry computation. Default: on.

◆ SetSphereSubsampling()

virtual void vtkvmtkCenterlineBranchGeometry::SetSphereSubsampling ( int )
virtual

Toggle an alternative subsampling strategy that walks along each branch skipping ahead by the local maximum inscribed sphere radius (from RadiusArrayName) at each step, rather than a fixed spacing. Default: on.

◆ GetSphereSubsampling()

virtual int vtkvmtkCenterlineBranchGeometry::GetSphereSubsampling ( )
virtual

Toggle an alternative subsampling strategy that walks along each branch skipping ahead by the local maximum inscribed sphere radius (from RadiusArrayName) at each step, rather than a fixed spacing. Default: on.

◆ SphereSubsamplingOn()

virtual void vtkvmtkCenterlineBranchGeometry::SphereSubsamplingOn ( )
virtual

Toggle an alternative subsampling strategy that walks along each branch skipping ahead by the local maximum inscribed sphere radius (from RadiusArrayName) at each step, rather than a fixed spacing. Default: on.

◆ SphereSubsamplingOff()

virtual void vtkvmtkCenterlineBranchGeometry::SphereSubsamplingOff ( )
virtual

Toggle an alternative subsampling strategy that walks along each branch skipping ahead by the local maximum inscribed sphere radius (from RadiusArrayName) at each step, rather than a fixed spacing. Default: on.

◆ RequestData()

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

Definition at line 109 of file vtkvmtkCenterlineBranchGeometry.cxx.

113{
114 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
115 vtkInformation *outInfo = outputVector->GetInformationObject(0);
116
117 vtkPolyData *input = vtkPolyData::SafeDownCast(
118 inInfo->Get(vtkDataObject::DATA_OBJECT()));
119 vtkPolyData *output = vtkPolyData::SafeDownCast(
120 outInfo->Get(vtkDataObject::DATA_OBJECT()));
121
122 if (!this->RadiusArrayName)
123 {
124 vtkErrorMacro(<<"RadiusArrayName not specified");
125 return 1;
126 }
127
128 vtkDataArray* radiusArray = input->GetPointData()->GetArray(this->RadiusArrayName);
129
130 if (!radiusArray)
131 {
132 vtkErrorMacro(<<"RadiusArray with name specified does not exist");
133 return 1;
134 }
135
136 if (!this->GroupIdsArrayName)
137 {
138 vtkErrorMacro(<<"GroupIdsArrayName not specified");
139 return 1;
140 }
141
142 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->GroupIdsArrayName);
143
144 if (!groupIdsArray)
145 {
146 vtkErrorMacro(<<"GroupIdsArray with name specified does not exist");
147 return 1;
148 }
149
150 if (!this->BlankingArrayName)
151 {
152 vtkErrorMacro(<<"BlankingArrayName not specified");
153 return 1;
154 }
155
156 vtkDataArray* blankingArray = input->GetCellData()->GetArray(this->BlankingArrayName);
157
158 if (!blankingArray)
159 {
160 vtkErrorMacro(<<"BlankingArray with name specified does not exist");
161 return 1;
162 }
163
164 if (!this->LengthArrayName)
165 {
166 vtkErrorMacro(<<"LengthArrayName not specified");
167 return 1;
168 }
169
170 if (!this->CurvatureArrayName)
171 {
172 vtkErrorMacro(<<"CurvatureArrayName not specified");
173 return 1;
174 }
175
176 if (!this->TorsionArrayName)
177 {
178 vtkErrorMacro(<<"TorsionArrayName not specified");
179 return 1;
180 }
181
182 if (!this->TortuosityArrayName)
183 {
184 vtkErrorMacro(<<"TortuosityArrayName not specified");
185 return 1;
186 }
187
188 vtkDoubleArray* lengthArray = vtkDoubleArray::New();
189 lengthArray->SetName(this->LengthArrayName);
190
191 vtkDoubleArray* curvatureArray = vtkDoubleArray::New();
192 curvatureArray->SetName(this->CurvatureArrayName);
193
194 vtkDoubleArray* torsionArray = vtkDoubleArray::New();
195 torsionArray->SetName(this->TorsionArrayName);
196
197 vtkDoubleArray* tortuosityArray = vtkDoubleArray::New();
198 tortuosityArray->SetName(this->TortuosityArrayName);
199
200 vtkDoubleArray* branchGroupIdsArray = vtkDoubleArray::New();
201 branchGroupIdsArray->SetName(this->GroupIdsArrayName);
202
203 output->GetPointData()->AddArray(lengthArray);
204 output->GetPointData()->AddArray(curvatureArray);
205 output->GetPointData()->AddArray(torsionArray);
206 output->GetPointData()->AddArray(tortuosityArray);
207 output->GetPointData()->AddArray(branchGroupIdsArray);
208
209 vtkPoints* outputPoints = vtkPoints::New();
210 vtkCellArray* outputVerts = vtkCellArray::New();
211
212 output->SetPoints(outputPoints);
213 output->SetVerts(outputVerts);
214
215 vtkIdList* nonBlankedGroupIds = vtkIdList::New();
217 for (int i=0; i<nonBlankedGroupIds->GetNumberOfIds(); i++)
218 {
219 vtkIdType groupId = nonBlankedGroupIds->GetId(i);
220
221 double groupLength = this->ComputeGroupLength(input,groupId);
222 double groupCurvature = this->ComputeGroupCurvature(input,groupId);
223 double groupTorsion = this->ComputeGroupTorsion(input,groupId);
224 double groupTortuosity = this->ComputeGroupTortuosity(input,groupId,groupLength);
225
226 branchGroupIdsArray->InsertNextTuple1(groupId);
227 lengthArray->InsertNextTuple1(groupLength);
228 curvatureArray->InsertNextTuple1(groupCurvature);
229 torsionArray->InsertNextTuple1(groupTorsion);
230 tortuosityArray->InsertNextTuple1(groupTortuosity);
231
232 double zeroPoint[3];
233 zeroPoint[0] = zeroPoint[1] = zeroPoint[2] = 0.0;
234 vtkIdType pointId = outputPoints->InsertNextPoint(zeroPoint);
235 outputVerts->InsertNextCell(1);
236 outputVerts->InsertCellPoint(pointId);
237 }
238 nonBlankedGroupIds->Delete();
239
240 outputPoints->Delete();
241 outputVerts->Delete();
242
243 lengthArray->Delete();
244 curvatureArray->Delete();
245 torsionArray->Delete();
246 tortuosityArray->Delete();
247 branchGroupIdsArray->Delete();
248
249 return 1;
250}
double ComputeGroupLength(vtkPolyData *input, int branchGroupId)
double ComputeGroupTortuosity(vtkPolyData *input, int branchGroupId, double groupLength)
double ComputeGroupCurvature(vtkPolyData *input, int branchGroupId)
double ComputeGroupTorsion(vtkPolyData *input, int branchGroupId)
static void GetNonBlankedGroupsIdList(vtkPolyData *centerlines, const char *groupIdsArrayName, const char *blankingArrayName, vtkIdList *groupIds)

◆ ComputeGroupLength()

double vtkvmtkCenterlineBranchGeometry::ComputeGroupLength ( vtkPolyData * input,
int branchGroupId )
protected

Definition at line 252 of file vtkvmtkCenterlineBranchGeometry.cxx.

253{
254 double groupLength = 0.0;
255
256 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->GroupIdsArrayName);
257
258 int numberOfCells = input->GetNumberOfCells();
259
260 double lengthWeightSum = 0.0;
261
262 for (int i=0; i<numberOfCells; i++)
263 {
264 int groupId = static_cast<int>(groupIdsArray->GetComponent(i,0));
265
266 if (groupId != branchGroupId)
267 {
268 continue;
269 }
270
271 int numberOfCellPoints = input->GetCell(i)->GetNumberOfPoints();
272
273 double length = 0.0;
274
275 double point0[3], point1[3];
276 for (int j=0; j<numberOfCellPoints-1; j++)
277 {
278 input->GetCell(i)->GetPoints()->GetPoint(j,point0);
279 input->GetCell(i)->GetPoints()->GetPoint(j+1,point1);
280
281 length += sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
282 }
283
284 groupLength += length;
285 lengthWeightSum += 1.0;
286 }
287
288 groupLength /= lengthWeightSum;
289
290 return groupLength;
291}

◆ ComputeGroupCurvature()

double vtkvmtkCenterlineBranchGeometry::ComputeGroupCurvature ( vtkPolyData * input,
int branchGroupId )
protected

Definition at line 293 of file vtkvmtkCenterlineBranchGeometry.cxx.

294{
295 double groupCurvature = 0.0;
296
297 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->GroupIdsArrayName);
298
299 int numberOfCells = input->GetNumberOfCells();
300
301 double groupCurvatureWeightSum = 0.0;
302
303 for (int i=0; i<numberOfCells; i++)
304 {
305 int groupId = static_cast<int>(groupIdsArray->GetComponent(i,0));
306
307 if (groupId != branchGroupId)
308 {
309 continue;
310 }
311
312 vtkPoints* linePoints = vtkPoints::New();
313#ifndef SPIRAL_TEST
314 linePoints->DeepCopy(input->GetCell(i)->GetPoints());
315#else
316 int numberOfSectors = 5;
317 for (int j=0; j<numberOfSectors; j++)
318 {
319 double point[3];
320 point[0] = cos(j*2.0*vtkMath::Pi()/numberOfSectors);
321 point[1] = sin(j*2.0*vtkMath::Pi()/numberOfSectors);
322 point[2] = j*(2.0*vtkMath::Pi()/numberOfSectors);
323 linePoints->InsertNextPoint(point);
324 }
325#endif
326
327 if (this->LineSmoothing)
328 {
329 vtkPoints* smoothLinePoints = vtkPoints::New();
331 linePoints->DeepCopy(smoothLinePoints);
332 smoothLinePoints->Delete();
333 }
334
335 if (this->LineSubsampling)
336 {
337 vtkPoints* subsampledLinePoints = vtkPoints::New();
338 if (this->SphereSubsampling)
339 {
340 this->SphereSubsampleLine(input,i,subsampledLinePoints);
341 }
342 else
343 {
344 this->SubsampleLine(linePoints,subsampledLinePoints,this->MinSubsamplingSpacing);
345 }
346 linePoints->DeepCopy(subsampledLinePoints);
347 subsampledLinePoints->Delete();
348 }
349
350 vtkDoubleArray* curvatureArray = vtkDoubleArray::New();
351 double curvature = vtkvmtkCenterlineGeometry::ComputeLineCurvature(linePoints,curvatureArray);
352
353 curvatureArray->Delete();
354 linePoints->Delete();
355
356 groupCurvature += curvature;
357 groupCurvatureWeightSum += 1.0;
358 }
359
360 groupCurvature /= groupCurvatureWeightSum;
361
362// cout<<"Group curvature:"<<groupCurvature<<endl;
363
364 return groupCurvature;
365}
void SphereSubsampleLine(vtkPolyData *input, vtkIdType cellId, vtkPoints *subsampledLinePoints)
static void SubsampleLine(vtkPoints *linePoints, vtkPoints *subsampledLinePoints, double minSpacing=0.01)
static double ComputeLineCurvature(vtkPoints *linePoints, vtkDoubleArray *curvatureArray)
static void SmoothLine(vtkPoints *linePoints, vtkPoints *smoothLinePoints, int numberOfIterations=10, double relaxation=0.1)

◆ ComputeGroupTorsion()

double vtkvmtkCenterlineBranchGeometry::ComputeGroupTorsion ( vtkPolyData * input,
int branchGroupId )
protected

Definition at line 367 of file vtkvmtkCenterlineBranchGeometry.cxx.

368{
369 double groupTorsion = 0.0;
370
371 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->GroupIdsArrayName);
372
373 int numberOfCells = input->GetNumberOfCells();
374
375 double groupTorsionWeightSum = 0.0;
376
377 for (int i=0; i<numberOfCells; i++)
378 {
379 int groupId = static_cast<int>(groupIdsArray->GetComponent(i,0));
380
381 if (groupId != branchGroupId)
382 {
383 continue;
384 }
385
386 vtkPoints* linePoints = vtkPoints::New();
387#ifndef SPIRAL_TEST
388 linePoints->DeepCopy(input->GetCell(i)->GetPoints());
389#else
390 int numberOfSectors = 5;
391 for (int j=0; j<numberOfSectors; j++)
392 {
393 double point[3];
394 point[0] = cos(j*2.0*vtkMath::Pi()/numberOfSectors);
395 point[1] = sin(j*2.0*vtkMath::Pi()/numberOfSectors);
396 point[2] = j*(2.0*vtkMath::Pi()/numberOfSectors);
397 linePoints->InsertNextPoint(point);
398 }
399#endif
400
401 if (this->LineSmoothing)
402 {
403 vtkPoints* smoothLinePoints = vtkPoints::New();
405 linePoints->DeepCopy(smoothLinePoints);
406 smoothLinePoints->Delete();
407 }
408
409 if (this->LineSubsampling)
410 {
411 vtkPoints* subsampledLinePoints = vtkPoints::New();
412 if (this->SphereSubsampling)
413 {
414 this->SphereSubsampleLine(input,i,subsampledLinePoints);
415 }
416 else
417 {
418 this->SubsampleLine(linePoints,subsampledLinePoints,this->MinSubsamplingSpacing);
419 }
420 linePoints->DeepCopy(subsampledLinePoints);
421 subsampledLinePoints->Delete();
422 }
423
424 vtkDoubleArray* torsionArray = vtkDoubleArray::New();
425 double torsion = vtkvmtkCenterlineGeometry::ComputeLineTorsion(linePoints,torsionArray);
426
427 torsionArray->Delete();
428
429 linePoints->Delete();
430
431 groupTorsion += torsion;
432 groupTorsionWeightSum += 1.0;
433 }
434
435 groupTorsion /= groupTorsionWeightSum;
436
437// cout<<"Group torsion:"<<groupTorsion<<endl;
438
439 return groupTorsion;
440}
static double ComputeLineTorsion(vtkPoints *linePoints, vtkDoubleArray *torsionArray)

◆ ComputeGroupTortuosity()

double vtkvmtkCenterlineBranchGeometry::ComputeGroupTortuosity ( vtkPolyData * input,
int branchGroupId,
double groupLength )
protected

Definition at line 524 of file vtkvmtkCenterlineBranchGeometry.cxx.

525{
526 double groupTortuosity = 0.0;
527
528 vtkDataArray* groupIdsArray = input->GetCellData()->GetArray(this->GroupIdsArrayName);
529 vtkDataArray* radiusArray = input->GetPointData()->GetArray(this->RadiusArrayName);
530
531 int numberOfCells = input->GetNumberOfCells();
532
533 double averageFirstPoint[3], averageLastPoint[3];
534 averageFirstPoint[0] = averageFirstPoint[1] = averageFirstPoint[2] = 0.0;
535 averageLastPoint[0] = averageLastPoint[1] = averageLastPoint[2] = 0.0;
536 double firstPointWeightSum = 0.0;
537 double lastPointWeightSum = 0.0;
538
539 for (int i=0; i<numberOfCells; i++)
540 {
541 int groupId = static_cast<int>(groupIdsArray->GetComponent(i,0));
542
543 if (groupId != branchGroupId)
544 {
545 continue;
546 }
547
548 int numberOfCellPoints = input->GetCell(i)->GetNumberOfPoints();
549
550 double firstPoint[3], lastPoint[3];
551
552 input->GetCell(i)->GetPoints()->GetPoint(0,firstPoint);
553 input->GetCell(i)->GetPoints()->GetPoint(numberOfCellPoints-1,lastPoint);
554
555 double firstPointRadius = radiusArray->GetComponent(input->GetCell(i)->GetPointId(0),0);
556 double lastPointRadius = radiusArray->GetComponent(input->GetCell(i)->GetPointId(numberOfCellPoints-1),0);
557
558 averageFirstPoint[0] += firstPointRadius * firstPointRadius * firstPoint[0];
559 averageFirstPoint[1] += firstPointRadius * firstPointRadius * firstPoint[1];
560 averageFirstPoint[2] += firstPointRadius * firstPointRadius * firstPoint[2];
561
562 firstPointWeightSum += firstPointRadius * firstPointRadius;
563
564 averageLastPoint[0] += lastPointRadius * lastPointRadius * lastPoint[0];
565 averageLastPoint[1] += lastPointRadius * lastPointRadius * lastPoint[1];
566 averageLastPoint[2] += lastPointRadius * lastPointRadius * lastPoint[2];
567
568 lastPointWeightSum += lastPointRadius * lastPointRadius;
569 }
570
571 averageFirstPoint[0] /= firstPointWeightSum;
572 averageFirstPoint[1] /= firstPointWeightSum;
573 averageFirstPoint[2] /= firstPointWeightSum;
574
575 averageLastPoint[0] /= lastPointWeightSum;
576 averageLastPoint[1] /= lastPointWeightSum;
577 averageLastPoint[2] /= lastPointWeightSum;
578
579 groupTortuosity = groupLength / sqrt(vtkMath::Distance2BetweenPoints(averageFirstPoint,averageLastPoint)) - 1.0;
580
581 return groupTortuosity;
582}

◆ SubsampleLine()

void vtkvmtkCenterlineBranchGeometry::SubsampleLine ( vtkPoints * linePoints,
vtkPoints * subsampledLinePoints,
double minSpacing = 0.01 )
staticprotected

Definition at line 443 of file vtkvmtkCenterlineBranchGeometry.cxx.

444{
445 int numberOfPoints = linePoints->GetNumberOfPoints();
446
447 double point0[3];
448 double point1[3];
449
450 double spacing = 0.0;
451 linePoints->GetPoint(0,point0);
452 subsampledLinePoints->InsertNextPoint(point0);
453 for (int j=1; j<numberOfPoints-1; j++)
454 {
455 linePoints->GetPoint(j,point1);
456
457 spacing += sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
458
459 if (spacing < minSpacing)
460 {
461 continue;
462 }
463
464 subsampledLinePoints->InsertNextPoint(point1);
465 linePoints->GetPoint(j,point0);
466 spacing = 0.0;
467 }
468
469 linePoints->GetPoint(numberOfPoints-1,point1);
470
471 spacing = sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
472
473 if (spacing<minSpacing)
474 {
475 int numberOfSubsampledPoints = subsampledLinePoints->GetNumberOfPoints();
476 subsampledLinePoints->InsertPoint(numberOfSubsampledPoints-1,point1);
477 }
478 else
479 {
480 subsampledLinePoints->InsertNextPoint(point1);
481 }
482}

◆ SphereSubsampleLine()

void vtkvmtkCenterlineBranchGeometry::SphereSubsampleLine ( vtkPolyData * input,
vtkIdType cellId,
vtkPoints * subsampledLinePoints )
protected

Definition at line 484 of file vtkvmtkCenterlineBranchGeometry.cxx.

485{
486 vtkIdType subId = 0;
487 double pcoord = 0.0;
488
489 vtkIdType touchingSubId = 0;
490 double touchingPCoord = 0.0;
491
492 double point[3];
493 double point0[3];
494 double point1[3];
495
496 subsampledLinePoints->InsertNextPoint(input->GetCell(cellId)->GetPoints()->GetPoint(0));
497
498 while (touchingSubId != -1)
499 {
500 vtkvmtkCenterlineSphereDistance::FindTouchingSphereCenter(input, this->RadiusArrayName, cellId, subId, pcoord, touchingSubId, touchingPCoord, false);
501
502 if (touchingSubId == -1)
503 {
504 break;
505 }
506
507 input->GetCell(cellId)->GetPoints()->GetPoint(touchingSubId,point0);
508 input->GetCell(cellId)->GetPoints()->GetPoint(touchingSubId+1,point1);
509
510 point[0] = (1.0 - touchingPCoord) * point0[0] + touchingPCoord * point1[0];
511 point[1] = (1.0 - touchingPCoord) * point0[1] + touchingPCoord * point1[1];
512 point[2] = (1.0 - touchingPCoord) * point0[2] + touchingPCoord * point1[2];
513
514 subsampledLinePoints->InsertNextPoint(point);
515
516 subId = touchingSubId;
517 pcoord = touchingPCoord;
518 }
519
520 subsampledLinePoints->InsertNextPoint(input->GetCell(cellId)->GetPoints()->GetPoint(input->GetCell(cellId)->GetNumberOfPoints()-1));
521
522}
static void FindTouchingSphereCenter(vtkPolyData *centerlines, const char *radiusArrayName, vtkIdType cellId, vtkIdType subId, double pcoord, vtkIdType &touchingSubId, double &touchingPCoord, bool forward=true)

Member Data Documentation

◆ RadiusArrayName

char* vtkvmtkCenterlineBranchGeometry::RadiusArrayName
protected

Definition at line 199 of file vtkvmtkCenterlineBranchGeometry.h.

◆ GroupIdsArrayName

char* vtkvmtkCenterlineBranchGeometry::GroupIdsArrayName
protected

Definition at line 200 of file vtkvmtkCenterlineBranchGeometry.h.

◆ BlankingArrayName

char* vtkvmtkCenterlineBranchGeometry::BlankingArrayName
protected

Definition at line 201 of file vtkvmtkCenterlineBranchGeometry.h.

◆ LengthArrayName

char* vtkvmtkCenterlineBranchGeometry::LengthArrayName
protected

Definition at line 203 of file vtkvmtkCenterlineBranchGeometry.h.

◆ CurvatureArrayName

char* vtkvmtkCenterlineBranchGeometry::CurvatureArrayName
protected

Definition at line 204 of file vtkvmtkCenterlineBranchGeometry.h.

◆ TorsionArrayName

char* vtkvmtkCenterlineBranchGeometry::TorsionArrayName
protected

Definition at line 205 of file vtkvmtkCenterlineBranchGeometry.h.

◆ TortuosityArrayName

char* vtkvmtkCenterlineBranchGeometry::TortuosityArrayName
protected

Definition at line 206 of file vtkvmtkCenterlineBranchGeometry.h.

◆ LineSubsampling

int vtkvmtkCenterlineBranchGeometry::LineSubsampling
protected

Definition at line 208 of file vtkvmtkCenterlineBranchGeometry.h.

◆ SphereSubsampling

int vtkvmtkCenterlineBranchGeometry::SphereSubsampling
protected

Definition at line 209 of file vtkvmtkCenterlineBranchGeometry.h.

◆ LineSmoothing

int vtkvmtkCenterlineBranchGeometry::LineSmoothing
protected

Definition at line 210 of file vtkvmtkCenterlineBranchGeometry.h.

◆ MinSubsamplingSpacing

double vtkvmtkCenterlineBranchGeometry::MinSubsamplingSpacing
protected

Definition at line 212 of file vtkvmtkCenterlineBranchGeometry.h.

◆ SmoothingFactor

double vtkvmtkCenterlineBranchGeometry::SmoothingFactor
protected

Definition at line 213 of file vtkvmtkCenterlineBranchGeometry.h.

◆ NumberOfSmoothingIterations

int vtkvmtkCenterlineBranchGeometry::NumberOfSmoothingIterations
protected

Definition at line 214 of file vtkvmtkCenterlineBranchGeometry.h.


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