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

Extract a set of vessel sections from a surface along a centerline. More...

#include <vtkvmtkPolyDataCenterlineSections.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataCenterlineSections * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetCenterlines (vtkPolyData *)
virtual vtkPolyData * GetCenterlines ()
virtual void SetCenterlineSectionAreaArrayName (const char *)
virtual char * GetCenterlineSectionAreaArrayName ()
virtual void SetCenterlineSectionMinSizeArrayName (const char *)
virtual char * GetCenterlineSectionMinSizeArrayName ()
virtual void SetCenterlineSectionMaxSizeArrayName (const char *)
virtual char * GetCenterlineSectionMaxSizeArrayName ()
virtual void SetCenterlineSectionShapeArrayName (const char *)
virtual char * GetCenterlineSectionShapeArrayName ()
virtual void SetCenterlineSectionClosedArrayName (const char *)
virtual char * GetCenterlineSectionClosedArrayName ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataCenterlineSections ()
 ~vtkvmtkPolyDataCenterlineSections ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void ComputeCenterlineSections (vtkPolyData *input, vtkPolyData *output)
virtual bool ComputeSectionPlane (vtkIdType cellId, vtkIdType cellPointIndex, double origin[3], double normal[3])
virtual void ExtractSection (vtkPolyData *input, double origin[3], double normal[3], vtkPolyData *section, bool &closed)
virtual void ProcessSection (vtkPolyData *input, vtkIdType pointId, vtkIdType sectionId, vtkPolyData *section, double origin[3], double normal[3], bool closed)
bool AbortRequested ()

Protected Attributes

vtkPolyData * Centerlines
char * CenterlineSectionAreaArrayName
char * CenterlineSectionMinSizeArrayName
char * CenterlineSectionMaxSizeArrayName
char * CenterlineSectionShapeArrayName
char * CenterlineSectionClosedArrayName

Detailed Description

Extract a set of vessel sections from a surface along a centerline.

Unlike vtkvmtkPolyDataBranchSections/vtkvmtkPolyDataBifurcationSections (which cut one section at a fixed sphere-distance per branch/bifurcation), this class cuts one cross-section at every point of the input Centerlines, giving a dense series of sections along the whole vessel.

The set of vessel sections contain the profile as well as the the following information about the section:

  • Centerline Section Area
  • Centerline Section Min Size
  • Centerline Section Max Size
  • Centerline Section Shape
  • Centerline Section Closed
See also
vtkvmtkPolyDataBranchSections, vtkvmtkPolyDataBifurcationSections

Definition at line 45 of file vtkvmtkPolyDataCenterlineSections.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataCenterlineSections::Superclass

Definition at line 48 of file vtkvmtkPolyDataCenterlineSections.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataCenterlineSections()

◆ ~vtkvmtkPolyDataCenterlineSections()

vtkvmtkPolyDataCenterlineSections::~vtkvmtkPolyDataCenterlineSections ( )
protected

Definition at line 154 of file vtkvmtkPolyDataCenterlineSections.cxx.

155{
156 if (this->Centerlines)
157 {
158 this->Centerlines->Delete();
159 this->Centerlines = NULL;
160 }
161
163 {
164 delete[] this->CenterlineSectionAreaArrayName;
166 }
167
169 {
172 }
173
175 {
178 }
179
181 {
182 delete[] this->CenterlineSectionShapeArrayName;
184 }
185
187 {
190 }
191}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataCenterlineSections::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataCenterlineSections * vtkvmtkPolyDataCenterlineSections::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 441 of file vtkvmtkPolyDataCenterlineSections.cxx.

442{
443 this->Superclass::PrintSelf(os,indent);
444}

◆ New()

vtkvmtkPolyDataCenterlineSections * vtkvmtkPolyDataCenterlineSections::New ( )
static

◆ SetCenterlines()

virtual void vtkvmtkPolyDataCenterlineSections::SetCenterlines ( vtkPolyData * )
virtual

Set/Get the centerline(s) along which sections are cut, one per centerline point. Required input.

◆ GetCenterlines()

virtual vtkPolyData * vtkvmtkPolyDataCenterlineSections::GetCenterlines ( )
virtual

Set/Get the centerline(s) along which sections are cut, one per centerline point. Required input.

◆ SetCenterlineSectionAreaArrayName()

virtual void vtkvmtkPolyDataCenterlineSections::SetCenterlineSectionAreaArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the cross-sectional area of each section is stored. Commonly named "CenterlineSectionArea".

◆ GetCenterlineSectionAreaArrayName()

virtual char * vtkvmtkPolyDataCenterlineSections::GetCenterlineSectionAreaArrayName ( )
virtual

Set/Get the name of the output cell data array where the cross-sectional area of each section is stored. Commonly named "CenterlineSectionArea".

◆ SetCenterlineSectionMinSizeArrayName()

virtual void vtkvmtkPolyDataCenterlineSections::SetCenterlineSectionMinSizeArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the minimum diameter of each section is stored. Commonly named "CenterlineSectionMinSize".

◆ GetCenterlineSectionMinSizeArrayName()

virtual char * vtkvmtkPolyDataCenterlineSections::GetCenterlineSectionMinSizeArrayName ( )
virtual

Set/Get the name of the output cell data array where the minimum diameter of each section is stored. Commonly named "CenterlineSectionMinSize".

◆ SetCenterlineSectionMaxSizeArrayName()

virtual void vtkvmtkPolyDataCenterlineSections::SetCenterlineSectionMaxSizeArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the maximum diameter of each section is stored. Commonly named "CenterlineSectionMaxSize".

◆ GetCenterlineSectionMaxSizeArrayName()

virtual char * vtkvmtkPolyDataCenterlineSections::GetCenterlineSectionMaxSizeArrayName ( )
virtual

Set/Get the name of the output cell data array where the maximum diameter of each section is stored. Commonly named "CenterlineSectionMaxSize".

◆ SetCenterlineSectionShapeArrayName()

virtual void vtkvmtkPolyDataCenterlineSections::SetCenterlineSectionShapeArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where the shape index of each section (the ratio between its minimum and maximum diameter) is stored. Commonly named "CenterlineSectionShape".

◆ GetCenterlineSectionShapeArrayName()

virtual char * vtkvmtkPolyDataCenterlineSections::GetCenterlineSectionShapeArrayName ( )
virtual

Set/Get the name of the output cell data array where the shape index of each section (the ratio between its minimum and maximum diameter) is stored. Commonly named "CenterlineSectionShape".

◆ SetCenterlineSectionClosedArrayName()

virtual void vtkvmtkPolyDataCenterlineSections::SetCenterlineSectionClosedArrayName ( const char * )
virtual

Set/Get the name of the output cell data array where, for each section, whether the cutting plane fully closes off the vessel lumen (1) or not (0) is stored. Commonly named "CenterlineSectionClosed".

◆ GetCenterlineSectionClosedArrayName()

virtual char * vtkvmtkPolyDataCenterlineSections::GetCenterlineSectionClosedArrayName ( )
virtual

Set/Get the name of the output cell data array where, for each section, whether the cutting plane fully closes off the vessel lumen (1) or not (0) is stored. Commonly named "CenterlineSectionClosed".

◆ RequestData()

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

Reimplemented in vtkvmtkPolyDataCenterlineBranchSplitting.

Definition at line 193 of file vtkvmtkPolyDataCenterlineSections.cxx.

197{
198 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
199 vtkInformation *outInfo = outputVector->GetInformationObject(0);
200
201 vtkPolyData *input = vtkPolyData::SafeDownCast(
202 inInfo->Get(vtkDataObject::DATA_OBJECT()));
203 vtkPolyData *output = vtkPolyData::SafeDownCast(
204 outInfo->Get(vtkDataObject::DATA_OBJECT()));
205
206 if (!this->Centerlines)
207 {
208 vtkErrorMacro(<<"Centerlines not set");
209 return 1;
210 }
211
213 {
214 vtkErrorMacro(<<"CenterlineSectionAreaArrayName not specified");
215 return 1;
216 }
217
219 {
220 vtkErrorMacro(<<"CenterlineSectionMinSizeArrayName not specified");
221 return 1;
222 }
223
225 {
226 vtkErrorMacro(<<"CenterlineSectionMaxSizeArrayName not specified");
227 return 1;
228 }
229
231 {
232 vtkErrorMacro(<<"CenterlineSectionShapeArrayName not specified");
233 return 1;
234 }
235
237 {
238 vtkErrorMacro(<<"CenterlineSectionClosedArrayName not specified");
239 return 1;
240 }
241
242 this->SetProgressText("Computing centerline sections");
243 this->UpdateProgress(0.0);
244 this->ComputeCenterlineSections(input,output);
245 this->UpdateProgress(1.0);
246
247 return 1;
248}
void ComputeCenterlineSections(vtkPolyData *input, vtkPolyData *output)

◆ ComputeCenterlineSections()

void vtkvmtkPolyDataCenterlineSections::ComputeCenterlineSections ( vtkPolyData * input,
vtkPolyData * output )
protected

Cut a section of input at each centerline point and store it in output, with its properties both on output and on the centerline point. The section arrays are created here, so the array names must be set; cell data arrays already on output are kept. Points are visited in the order of the centerline cells and of the points in each cell; a point shared by several cells is visited once. A point gets no section if ComputeSectionPlane returns false for it or the plane does not cut input. Progress is reported from 0 to 1 over the points. If an abort is requested, it returns before all points are visited.

Definition at line 259 of file vtkvmtkPolyDataCenterlineSections.cxx.

260{
261 vtkNew<vtkPoints> outputPoints;
262 vtkNew<vtkCellArray> outputPolys;
263
264 output->SetPoints(outputPoints);
265 output->SetPolys(outputPolys);
266 vtkPoints* centerlineSectionPoints = outputPoints;
267 vtkCellArray* centerlineSectionPolys = outputPolys;
268
269 int numberOfCenterlinePoints = this->Centerlines->GetNumberOfPoints();
270
271 // Sections are stored both on the output, one tuple per section, and on
272 // the centerline points. Centerline points that get no section keep 0.
273 vtkNew<vtkDoubleArray> centerlineSectionAreaArray;
274 centerlineSectionAreaArray->SetName(this->CenterlineSectionAreaArrayName);
275 vtkNew<vtkDoubleArray> centerlineSectionMinSizeArray;
276 centerlineSectionMinSizeArray->SetName(this->CenterlineSectionMinSizeArrayName);
277 vtkNew<vtkDoubleArray> centerlineSectionMaxSizeArray;
278 centerlineSectionMaxSizeArray->SetName(this->CenterlineSectionMaxSizeArrayName);
279 vtkNew<vtkDoubleArray> centerlineSectionShapeArray;
280 centerlineSectionShapeArray->SetName(this->CenterlineSectionShapeArrayName);
281 vtkNew<vtkIntArray> centerlineSectionClosedArray;
282 centerlineSectionClosedArray->SetName(this->CenterlineSectionClosedArrayName);
283
284 output->GetCellData()->AddArray(centerlineSectionAreaArray);
285 output->GetCellData()->AddArray(centerlineSectionMinSizeArray);
286 output->GetCellData()->AddArray(centerlineSectionMaxSizeArray);
287 output->GetCellData()->AddArray(centerlineSectionShapeArray);
288 output->GetCellData()->AddArray(centerlineSectionClosedArray);
289
290 vtkNew<vtkDoubleArray> centerlineAreaArray;
291 centerlineAreaArray->SetName(this->CenterlineSectionAreaArrayName);
292 vtkNew<vtkDoubleArray> centerlineMinSizeArray;
293 centerlineMinSizeArray->SetName(this->CenterlineSectionMinSizeArrayName);
294 vtkNew<vtkDoubleArray> centerlineMaxSizeArray;
295 centerlineMaxSizeArray->SetName(this->CenterlineSectionMaxSizeArrayName);
296 vtkNew<vtkDoubleArray> centerlineShapeArray;
297 centerlineShapeArray->SetName(this->CenterlineSectionShapeArrayName);
298 vtkNew<vtkIntArray> centerlineClosedArray;
299 centerlineClosedArray->SetName(this->CenterlineSectionClosedArrayName);
300
301 vtkDataArray* centerlineArrays[] = {centerlineAreaArray, centerlineMinSizeArray, centerlineMaxSizeArray, centerlineShapeArray, centerlineClosedArray};
302 for (vtkDataArray* centerlineArray : centerlineArrays)
303 {
304 centerlineArray->SetNumberOfTuples(numberOfCenterlinePoints);
305 centerlineArray->Fill(0.0);
306 this->Centerlines->GetPointData()->AddArray(centerlineArray);
307 }
308
309 // Points are visited in the order of the centerline cells and of the points
310 // in each cell. A point shared by several cells gets a single section.
311 std::vector<bool> visited(this->Centerlines->GetNumberOfPoints(),false);
312 // Progress is reported, and an abort checked for, about every 1% of points
313 const vtkIdType progressInterval = std::max<vtkIdType>(numberOfCenterlinePoints / 100, 1);
314 vtkIdType numberOfVisitedPoints = 0;
315
316 // The cutter visits every cell of its input, which dominates the time spent
317 // on a section, so only the cells that the plane crosses are cut
318 CrossingCells crossingCells(input);
319 vtkNew<vtkPolyData> sectionInput;
320
321 vtkNew<vtkIdList> cellPointIds;
322 for (vtkIdType cellId=0; cellId<this->Centerlines->GetNumberOfCells(); cellId++)
323 {
324 this->Centerlines->GetCellPoints(cellId,cellPointIds);
325 for (vtkIdType i=0; i<cellPointIds->GetNumberOfIds(); i++)
326 {
327 vtkIdType pointId = cellPointIds->GetId(i);
328 if (visited[pointId])
329 {
330 continue;
331 }
332 visited[pointId] = true;
333
334 if (numberOfVisitedPoints % progressInterval == 0)
335 {
336 this->UpdateProgress(static_cast<double>(numberOfVisitedPoints) / numberOfCenterlinePoints);
337 if (this->AbortRequested())
338 {
339 return;
340 }
341 }
342 numberOfVisitedPoints++;
343
344 double origin[3], normal[3];
345 if (!this->ComputeSectionPlane(cellId,i,origin,normal))
346 {
347 continue;
348 }
349
350 vtkNew<vtkPolyData> section;
351 bool closed = false;
352 if (crossingCells.CanSelect())
353 {
354 crossingCells.Select(origin,normal,sectionInput);
355 this->ExtractSection(sectionInput,origin,normal,section,closed);
356 }
357 else
358 {
359 this->ExtractSection(input,origin,normal,section,closed);
360 }
361
362 section->BuildCells();
363 if (section->GetNumberOfCells() == 0)
364 {
365 // The plane does not cut the surface, for example past an open end
366 continue;
367 }
368
369 vtkPoints* sectionCellPoints = section->GetCell(0)->GetPoints();
370 int numberOfSectionCellPoints = sectionCellPoints->GetNumberOfPoints();
371 vtkIdType sectionId = centerlineSectionPolys->InsertNextCell(numberOfSectionCellPoints);
372 for (int k=0; k<numberOfSectionCellPoints; k++)
373 {
374 vtkIdType sectionPointId = centerlineSectionPoints->InsertNextPoint(sectionCellPoints->GetPoint(k));
375 centerlineSectionPolys->InsertCellPoint(sectionPointId);
376 }
377
379 double sizeRange[2];
380 double shape = vtkvmtkPolyDataBranchSections::ComputeBranchSectionShape(section,origin,sizeRange);
381
382 centerlineSectionAreaArray->InsertNextValue(area);
383 centerlineSectionMinSizeArray->InsertNextValue(sizeRange[0]);
384 centerlineSectionMaxSizeArray->InsertNextValue(sizeRange[1]);
385 centerlineSectionShapeArray->InsertNextValue(shape);
386 centerlineSectionClosedArray->InsertNextValue(closed);
387
388 centerlineAreaArray->SetValue(pointId,area);
389 centerlineMinSizeArray->SetValue(pointId,sizeRange[0]);
390 centerlineMaxSizeArray->SetValue(pointId,sizeRange[1]);
391 centerlineShapeArray->SetValue(pointId,shape);
392 centerlineClosedArray->SetValue(pointId,closed);
393
394 this->ProcessSection(input,pointId,sectionId,section,origin,normal,closed);
395 }
396 }
397}
static double ComputeBranchSectionArea(vtkPolyData *branchSection)
static double ComputeBranchSectionShape(vtkPolyData *branchSection, double center[3], double sizeRange[2])
virtual void ExtractSection(vtkPolyData *input, double origin[3], double normal[3], vtkPolyData *section, bool &closed)
virtual void ProcessSection(vtkPolyData *input, vtkIdType pointId, vtkIdType sectionId, vtkPolyData *section, double origin[3], double normal[3], bool closed)
virtual bool ComputeSectionPlane(vtkIdType cellId, vtkIdType cellPointIndex, double origin[3], double normal[3])

◆ ComputeSectionPlane()

bool vtkvmtkPolyDataCenterlineSections::ComputeSectionPlane ( vtkIdType cellId,
vtkIdType cellPointIndex,
double origin[3],
double normal[3] )
protectedvirtual

Compute the plane of the section at a centerline point, given as the index cellPointIndex of the point within centerline cell cellId. Return false to cut no section at that point. The default places the plane at the point, perpendicular to the average of the directions from the previous and to the next distinct point of the cell, and returns false only if the cell has no point distinct from it. Subclasses can override it, for example to use tangents computed in advance.

Reimplemented in vtkvmtkPolyDataCenterlineBranchSplitting.

Definition at line 399 of file vtkvmtkPolyDataCenterlineSections.cxx.

400{
401 vtkNew<vtkIdList> cellPointIds;
402 this->Centerlines->GetCellPoints(cellId,cellPointIds);
403 const vtkIdType numberOfCellPoints = cellPointIds->GetNumberOfIds();
404
405 this->Centerlines->GetPoint(cellPointIds->GetId(cellPointIndex),origin);
406
407 // Average the directions from the previous and to the next point. Points
408 // that coincide with the section point, such as a duplicated end point, have
409 // no direction, so the nearest distinct point on each side is used instead.
410 normal[0] = normal[1] = normal[2] = 0.0;
411 double neighborPoint[3], direction[3];
412 for (vtkIdType step : {-1, 1})
413 {
414 for (vtkIdType j=cellPointIndex+step; j>=0 && j<numberOfCellPoints; j+=step)
415 {
416 this->Centerlines->GetPoint(cellPointIds->GetId(j),neighborPoint);
417 vtkMath::Subtract(neighborPoint,origin,direction);
418 double distance = vtkMath::Normalize(direction);
419 if (distance > 0.0)
420 {
421 normal[0] += step * direction[0];
422 normal[1] += step * direction[1];
423 normal[2] += step * direction[2];
424 break;
425 }
426 }
427 }
428
429 return vtkMath::Normalize(normal) > 0.0;
430}

◆ ExtractSection()

void vtkvmtkPolyDataCenterlineSections::ExtractSection ( vtkPolyData * input,
double origin[3],
double normal[3],
vtkPolyData * section,
bool & closed )
protectedvirtual

Cut input with the plane specified by origin and normal. The default calls vtkvmtkPolyDataBranchSections::ExtractCylinderSection. Subclasses can override it, for example to keep attributes of input on the section. To save time, ComputeCenterlineSections calls it with only the cells of input that the plane crosses, sharing the points and point data of input, so overrides must depend only on the cut of the cells they are given.

Reimplemented in vtkvmtkPolyDataCenterlineBranchSplitting.

Definition at line 432 of file vtkvmtkPolyDataCenterlineSections.cxx.

433{
434 vtkvmtkPolyDataBranchSections::ExtractCylinderSection(input,origin,normal,section,closed);
435}
static void ExtractCylinderSection(vtkPolyData *cylinder, double origin[3], double normal[3], vtkPolyData *section, bool &closed, const char *idsArrayName=nullptr)

◆ ProcessSection()

void vtkvmtkPolyDataCenterlineSections::ProcessSection ( vtkPolyData * input,
vtkIdType pointId,
vtkIdType sectionId,
vtkPolyData * section,
double origin[3],
double normal[3],
bool closed )
protectedvirtual

Called for each section after it has been added to the output as cell sectionId and its properties have been stored. pointId is the centerline point the section was cut at. The default does nothing. Subclasses can override it to compute and store additional section properties.

Reimplemented in vtkvmtkPolyDataCenterlineBranchSplitting.

Definition at line 437 of file vtkvmtkPolyDataCenterlineSections.cxx.

438{
439}

◆ AbortRequested()

bool vtkvmtkPolyDataCenterlineSections::AbortRequested ( )
protected

Return true if aborting the execution was requested, using vtkAlgorithm::CheckAbort where available (VTK 9.4 and later), so that the output is also flagged as aborted.

Definition at line 250 of file vtkvmtkPolyDataCenterlineSections.cxx.

251{
252#if VTK_MAJOR_VERSION > 9 || (VTK_MAJOR_VERSION == 9 && VTK_MINOR_VERSION >= 4)
253 return this->CheckAbort();
254#else
255 return this->GetAbortExecute() != 0;
256#endif
257}

Member Data Documentation

◆ Centerlines

vtkPolyData* vtkvmtkPolyDataCenterlineSections::Centerlines
protected

Definition at line 162 of file vtkvmtkPolyDataCenterlineSections.h.

◆ CenterlineSectionAreaArrayName

char* vtkvmtkPolyDataCenterlineSections::CenterlineSectionAreaArrayName
protected

Definition at line 164 of file vtkvmtkPolyDataCenterlineSections.h.

◆ CenterlineSectionMinSizeArrayName

char* vtkvmtkPolyDataCenterlineSections::CenterlineSectionMinSizeArrayName
protected

Definition at line 165 of file vtkvmtkPolyDataCenterlineSections.h.

◆ CenterlineSectionMaxSizeArrayName

char* vtkvmtkPolyDataCenterlineSections::CenterlineSectionMaxSizeArrayName
protected

Definition at line 166 of file vtkvmtkPolyDataCenterlineSections.h.

◆ CenterlineSectionShapeArrayName

char* vtkvmtkPolyDataCenterlineSections::CenterlineSectionShapeArrayName
protected

Definition at line 167 of file vtkvmtkPolyDataCenterlineSections.h.

◆ CenterlineSectionClosedArrayName

char* vtkvmtkPolyDataCenterlineSections::CenterlineSectionClosedArrayName
protected

Definition at line 168 of file vtkvmtkPolyDataCenterlineSections.h.


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