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

Compute centerlines from surface. More...

#include <vtkvmtkPolyDataCenterlines.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataCenterlines * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetSourceSeedIds (vtkIdList *)
virtual vtkIdList * GetSourceSeedIds ()
virtual void SetTargetSeedIds (vtkIdList *)
virtual vtkIdList * GetTargetSeedIds ()
virtual void SetCapCenterIds (vtkIdList *)
virtual vtkIdList * GetCapCenterIds ()
virtual void SetDelaunayTessellation (vtkUnstructuredGrid *)
virtual vtkUnstructuredGrid * GetDelaunayTessellation ()
virtual void SetVoronoiDiagram (vtkPolyData *)
virtual vtkPolyData * GetVoronoiDiagram ()
virtual void SetPoleIds (vtkIdList *)
virtual vtkIdList * GetPoleIds ()
virtual void SetRadiusArrayName (const char *)
virtual char * GetRadiusArrayName ()
virtual void SetCostFunction (const char *)
virtual char * GetCostFunction ()
virtual void SetEikonalSolutionArrayName (const char *)
virtual char * GetEikonalSolutionArrayName ()
virtual void SetEdgeArrayName (const char *)
virtual char * GetEdgeArrayName ()
virtual void SetEdgePCoordArrayName (const char *)
virtual char * GetEdgePCoordArrayName ()
virtual void SetCostFunctionArrayName (const char *)
virtual char * GetCostFunctionArrayName ()
virtual void SetFlipNormals (int)
virtual int GetFlipNormals ()
virtual void FlipNormalsOn ()
virtual void FlipNormalsOff ()
virtual void SetSimplifyVoronoi (int)
virtual int GetSimplifyVoronoi ()
virtual void SimplifyVoronoiOn ()
virtual void SimplifyVoronoiOff ()
virtual void SetCenterlineResampling (int)
virtual int GetCenterlineResampling ()
virtual void CenterlineResamplingOn ()
virtual void CenterlineResamplingOff ()
virtual void SetResamplingStepLength (double)
virtual double GetResamplingStepLength ()
virtual void SetAppendEndPointsToCenterlines (int)
virtual int GetAppendEndPointsToCenterlines ()
virtual void AppendEndPointsToCenterlinesOn ()
virtual void AppendEndPointsToCenterlinesOff ()
virtual void SetGenerateDelaunayTessellation (int)
virtual int GetGenerateDelaunayTessellation ()
virtual void GenerateDelaunayTessellationOn ()
virtual void GenerateDelaunayTessellationOff ()
virtual void SetGenerateVoronoiDiagram (int)
virtual int GetGenerateVoronoiDiagram ()
virtual void GenerateVoronoiDiagramOn ()
virtual void GenerateVoronoiDiagramOff ()
virtual void SetStopFastMarchingOnReachingTarget (int)
virtual int GetStopFastMarchingOnReachingTarget ()
virtual void StopFastMarchingOnReachingTargetOn ()
virtual void StopFastMarchingOnReachingTargetOff ()
virtual void SetDelaunayTolerance (double)
virtual double GetDelaunayTolerance ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataCenterlines ()
 ~vtkvmtkPolyDataCenterlines ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void FindVoronoiSeeds (vtkUnstructuredGrid *delaunay, vtkIdList *boundaryBaricenterIds, vtkDataArray *normals, vtkIdList *seedIds)
void AppendEndPoints (vtkPoints *endPointPairs)
void ResampleCenterlines ()
void ReverseCenterlines ()

Protected Attributes

vtkIdList * SourceSeedIds
vtkIdList * TargetSeedIds
vtkIdList * CapCenterIds
vtkUnstructuredGrid * DelaunayTessellation
vtkPolyData * VoronoiDiagram
vtkIdList * PoleIds
char * RadiusArrayName
char * CostFunction
char * EikonalSolutionArrayName
char * EdgeArrayName
char * EdgePCoordArrayName
char * CostFunctionArrayName
int FlipNormals
int SimplifyVoronoi
int AppendEndPointsToCenterlines
int CenterlineResampling
double ResamplingStepLength
int GenerateVoronoiDiagram
int StopFastMarchingOnReachingTarget
int GenerateDelaunayTessellation
double DelaunayTolerance

Detailed Description

Compute centerlines from surface.

Computes centerlines (with a maximum inscribed sphere radius at each point) between a set of source and target boundary points on a closed surface, using the Voronoi-diagram-based method of Antiga & Steinman: the surface is first Delaunay-tessellated (unless a precomputed DelaunayTessellation is supplied), then its Voronoi diagram is extracted – the Voronoi diagram of points on a tubular surface approximates its medial axis, with the distance to the surface giving the local maximum inscribed sphere radius. A single-source shortest-path search (Fast Marching / Dijkstra-like propagation, weighted by CostFunction, typically favoring paths through the widest part of the vessel) is then run on the Voronoi diagram from the source seed(s) to each target seed, and the resulting paths become the output centerlines. This is the filter behind the vmtkcenterlines pype script, the foundation of most other centerline-based analysis in vmtk.

See also
vtkvmtkVoronoiDiagram3D, vtkvmtkNonManifoldFastMarching, vtkvmtkSteepestDescentLineTracer

Definition at line 51 of file vtkvmtkPolyDataCenterlines.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataCenterlines::Superclass

Definition at line 54 of file vtkvmtkPolyDataCenterlines.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataCenterlines()

vtkvmtkPolyDataCenterlines::vtkvmtkPolyDataCenterlines ( )
protected

Definition at line 50 of file vtkvmtkPolyDataCenterlines.cxx.

51{
52 this->SourceSeedIds = NULL;
53 this->TargetSeedIds = NULL;
54 this->CapCenterIds = NULL;
55
56 this->RadiusArrayName = NULL;
57 this->CostFunction = new char[16];
58 strcpy(this->CostFunction,"1/R");
59
60 this->CostFunctionArrayName = new char[256];
61 strcpy(this->CostFunctionArrayName,"CostFunctionArray");
62
63 this->EikonalSolutionArrayName = new char[256];
64 strcpy(this->EikonalSolutionArrayName,"EikonalSolutionArray");
65
66 this->EdgeArrayName = new char[256];
67 strcpy(this->EdgeArrayName,"EdgeArray");
68
69 this->EdgePCoordArrayName = new char[256];
70 strcpy(this->EdgePCoordArrayName,"EdgePCoordArray");
71
72 this->FlipNormals = 0;
73 this->SimplifyVoronoi = 0;
74 this->CenterlineResampling = 0;
76
77 this->ResamplingStepLength = 1.0;
78
80
81 this->DelaunayTessellation = NULL;
82 this->DelaunayTolerance = 1E-3;
83
84 this->GenerateVoronoiDiagram = 1;
86 this->VoronoiDiagram = NULL;
87 this->PoleIds = NULL;
88}

◆ ~vtkvmtkPolyDataCenterlines()

vtkvmtkPolyDataCenterlines::~vtkvmtkPolyDataCenterlines ( )
protected

Definition at line 90 of file vtkvmtkPolyDataCenterlines.cxx.

91{
92 if (this->SourceSeedIds)
93 {
94 this->SourceSeedIds->Delete();
95 this->SourceSeedIds = NULL;
96 }
97
98 if (this->TargetSeedIds)
99 {
100 this->TargetSeedIds->Delete();
101 this->TargetSeedIds = NULL;
102 }
103
104 if (this->CapCenterIds)
105 {
106 this->CapCenterIds->Delete();
107 this->CapCenterIds = NULL;
108 }
109
110 if (this->CostFunction)
111 {
112 delete[] this->CostFunction;
113 this->CostFunction = NULL;
114 }
115
116 if (this->CostFunctionArrayName)
117 {
118 delete[] this->CostFunctionArrayName;
119 this->CostFunctionArrayName = NULL;
120 }
121
122 if (this->EikonalSolutionArrayName)
123 {
124 delete[] this->EikonalSolutionArrayName;
125 this->EikonalSolutionArrayName = NULL;
126 }
127
128 if (this->EdgeArrayName)
129 {
130 delete[] this->EdgeArrayName;
131 this->EdgeArrayName = NULL;
132 }
133
134 if (this->EdgePCoordArrayName)
135 {
136 delete[] this->EdgePCoordArrayName;
137 this->EdgePCoordArrayName = NULL;
138 }
139
140 if (this->RadiusArrayName)
141 {
142 delete[] this->RadiusArrayName;
143 this->RadiusArrayName = NULL;
144 }
145
146 if (this->DelaunayTessellation)
147 {
148 this->DelaunayTessellation->Delete();
149 this->DelaunayTessellation = NULL;
150 }
151
152 if (this->VoronoiDiagram)
153 {
154 this->VoronoiDiagram->Delete();
155 this->VoronoiDiagram = NULL;
156 }
157
158 if (this->PoleIds)
159 {
160 this->PoleIds->Delete();
161 this->PoleIds = NULL;
162 }
163
164}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataCenterlines::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataCenterlines * vtkvmtkPolyDataCenterlines::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 708 of file vtkvmtkPolyDataCenterlines.cxx.

709{
710 this->Superclass::PrintSelf(os,indent);
711}

◆ New()

vtkvmtkPolyDataCenterlines * vtkvmtkPolyDataCenterlines::New ( )
static

◆ SetSourceSeedIds()

virtual void vtkvmtkPolyDataCenterlines::SetSourceSeedIds ( vtkIdList * )
virtual

Set/Get the ids, on the input surface, of the point(s) from which the centerline search starts. Required input.

◆ GetSourceSeedIds()

virtual vtkIdList * vtkvmtkPolyDataCenterlines::GetSourceSeedIds ( )
virtual

Set/Get the ids, on the input surface, of the point(s) from which the centerline search starts. Required input.

◆ SetTargetSeedIds()

virtual void vtkvmtkPolyDataCenterlines::SetTargetSeedIds ( vtkIdList * )
virtual

Set/Get the ids, on the input surface, of the point(s) that a centerline is computed to from each source seed. Required input.

◆ GetTargetSeedIds()

virtual vtkIdList * vtkvmtkPolyDataCenterlines::GetTargetSeedIds ( )
virtual

Set/Get the ids, on the input surface, of the point(s) that a centerline is computed to from each source seed. Required input.

◆ SetCapCenterIds()

virtual void vtkvmtkPolyDataCenterlines::SetCapCenterIds ( vtkIdList * )
virtual

Set/Get the ids of cap-center points (e.g. as produced by vtkvmtkCapPolyData) on the input surface. When set, these points are used to seed the Voronoi diagram computation more robustly near capped boundaries.

◆ GetCapCenterIds()

virtual vtkIdList * vtkvmtkPolyDataCenterlines::GetCapCenterIds ( )
virtual

Set/Get the ids of cap-center points (e.g. as produced by vtkvmtkCapPolyData) on the input surface. When set, these points are used to seed the Voronoi diagram computation more robustly near capped boundaries.

◆ SetDelaunayTessellation()

virtual void vtkvmtkPolyDataCenterlines::SetDelaunayTessellation ( vtkUnstructuredGrid * )
virtual

Set/Get a precomputed Delaunay tessellation of the input surface to use instead of computing one internally (see GenerateDelaunayTessellation). After Update(), also usable to retrieve the (possibly internally computed) tessellation.

◆ GetDelaunayTessellation()

virtual vtkUnstructuredGrid * vtkvmtkPolyDataCenterlines::GetDelaunayTessellation ( )
virtual

Set/Get a precomputed Delaunay tessellation of the input surface to use instead of computing one internally (see GenerateDelaunayTessellation). After Update(), also usable to retrieve the (possibly internally computed) tessellation.

◆ SetVoronoiDiagram()

virtual void vtkvmtkPolyDataCenterlines::SetVoronoiDiagram ( vtkPolyData * )
virtual

Set/Get a precomputed Voronoi diagram of the input surface to use instead of computing one internally (see GenerateVoronoiDiagram; also requires PoleIds to be set). After Update(), also usable to retrieve the (possibly internally computed) diagram.

◆ GetVoronoiDiagram()

virtual vtkPolyData * vtkvmtkPolyDataCenterlines::GetVoronoiDiagram ( )
virtual

Set/Get a precomputed Voronoi diagram of the input surface to use instead of computing one internally (see GenerateVoronoiDiagram; also requires PoleIds to be set). After Update(), also usable to retrieve the (possibly internally computed) diagram.

◆ SetPoleIds()

virtual void vtkvmtkPolyDataCenterlines::SetPoleIds ( vtkIdList * )
virtual

Set/Get the "pole" ids of the Delaunay tessellation (points of the tessellation that are vertices of the Voronoi diagram); required together with VoronoiDiagram when supplying a precomputed diagram. After Update(), also usable to retrieve the internally computed pole ids.

◆ GetPoleIds()

virtual vtkIdList * vtkvmtkPolyDataCenterlines::GetPoleIds ( )
virtual

Set/Get the "pole" ids of the Delaunay tessellation (points of the tessellation that are vertices of the Voronoi diagram); required together with VoronoiDiagram when supplying a precomputed diagram. After Update(), also usable to retrieve the internally computed pole ids.

◆ SetRadiusArrayName()

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

Set/Get the name of the point data array where the maximum inscribed sphere radius is stored, on both the output centerlines and the Voronoi diagram. Default: "MaximumInscribedSphereRadius".

◆ GetRadiusArrayName()

virtual char * vtkvmtkPolyDataCenterlines::GetRadiusArrayName ( )
virtual

Set/Get the name of the point data array where the maximum inscribed sphere radius is stored, on both the output centerlines and the Voronoi diagram. Default: "MaximumInscribedSphereRadius".

◆ SetCostFunction()

virtual void vtkvmtkPolyDataCenterlines::SetCostFunction ( const char * )
virtual

Set/Get the cost function used to weight the shortest-path search on the Voronoi diagram, expressed as a string in terms of R (the local maximum inscribed sphere radius); e.g. the default "1/R" biases the path towards the widest part of the vessel (favoring centeredness), a larger exponent such as "1/R2" biases it even more strongly, and "1" reduces to a plain geodesic (shortest Euclidean path).

◆ GetCostFunction()

virtual char * vtkvmtkPolyDataCenterlines::GetCostFunction ( )
virtual

Set/Get the cost function used to weight the shortest-path search on the Voronoi diagram, expressed as a string in terms of R (the local maximum inscribed sphere radius); e.g. the default "1/R" biases the path towards the widest part of the vessel (favoring centeredness), a larger exponent such as "1/R2" biases it even more strongly, and "1" reduces to a plain geodesic (shortest Euclidean path).

◆ SetEikonalSolutionArrayName()

virtual void vtkvmtkPolyDataCenterlines::SetEikonalSolutionArrayName ( const char * )
virtual

Set/Get the name of the point data array of the Voronoi diagram where the Eikonal (shortest-path travel time) solution is stored. Commonly named "EikonalSolution".

◆ GetEikonalSolutionArrayName()

virtual char * vtkvmtkPolyDataCenterlines::GetEikonalSolutionArrayName ( )
virtual

Set/Get the name of the point data array of the Voronoi diagram where the Eikonal (shortest-path travel time) solution is stored. Commonly named "EikonalSolution".

◆ SetEdgeArrayName()

virtual void vtkvmtkPolyDataCenterlines::SetEdgeArrayName ( const char * )
virtual

Set/Get the name of the point data array of the Voronoi diagram used internally to track, for each point, the edge of the shortest-path tree it was reached through. Commonly named "EdgeArray".

◆ GetEdgeArrayName()

virtual char * vtkvmtkPolyDataCenterlines::GetEdgeArrayName ( )
virtual

Set/Get the name of the point data array of the Voronoi diagram used internally to track, for each point, the edge of the shortest-path tree it was reached through. Commonly named "EdgeArray".

◆ SetEdgePCoordArrayName()

virtual void vtkvmtkPolyDataCenterlines::SetEdgePCoordArrayName ( const char * )
virtual

Set/Get the name of the point data array of the Voronoi diagram used internally to store the parametric coordinate along the shortest-path tree edge (see EdgeArrayName) at which each point was reached. Commonly named "EdgePCoordArray".

◆ GetEdgePCoordArrayName()

virtual char * vtkvmtkPolyDataCenterlines::GetEdgePCoordArrayName ( )
virtual

Set/Get the name of the point data array of the Voronoi diagram used internally to store the parametric coordinate along the shortest-path tree edge (see EdgeArrayName) at which each point was reached. Commonly named "EdgePCoordArray".

◆ SetCostFunctionArrayName()

virtual void vtkvmtkPolyDataCenterlines::SetCostFunctionArrayName ( const char * )
virtual

Set/Get the name of the point data array of the Voronoi diagram where the evaluated CostFunction value is stored at each point. Commonly named "CostFunctionArray".

◆ GetCostFunctionArrayName()

virtual char * vtkvmtkPolyDataCenterlines::GetCostFunctionArrayName ( )
virtual

Set/Get the name of the point data array of the Voronoi diagram where the evaluated CostFunction value is stored at each point. Commonly named "CostFunctionArray".

◆ SetFlipNormals()

virtual void vtkvmtkPolyDataCenterlines::SetFlipNormals ( int )
virtual

Toggle flipping the orientation of the surface normals used when computing the Voronoi diagram. Turn on if the resulting centerlines look degenerate/incorrect, which can indicate the input surface has inward-pointing normals. Default: off.

◆ GetFlipNormals()

virtual int vtkvmtkPolyDataCenterlines::GetFlipNormals ( )
virtual

Toggle flipping the orientation of the surface normals used when computing the Voronoi diagram. Turn on if the resulting centerlines look degenerate/incorrect, which can indicate the input surface has inward-pointing normals. Default: off.

◆ FlipNormalsOn()

virtual void vtkvmtkPolyDataCenterlines::FlipNormalsOn ( )
virtual

Toggle flipping the orientation of the surface normals used when computing the Voronoi diagram. Turn on if the resulting centerlines look degenerate/incorrect, which can indicate the input surface has inward-pointing normals. Default: off.

◆ FlipNormalsOff()

virtual void vtkvmtkPolyDataCenterlines::FlipNormalsOff ( )
virtual

Toggle flipping the orientation of the surface normals used when computing the Voronoi diagram. Turn on if the resulting centerlines look degenerate/incorrect, which can indicate the input surface has inward-pointing normals. Default: off.

◆ SetSimplifyVoronoi()

virtual void vtkvmtkPolyDataCenterlines::SetSimplifyVoronoi ( int )
virtual

Toggle simplifying the Voronoi diagram before the shortest-path search, discarding points/cells that don't contribute to the medial axis (see vtkvmtkSimplifyVoronoiDiagram). Speeds up processing of large models at a small accuracy cost. Default: off.

◆ GetSimplifyVoronoi()

virtual int vtkvmtkPolyDataCenterlines::GetSimplifyVoronoi ( )
virtual

Toggle simplifying the Voronoi diagram before the shortest-path search, discarding points/cells that don't contribute to the medial axis (see vtkvmtkSimplifyVoronoiDiagram). Speeds up processing of large models at a small accuracy cost. Default: off.

◆ SimplifyVoronoiOn()

virtual void vtkvmtkPolyDataCenterlines::SimplifyVoronoiOn ( )
virtual

Toggle simplifying the Voronoi diagram before the shortest-path search, discarding points/cells that don't contribute to the medial axis (see vtkvmtkSimplifyVoronoiDiagram). Speeds up processing of large models at a small accuracy cost. Default: off.

◆ SimplifyVoronoiOff()

virtual void vtkvmtkPolyDataCenterlines::SimplifyVoronoiOff ( )
virtual

Toggle simplifying the Voronoi diagram before the shortest-path search, discarding points/cells that don't contribute to the medial axis (see vtkvmtkSimplifyVoronoiDiagram). Speeds up processing of large models at a small accuracy cost. Default: off.

◆ SetCenterlineResampling()

virtual void vtkvmtkPolyDataCenterlines::SetCenterlineResampling ( int )
virtual

Toggle resampling the output centerlines to a uniform point spacing of ResamplingStepLength. Default: off.

◆ GetCenterlineResampling()

virtual int vtkvmtkPolyDataCenterlines::GetCenterlineResampling ( )
virtual

Toggle resampling the output centerlines to a uniform point spacing of ResamplingStepLength. Default: off.

◆ CenterlineResamplingOn()

virtual void vtkvmtkPolyDataCenterlines::CenterlineResamplingOn ( )
virtual

Toggle resampling the output centerlines to a uniform point spacing of ResamplingStepLength. Default: off.

◆ CenterlineResamplingOff()

virtual void vtkvmtkPolyDataCenterlines::CenterlineResamplingOff ( )
virtual

Toggle resampling the output centerlines to a uniform point spacing of ResamplingStepLength. Default: off.

◆ SetResamplingStepLength()

virtual void vtkvmtkPolyDataCenterlines::SetResamplingStepLength ( double )
virtual

Set/Get the point spacing used to resample the output centerlines when CenterlineResampling is on. Default: 1.0.

◆ GetResamplingStepLength()

virtual double vtkvmtkPolyDataCenterlines::GetResamplingStepLength ( )
virtual

Set/Get the point spacing used to resample the output centerlines when CenterlineResampling is on. Default: 1.0.

◆ SetAppendEndPointsToCenterlines()

virtual void vtkvmtkPolyDataCenterlines::SetAppendEndPointsToCenterlines ( int )
virtual

Toggle appending a short straight segment at each free end of the output centerlines, from the seed point on the surface to the corresponding source/target seed's cap center (requires CapCenterIds to be set). Default: off.

◆ GetAppendEndPointsToCenterlines()

virtual int vtkvmtkPolyDataCenterlines::GetAppendEndPointsToCenterlines ( )
virtual

Toggle appending a short straight segment at each free end of the output centerlines, from the seed point on the surface to the corresponding source/target seed's cap center (requires CapCenterIds to be set). Default: off.

◆ AppendEndPointsToCenterlinesOn()

virtual void vtkvmtkPolyDataCenterlines::AppendEndPointsToCenterlinesOn ( )
virtual

Toggle appending a short straight segment at each free end of the output centerlines, from the seed point on the surface to the corresponding source/target seed's cap center (requires CapCenterIds to be set). Default: off.

◆ AppendEndPointsToCenterlinesOff()

virtual void vtkvmtkPolyDataCenterlines::AppendEndPointsToCenterlinesOff ( )
virtual

Toggle appending a short straight segment at each free end of the output centerlines, from the seed point on the surface to the corresponding source/target seed's cap center (requires CapCenterIds to be set). Default: off.

◆ SetGenerateDelaunayTessellation()

virtual void vtkvmtkPolyDataCenterlines::SetGenerateDelaunayTessellation ( int )
virtual

Toggle computing the Delaunay tessellation internally from the input surface. Turn off and supply DelaunayTessellation directly to reuse a tessellation computed elsewhere (e.g. to speed up repeated centerline extractions on the same surface). Default: on.

◆ GetGenerateDelaunayTessellation()

virtual int vtkvmtkPolyDataCenterlines::GetGenerateDelaunayTessellation ( )
virtual

Toggle computing the Delaunay tessellation internally from the input surface. Turn off and supply DelaunayTessellation directly to reuse a tessellation computed elsewhere (e.g. to speed up repeated centerline extractions on the same surface). Default: on.

◆ GenerateDelaunayTessellationOn()

virtual void vtkvmtkPolyDataCenterlines::GenerateDelaunayTessellationOn ( )
virtual

Toggle computing the Delaunay tessellation internally from the input surface. Turn off and supply DelaunayTessellation directly to reuse a tessellation computed elsewhere (e.g. to speed up repeated centerline extractions on the same surface). Default: on.

◆ GenerateDelaunayTessellationOff()

virtual void vtkvmtkPolyDataCenterlines::GenerateDelaunayTessellationOff ( )
virtual

Toggle computing the Delaunay tessellation internally from the input surface. Turn off and supply DelaunayTessellation directly to reuse a tessellation computed elsewhere (e.g. to speed up repeated centerline extractions on the same surface). Default: on.

◆ SetGenerateVoronoiDiagram()

virtual void vtkvmtkPolyDataCenterlines::SetGenerateVoronoiDiagram ( int )
virtual

Toggle computing the Voronoi diagram internally from the Delaunay tessellation. Turn off and supply VoronoiDiagram and PoleIds directly to reuse a diagram computed elsewhere. Default: on.

◆ GetGenerateVoronoiDiagram()

virtual int vtkvmtkPolyDataCenterlines::GetGenerateVoronoiDiagram ( )
virtual

Toggle computing the Voronoi diagram internally from the Delaunay tessellation. Turn off and supply VoronoiDiagram and PoleIds directly to reuse a diagram computed elsewhere. Default: on.

◆ GenerateVoronoiDiagramOn()

virtual void vtkvmtkPolyDataCenterlines::GenerateVoronoiDiagramOn ( )
virtual

Toggle computing the Voronoi diagram internally from the Delaunay tessellation. Turn off and supply VoronoiDiagram and PoleIds directly to reuse a diagram computed elsewhere. Default: on.

◆ GenerateVoronoiDiagramOff()

virtual void vtkvmtkPolyDataCenterlines::GenerateVoronoiDiagramOff ( )
virtual

Toggle computing the Voronoi diagram internally from the Delaunay tessellation. Turn off and supply VoronoiDiagram and PoleIds directly to reuse a diagram computed elsewhere. Default: on.

◆ SetStopFastMarchingOnReachingTarget()

virtual void vtkvmtkPolyDataCenterlines::SetStopFastMarchingOnReachingTarget ( int )
virtual

Toggle stopping the shortest-path propagation as soon as all target seeds have been reached, rather than continuing until the whole Voronoi diagram is visited. Speeds up processing when only a few targets are needed out of a large model. Default: off.

◆ GetStopFastMarchingOnReachingTarget()

virtual int vtkvmtkPolyDataCenterlines::GetStopFastMarchingOnReachingTarget ( )
virtual

Toggle stopping the shortest-path propagation as soon as all target seeds have been reached, rather than continuing until the whole Voronoi diagram is visited. Speeds up processing when only a few targets are needed out of a large model. Default: off.

◆ StopFastMarchingOnReachingTargetOn()

virtual void vtkvmtkPolyDataCenterlines::StopFastMarchingOnReachingTargetOn ( )
virtual

Toggle stopping the shortest-path propagation as soon as all target seeds have been reached, rather than continuing until the whole Voronoi diagram is visited. Speeds up processing when only a few targets are needed out of a large model. Default: off.

◆ StopFastMarchingOnReachingTargetOff()

virtual void vtkvmtkPolyDataCenterlines::StopFastMarchingOnReachingTargetOff ( )
virtual

Toggle stopping the shortest-path propagation as soon as all target seeds have been reached, rather than continuing until the whole Voronoi diagram is visited. Speeds up processing when only a few targets are needed out of a large model. Default: off.

◆ SetDelaunayTolerance()

virtual void vtkvmtkPolyDataCenterlines::SetDelaunayTolerance ( double )
virtual

Set/Get the numerical tolerance used when computing the Delaunay tessellation (points closer together than this are merged). Default: 1E-3.

◆ GetDelaunayTolerance()

virtual double vtkvmtkPolyDataCenterlines::GetDelaunayTolerance ( )
virtual

Set/Get the numerical tolerance used when computing the Delaunay tessellation (points closer together than this are merged). Default: 1E-3.

◆ RequestData()

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

Definition at line 166 of file vtkvmtkPolyDataCenterlines.cxx.

170{
171 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
172 vtkInformation *outInfo = outputVector->GetInformationObject(0);
173
174 vtkPolyData *input = vtkPolyData::SafeDownCast(
175 inInfo->Get(vtkDataObject::DATA_OBJECT()));
176 vtkPolyData *output = vtkPolyData::SafeDownCast(
177 outInfo->Get(vtkDataObject::DATA_OBJECT()));
178
179 if (!this->SourceSeedIds)
180 {
181 vtkErrorMacro(<< "No SourceSeedIds set.");
182 return 1;
183 }
184
185 if (!this->TargetSeedIds)
186 {
187 vtkErrorMacro(<< "No TargetSeedIds set.");
188 return 1;
189 }
190
191 if (!this->RadiusArrayName)
192 {
193 vtkErrorMacro(<< "No RadiusArrayName set.");
194 return 1;
195 }
196
198 {
199 vtkErrorMacro(<< "GenerateDelaunayTessellation is off but a DelaunayTessellation has not been set.");
200 return 1;
201 }
202
203 if (!this->GenerateVoronoiDiagram && !this->VoronoiDiagram)
204 {
205 vtkErrorMacro(<< "GenerateVoronoiDiagram is off but a VoronoiDiagram has not been set.");
206 return 1;
207 }
208
209 if (!this->GenerateVoronoiDiagram && !this->PoleIds)
210 {
211 vtkErrorMacro(<< "GenerateVoronoiDiagram is off but Voronoi PoleIds have not been set.");
212 return 1;
213 }
214
215 // Since VTK 9.4, vtkPolyDataNormals passes pre-existing normals through
216 // unchanged instead of recomputing them, so inherited input normals would
217 // bypass AutoOrientNormals and feed arbitrarily oriented normals to the
218 // internal tetrahedra classification below, breaking the Voronoi diagram
219 // and centerline backtracing. Strip them so outward-oriented normals are
220 // always recomputed.
221 vtkPolyData* inputWithoutNormals = vtkPolyData::New();
222 inputWithoutNormals->ShallowCopy(input);
223 inputWithoutNormals->GetPointData()->SetNormals(NULL);
224 inputWithoutNormals->GetCellData()->SetNormals(NULL);
225
226 vtkPolyDataNormals* surfaceNormals = vtkPolyDataNormals::New();
227 surfaceNormals->SetInputData(inputWithoutNormals);
228 inputWithoutNormals->Delete();
229 surfaceNormals->SplittingOff();
230 surfaceNormals->AutoOrientNormalsOn();
231 surfaceNormals->SetFlipNormals(this->FlipNormals);
232 surfaceNormals->ComputePointNormalsOn();
233 surfaceNormals->ConsistencyOn();
234 surfaceNormals->Update();
235
237 {
238 vtkDelaunay3D* delaunayTessellator = vtkDelaunay3D::New();
239 delaunayTessellator->CreateDefaultLocator();
240 delaunayTessellator->SetInputConnection(surfaceNormals->GetOutputPort());
241 delaunayTessellator->SetTolerance(this->DelaunayTolerance);
242 delaunayTessellator->Update();
243
244 vtkUnstructuredGrid* delaunay = delaunayTessellator->GetOutput();
245 delaunay->GetPointData()->AddArray(surfaceNormals->GetOutput()->GetPointData()->GetNormals());
246
247 vtkvmtkInternalTetrahedraExtractor* internalTetrahedraExtractor = vtkvmtkInternalTetrahedraExtractor::New();
248 internalTetrahedraExtractor->SetInputConnection(delaunayTessellator->GetOutputPort());
249 if (!surfaceNormals
250 || !surfaceNormals->GetOutput()
251 || !surfaceNormals->GetOutput()->GetPointData()
252 || !surfaceNormals->GetOutput()->GetPointData()->GetNormals()
253 || !surfaceNormals->GetOutput()->GetPointData()->GetNormals()->GetName())
254 {
255 vtkErrorMacro(<< "Centerline extraction failed: could not compute surface normals");
256 return 1;
257 }
258
259 internalTetrahedraExtractor->SetOutwardNormalsArrayName(surfaceNormals->GetOutput()->GetPointData()->GetNormals()->GetName());
260
261 if (this->CapCenterIds)
262 {
263 internalTetrahedraExtractor->UseCapsOn();
264 internalTetrahedraExtractor->SetCapCenterIds(this->CapCenterIds);
265 }
266
267 internalTetrahedraExtractor->Update();
268
269 this->DelaunayTessellation = internalTetrahedraExtractor->GetOutput();
270 this->DelaunayTessellation->Register(this);
271
272 delaunayTessellator->Delete();
273 internalTetrahedraExtractor->Delete();
274 }
275
276 if (this->GenerateVoronoiDiagram)
277 {
278 vtkvmtkVoronoiDiagram3D* voronoiDiagramFilter = vtkvmtkVoronoiDiagram3D::New();
279 voronoiDiagramFilter->SetInputData(this->DelaunayTessellation);
280 voronoiDiagramFilter->SetRadiusArrayName(this->RadiusArrayName);
281 voronoiDiagramFilter->Update();
282
283 this->PoleIds = vtkIdList::New();
284 this->PoleIds->DeepCopy(voronoiDiagramFilter->GetPoleIds());
285
286 vtkPolyData* voronoiDiagram = voronoiDiagramFilter->GetOutput();
287
288 if (this->SimplifyVoronoi)
289 {
290 vtkvmtkSimplifyVoronoiDiagram* voronoiDiagramSimplifier = vtkvmtkSimplifyVoronoiDiagram::New();
291 voronoiDiagramSimplifier->SetInputConnection(voronoiDiagramFilter->GetOutputPort());
292 voronoiDiagramSimplifier->SetUnremovablePointIds(voronoiDiagramFilter->GetPoleIds());
293 voronoiDiagramSimplifier->Update();
294 voronoiDiagram = voronoiDiagramSimplifier->GetOutput();
295 voronoiDiagram->Register(this);
296 voronoiDiagramSimplifier->Delete();
297 }
298 this->VoronoiDiagram = vtkPolyData::New();
299 this->VoronoiDiagram->DeepCopy(voronoiDiagram);
300 voronoiDiagramFilter->Delete();
301 }
302
303 #if defined(__EMSCRIPTEN__)
304 vtkNew<vtkDoubleArray> array;
305 array->SetName(this->CostFunctionArrayName);
306 auto outputArray = dynamic_cast<vtkDoubleArray *>(
307 this->VoronoiDiagram->GetPointData()->GetArray(this->RadiusArrayName));
308
309 for (int i = 0; i < outputArray->GetNumberOfTuples(); i++)
310 {
311 array->InsertNextValue(1 / outputArray->GetValue(i));
312 }
313 this->VoronoiDiagram->GetPointData()->AddArray(array);
314 #else
315 vtkArrayCalculator *voronoiCostFunctionCalculator = vtkArrayCalculator::New();
316 voronoiCostFunctionCalculator->SetInputData(this->VoronoiDiagram);
317 voronoiCostFunctionCalculator->SetAttributeTypeToPointData();
318 voronoiCostFunctionCalculator->AddScalarVariable("R", this->RadiusArrayName, 0);
319 voronoiCostFunctionCalculator->SetFunction(this->CostFunction);
320 voronoiCostFunctionCalculator->SetResultArrayName(this->CostFunctionArrayName);
321 voronoiCostFunctionCalculator->Update();
322 #endif
323
324 vtkIdList* voronoiSourceSeedIds = vtkIdList::New();
325 vtkIdList* voronoiTargetSeedIds = vtkIdList::New();
326
327 vtkIdList* voronoiSeeds = vtkIdList::New();
328
329 int i;
330 if (this->CapCenterIds)
331 {
332 this->FindVoronoiSeeds(this->DelaunayTessellation,this->CapCenterIds,surfaceNormals->GetOutput()->GetPointData()->GetNormals(),voronoiSeeds);
333 for (i=0; i<this->SourceSeedIds->GetNumberOfIds(); i++)
334 {
335 voronoiSourceSeedIds->InsertNextId(voronoiSeeds->GetId(this->SourceSeedIds->GetId(i)));
336 }
337 for (i=0; i<this->TargetSeedIds->GetNumberOfIds(); i++)
338 {
339 voronoiTargetSeedIds->InsertNextId(voronoiSeeds->GetId(this->TargetSeedIds->GetId(i)));
340 }
341 }
342 else
343 {
344 for (i=0; i<this->SourceSeedIds->GetNumberOfIds(); i++)
345 {
346 voronoiSourceSeedIds->InsertNextId(this->PoleIds->GetId(this->SourceSeedIds->GetId(i)));
347 }
348 for (i=0; i<this->TargetSeedIds->GetNumberOfIds(); i++)
349 {
350 voronoiTargetSeedIds->InsertNextId(this->PoleIds->GetId(this->TargetSeedIds->GetId(i)));
351 }
352 }
353
354 vtkvmtkNonManifoldFastMarching* voronoiFastMarching = vtkvmtkNonManifoldFastMarching::New();
355 #if defined(__EMSCRIPTEN__)
356 voronoiFastMarching->SetInputData(this->VoronoiDiagram);
357 #else
358 voronoiFastMarching->SetInputConnection(voronoiCostFunctionCalculator->GetOutputPort());
359 #endif
360 voronoiFastMarching->SetCostFunctionArrayName(this->CostFunctionArrayName);
361 voronoiFastMarching->SetSolutionArrayName(this->EikonalSolutionArrayName);
363 {
364 voronoiFastMarching->SetStopSeedId(voronoiTargetSeedIds);
365 }
366 voronoiFastMarching->SeedsBoundaryConditionsOn();
367 voronoiFastMarching->SetSeeds(voronoiSourceSeedIds);
368 voronoiFastMarching->Update();
369
370 this->VoronoiDiagram->ShallowCopy(voronoiFastMarching->GetOutput());
371
372 vtkvmtkSteepestDescentLineTracer* centerlineBacktracing = vtkvmtkSteepestDescentLineTracer::New();
373 centerlineBacktracing->SetInputConnection(voronoiFastMarching->GetOutputPort());
374 centerlineBacktracing->SetDataArrayName(this->RadiusArrayName);
375 centerlineBacktracing->SetDescentArrayName(this->EikonalSolutionArrayName);
376 centerlineBacktracing->SetEdgeArrayName(this->EdgeArrayName);
377 centerlineBacktracing->SetEdgePCoordArrayName(this->EdgePCoordArrayName);
378 centerlineBacktracing->SetSeeds(voronoiTargetSeedIds);
379 centerlineBacktracing->MergePathsOff();
380 centerlineBacktracing->StopOnTargetsOn();
381 centerlineBacktracing->SetTargets(voronoiSourceSeedIds);
382 centerlineBacktracing->Update();
383
384 output->ShallowCopy(centerlineBacktracing->GetOutput());
385
386 vtkIdList* hitTargets = centerlineBacktracing->GetHitTargets();
387
388 vtkPoints* endPointPairs = vtkPoints::New();
389
390 const vtkIdType numTargetSeedIds = this->TargetSeedIds->GetNumberOfIds();
391 const vtkIdType numHitTargets = hitTargets->GetNumberOfIds();
392 if(numHitTargets == numTargetSeedIds) {
394 {
395 for (i=0; i<numTargetSeedIds; i++)
396 {
397 if (this->CapCenterIds)
398 {
399 vtkIdType endPointId1 = this->CapCenterIds->GetId(this->TargetSeedIds->GetId(i));
400 vtkIdType hitTargetPointId = hitTargets->GetId(i);
401 vtkIdType targetId = voronoiSourceSeedIds->IsId(hitTargetPointId);
402 vtkIdType endPointId2 = this->CapCenterIds->GetId(this->SourceSeedIds->GetId(targetId));
403 endPointPairs->InsertNextPoint(input->GetPoint(endPointId1));
404 endPointPairs->InsertNextPoint(input->GetPoint(endPointId2));
405 }
406 else
407 {
408 vtkIdType endPointId1 = this->TargetSeedIds->GetId(i);
409 vtkIdType hitTargetPointId = hitTargets->GetId(i);
410 vtkIdType targetId = voronoiSourceSeedIds->IsId(hitTargetPointId);
411 vtkIdType endPointId2 = this->SourceSeedIds->GetId(targetId);
412 endPointPairs->InsertNextPoint(input->GetPoint(endPointId1));
413 endPointPairs->InsertNextPoint(input->GetPoint(endPointId2));
414 }
415 }
416
417 this->AppendEndPoints(endPointPairs);
418 }
419 }
420
421 if (this->CenterlineResampling)
422 {
423 this->ResampleCenterlines();
424 }
425 this->ReverseCenterlines();
426
427 surfaceNormals->Delete();
428 #if !defined(__EMSCRIPTEN__)
429 voronoiCostFunctionCalculator->Delete();
430 #endif
431 voronoiSeeds->Delete();
432 voronoiSourceSeedIds->Delete();
433 voronoiTargetSeedIds->Delete();
434 voronoiFastMarching->Delete();
435 centerlineBacktracing->Delete();
436 endPointPairs->Delete();
437
438 return 1;
439}
static vtkvmtkInternalTetrahedraExtractor * New()
virtual void SetCapCenterIds(vtkIdList *)
virtual void SetOutwardNormalsArrayName(const char *)
virtual void SeedsBoundaryConditionsOn()
virtual void SetSeeds(vtkIdList *)
static vtkvmtkNonManifoldFastMarching * New()
virtual void SetStopSeedId(vtkIdList *)
virtual void SetCostFunctionArrayName(const char *)
virtual void SetSolutionArrayName(const char *)
virtual void SetDescentArrayName(const char *)
void AppendEndPoints(vtkPoints *endPointPairs)
void FindVoronoiSeeds(vtkUnstructuredGrid *delaunay, vtkIdList *boundaryBaricenterIds, vtkDataArray *normals, vtkIdList *seedIds)
static vtkvmtkSimplifyVoronoiDiagram * New()
virtual void SetUnremovablePointIds(vtkIdList *)
virtual void SetDataArrayName(const char *)
virtual void SetSeeds(vtkIdList *)
static vtkvmtkSteepestDescentLineTracer * New()
virtual vtkIdList * GetHitTargets()
virtual void SetTargets(vtkIdList *)
virtual void SetEdgeArrayName(const char *)
virtual void SetEdgePCoordArrayName(const char *)
static vtkvmtkVoronoiDiagram3D * New()
virtual void SetRadiusArrayName(const char *)
virtual vtkIdList * GetPoleIds()

◆ FindVoronoiSeeds()

void vtkvmtkPolyDataCenterlines::FindVoronoiSeeds ( vtkUnstructuredGrid * delaunay,
vtkIdList * boundaryBaricenterIds,
vtkDataArray * normals,
vtkIdList * seedIds )
protected

Definition at line 441 of file vtkvmtkPolyDataCenterlines.cxx.

442{
443 vtkIdType i, j;
444 vtkIdList *pointCells;
445 vtkIdType baricenterId;
446 double baricenter[3], normal[3];
447 double maxRadius, secondMaxRadius;
448 vtkTetra* tetra;
449 double p0[3], p1[3], p2[3], p3[3];
450 double circumcenter[3], circumradius, tetraRadius;
451 double referenceVector[3];
452 double pole[3], poleVector[3], secondPole[3], secondPoleVector[3];
453 pole[0] = pole[1] = pole[2] = 0.0;
454 vtkIdType maxRadiusCellId, secondMaxRadiusCellId;
455
456 pointCells = vtkIdList::New();
457
458 for (i=0; i<boundaryBaricenterIds->GetNumberOfIds(); i++)
459 {
460 baricenterId = boundaryBaricenterIds->GetId(i);
461 delaunay->GetPoint(baricenterId,baricenter);
462 normals->GetTuple(baricenterId,normal);
463 pointCells->Initialize();
464 delaunay->GetPointCells(baricenterId,pointCells);
465 maxRadius = 0.0;
466 maxRadiusCellId = -1;
467 secondMaxRadiusCellId = -1;
468
469 for (j=0; j<pointCells->GetNumberOfIds(); j++)
470 {
471 tetra = vtkTetra::SafeDownCast(delaunay->GetCell(pointCells->GetId(j)));
472 tetra->GetPoints()->GetPoint(0,p0);
473 tetra->GetPoints()->GetPoint(1,p1);
474 tetra->GetPoints()->GetPoint(2,p2);
475 tetra->GetPoints()->GetPoint(3,p3);
476
477 circumradius = vtkTetra::Circumsphere(p0,p1,p2,p3,circumcenter);
478 tetraRadius = sqrt(circumradius);
479
480 if (tetraRadius - maxRadius > VTK_VMTK_DOUBLE_TOL)
481 {
482 maxRadius = tetraRadius;
483 maxRadiusCellId = pointCells->GetId(j);
484 pole[0] = circumcenter[0];
485 pole[1] = circumcenter[1];
486 pole[2] = circumcenter[2];
487 }
488 }
489
490 poleVector[0] = pole[0] - baricenter[0];
491 poleVector[1] = pole[1] - baricenter[1];
492 poleVector[2] = pole[2] - baricenter[2];
493
494 secondMaxRadius = 0.0;
495
496 for (j=0; j<pointCells->GetNumberOfIds(); j++)
497 {
498 tetra = vtkTetra::SafeDownCast(delaunay->GetCell(pointCells->GetId(j)));
499 tetra->GetPoints()->GetPoint(0,p0);
500 tetra->GetPoints()->GetPoint(1,p1);
501 tetra->GetPoints()->GetPoint(2,p2);
502 tetra->GetPoints()->GetPoint(3,p3);
503
504 circumradius = vtkTetra::Circumsphere(p0,p1,p2,p3,circumcenter);
505 tetraRadius = sqrt(circumradius);
506
507 referenceVector[0] = circumcenter[0] - baricenter[0];
508 referenceVector[1] = circumcenter[1] - baricenter[1];
509 referenceVector[2] = circumcenter[2] - baricenter[2];
510
511 if ((tetraRadius - secondMaxRadius > VTK_VMTK_DOUBLE_TOL) && (vtkMath::Dot(poleVector,referenceVector) < VTK_VMTK_DOUBLE_TOL))
512 {
513 secondMaxRadius = tetraRadius;
514 secondMaxRadiusCellId = pointCells->GetId(j);
515 secondPole[0] = circumcenter[0];
516 secondPole[1] = circumcenter[1];
517 secondPole[2] = circumcenter[2];
518 }
519 }
520
521 secondPoleVector[0] = secondPole[0] - baricenter[0];
522 secondPoleVector[1] = secondPole[1] - baricenter[1];
523 secondPoleVector[2] = secondPole[2] - baricenter[2];
524
525 if (vtkMath::Dot(poleVector,normal) < VTK_VMTK_DOUBLE_TOL)
526 {
527 seedIds->InsertNextId(maxRadiusCellId);
528 }
529 else
530 {
531 seedIds->InsertNextId(secondMaxRadiusCellId);
532 }
533 }
534
535 pointCells->Delete();
536}
#define VTK_VMTK_DOUBLE_TOL

◆ AppendEndPoints()

void vtkvmtkPolyDataCenterlines::AppendEndPoints ( vtkPoints * endPointPairs)
protected

Definition at line 538 of file vtkvmtkPolyDataCenterlines.cxx.

539{
540 vtkIdType endPointId1, endPointId2;
541 vtkPolyData* output = this->GetOutput();
542 vtkPolyData* completeCenterlines = vtkPolyData::New();
543 vtkPoints* completeCenterlinesPoints = vtkPoints::New();
544 vtkCellArray* completeCenterlinesCellArray = vtkCellArray::New();
545 vtkDoubleArray* completeCenterlinesRadiusArray = vtkDoubleArray::New();
546 completeCenterlinesRadiusArray->SetName(this->RadiusArrayName);
547 vtkIdList* completeCell = vtkIdList::New();
548
549 vtkDoubleArray* centerlinesRadiusArray = vtkDoubleArray::SafeDownCast(output->GetPointData()->GetArray(this->RadiusArrayName));
550
551 completeCenterlinesPoints->DeepCopy(output->GetPoints());
552 completeCenterlinesRadiusArray->DeepCopy(centerlinesRadiusArray);
553
554 for (int k=0; k<output->GetNumberOfCells(); k++)
555 {
556 vtkCell* cell = output->GetCell(k);
557
558 endPointId1 = completeCenterlinesPoints->InsertNextPoint(endPointPairs->GetPoint(2*k));
559 endPointId2 = completeCenterlinesPoints->InsertNextPoint(endPointPairs->GetPoint(2*k+1));
560
561 completeCell->Initialize();
562 completeCell->SetNumberOfIds(cell->GetNumberOfPoints()+2);
563
564 completeCell->SetId(0,endPointId1);
565
566 for (int i=0; i<cell->GetNumberOfPoints(); i++)
567 {
568 completeCell->SetId(i+1,cell->GetPointId(i));
569 }
570 completeCell->SetId(cell->GetNumberOfPoints()+1,endPointId2);
571
572 completeCenterlinesCellArray->InsertNextCell(completeCell);
573
574 completeCenterlinesRadiusArray->InsertNextValue(centerlinesRadiusArray->GetValue(cell->GetPointId(0)));
575 completeCenterlinesRadiusArray->InsertNextValue(centerlinesRadiusArray->GetValue(cell->GetPointId(cell->GetNumberOfPoints()-1)));
576 }
577
578 completeCenterlines->SetPoints(completeCenterlinesPoints);
579 completeCenterlines->SetLines(completeCenterlinesCellArray);
580 completeCenterlines->GetPointData()->AddArray(completeCenterlinesRadiusArray);
581
582 output->ShallowCopy(completeCenterlines);
583
584 completeCell->Delete();
585 completeCenterlines->Delete();
586 completeCenterlinesPoints->Delete();
587 completeCenterlinesCellArray->Delete();
588 completeCenterlinesRadiusArray->Delete();
589}

◆ ResampleCenterlines()

void vtkvmtkPolyDataCenterlines::ResampleCenterlines ( )
protected

Definition at line 591 of file vtkvmtkPolyDataCenterlines.cxx.

592{
593 vtkPolyData* output = this->GetOutput();
594 vtkPolyData* resampledCenterlines = vtkPolyData::New();
595 vtkPoints* resampledCenterlinesPoints = vtkPoints::New();
596 vtkCellArray* resampledCenterlinesCellArray = vtkCellArray::New();
597 vtkDoubleArray* resampledCenterlinesRadiusArray = vtkDoubleArray::New();
598 resampledCenterlinesRadiusArray->SetName(this->RadiusArrayName);
599 vtkIdList* resampledCell = vtkIdList::New();
600
601 vtkDoubleArray* centerlinesRadiusArray = vtkDoubleArray::SafeDownCast(output->GetPointData()->GetArray(this->RadiusArrayName));
602
603 for (int k=0; k<output->GetNumberOfCells(); k++)
604 {
605 vtkCell* cell = output->GetCell(k);
606
607 resampledCell->Initialize();
608
609 vtkIdType id = resampledCenterlinesPoints->InsertNextPoint(cell->GetPoints()->GetPoint(0));
610 resampledCell->InsertNextId(id);
611 resampledCenterlinesRadiusArray->InsertNextValue(centerlinesRadiusArray->GetValue(cell->GetPointId(0)));
612
613 double point0[3], point1[3], point[3];
614 double abscissa, lineAbscissa, lineLength, stepAbscissa;
615
616 abscissa = 0.0;
617 lineAbscissa = 0.0;
618 lineLength = 0.0;
619 stepAbscissa = 0.0;
620
621 for (int i=0; i<cell->GetNumberOfPoints()-1; i++)
622 {
623 cell->GetPoints()->GetPoint(i,point0);
624 cell->GetPoints()->GetPoint(i+1,point1);
625
626 double scalar0 = centerlinesRadiusArray->GetValue(cell->GetPointId(i));
627 double scalar1 = centerlinesRadiusArray->GetValue(cell->GetPointId(i+1));
628
629 double length = sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
630
631 if (length < this->ResamplingStepLength - stepAbscissa)
632 {
633 stepAbscissa = stepAbscissa + length;
634 continue;
635 }
636
637 double pcoord = 0.0;
638 double pcoordStep = this->ResamplingStepLength / length;
639 while (pcoord < 1.0)
640 {
641 point[0] = point0[0] + (point1[0] - point0[0]) * pcoord;
642 point[1] = point0[1] + (point1[1] - point0[1]) * pcoord;
643 point[2] = point0[2] + (point1[2] - point0[2]) * pcoord;
644
645 double scalar = scalar0 + (scalar1 - scalar0) * pcoord;
646
647 vtkIdType id = resampledCenterlinesPoints->InsertNextPoint(point);
648 resampledCell->InsertNextId(id);
649 resampledCenterlinesRadiusArray->InsertNextValue(scalar);
650
651 if (pcoord + pcoordStep > 1.0)
652 {
653 break;
654 }
655 pcoord = pcoord + pcoordStep;
656 }
657 stepAbscissa = (1.0 - pcoord) * length;
658 }
659
660 id = resampledCenterlinesPoints->InsertNextPoint(cell->GetPoints()->GetPoint(cell->GetNumberOfPoints()-1));
661 resampledCell->InsertNextId(id);
662 resampledCenterlinesRadiusArray->InsertNextValue(centerlinesRadiusArray->GetValue(cell->GetPointId(cell->GetNumberOfPoints()-1)));
663
664 resampledCenterlinesCellArray->InsertNextCell(resampledCell);
665 }
666 resampledCenterlines->SetPoints(resampledCenterlinesPoints);
667 resampledCenterlines->SetLines(resampledCenterlinesCellArray);
668 resampledCenterlines->GetPointData()->AddArray(resampledCenterlinesRadiusArray);
669
670 output->ShallowCopy(resampledCenterlines);
671
672 resampledCenterlines->Delete();
673 resampledCenterlinesPoints->Delete();
674 resampledCenterlinesCellArray->Delete();
675 resampledCenterlinesRadiusArray->Delete();
676 resampledCell->Delete();
677}

◆ ReverseCenterlines()

void vtkvmtkPolyDataCenterlines::ReverseCenterlines ( )
protected

Definition at line 679 of file vtkvmtkPolyDataCenterlines.cxx.

680{
681 vtkPolyData* output = this->GetOutput();
682
683 vtkCellArray* reversedCenterlinesCellArray = vtkCellArray::New();
684 vtkIdList* reversedCell = vtkIdList::New();
685
686 for (int k=0; k<output->GetNumberOfCells(); k++)
687 {
688 vtkCell* cell = output->GetCell(k);
689
690 reversedCell->Initialize();
691
692 vtkIdType numberOfCellPoints = cell->GetNumberOfPoints();
693
694 for (int i=0; i<numberOfCellPoints; i++)
695 {
696 vtkIdType id = cell->GetPointId(numberOfCellPoints-1-i);
697 reversedCell->InsertNextId(id);
698 }
699 reversedCenterlinesCellArray->InsertNextCell(reversedCell);
700 }
701
702 output->SetLines(reversedCenterlinesCellArray);
703
704 reversedCell->Delete();
705 reversedCenterlinesCellArray->Delete();
706}

Member Data Documentation

◆ SourceSeedIds

vtkIdList* vtkvmtkPolyDataCenterlines::SourceSeedIds
protected

Definition at line 284 of file vtkvmtkPolyDataCenterlines.h.

◆ TargetSeedIds

vtkIdList* vtkvmtkPolyDataCenterlines::TargetSeedIds
protected

Definition at line 285 of file vtkvmtkPolyDataCenterlines.h.

◆ CapCenterIds

vtkIdList* vtkvmtkPolyDataCenterlines::CapCenterIds
protected

Definition at line 287 of file vtkvmtkPolyDataCenterlines.h.

◆ DelaunayTessellation

vtkUnstructuredGrid* vtkvmtkPolyDataCenterlines::DelaunayTessellation
protected

Definition at line 289 of file vtkvmtkPolyDataCenterlines.h.

◆ VoronoiDiagram

vtkPolyData* vtkvmtkPolyDataCenterlines::VoronoiDiagram
protected

Definition at line 291 of file vtkvmtkPolyDataCenterlines.h.

◆ PoleIds

vtkIdList* vtkvmtkPolyDataCenterlines::PoleIds
protected

Definition at line 293 of file vtkvmtkPolyDataCenterlines.h.

◆ RadiusArrayName

char* vtkvmtkPolyDataCenterlines::RadiusArrayName
protected

Definition at line 295 of file vtkvmtkPolyDataCenterlines.h.

◆ CostFunction

char* vtkvmtkPolyDataCenterlines::CostFunction
protected

Definition at line 296 of file vtkvmtkPolyDataCenterlines.h.

◆ EikonalSolutionArrayName

char* vtkvmtkPolyDataCenterlines::EikonalSolutionArrayName
protected

Definition at line 297 of file vtkvmtkPolyDataCenterlines.h.

◆ EdgeArrayName

char* vtkvmtkPolyDataCenterlines::EdgeArrayName
protected

Definition at line 298 of file vtkvmtkPolyDataCenterlines.h.

◆ EdgePCoordArrayName

char* vtkvmtkPolyDataCenterlines::EdgePCoordArrayName
protected

Definition at line 299 of file vtkvmtkPolyDataCenterlines.h.

◆ CostFunctionArrayName

char* vtkvmtkPolyDataCenterlines::CostFunctionArrayName
protected

Definition at line 300 of file vtkvmtkPolyDataCenterlines.h.

◆ FlipNormals

int vtkvmtkPolyDataCenterlines::FlipNormals
protected

Definition at line 302 of file vtkvmtkPolyDataCenterlines.h.

◆ SimplifyVoronoi

int vtkvmtkPolyDataCenterlines::SimplifyVoronoi
protected

Definition at line 303 of file vtkvmtkPolyDataCenterlines.h.

◆ AppendEndPointsToCenterlines

int vtkvmtkPolyDataCenterlines::AppendEndPointsToCenterlines
protected

Definition at line 304 of file vtkvmtkPolyDataCenterlines.h.

◆ CenterlineResampling

int vtkvmtkPolyDataCenterlines::CenterlineResampling
protected

Definition at line 305 of file vtkvmtkPolyDataCenterlines.h.

◆ ResamplingStepLength

double vtkvmtkPolyDataCenterlines::ResamplingStepLength
protected

Definition at line 307 of file vtkvmtkPolyDataCenterlines.h.

◆ GenerateVoronoiDiagram

int vtkvmtkPolyDataCenterlines::GenerateVoronoiDiagram
protected

Definition at line 309 of file vtkvmtkPolyDataCenterlines.h.

◆ StopFastMarchingOnReachingTarget

int vtkvmtkPolyDataCenterlines::StopFastMarchingOnReachingTarget
protected

Definition at line 310 of file vtkvmtkPolyDataCenterlines.h.

◆ GenerateDelaunayTessellation

int vtkvmtkPolyDataCenterlines::GenerateDelaunayTessellation
protected

Definition at line 311 of file vtkvmtkPolyDataCenterlines.h.

◆ DelaunayTolerance

double vtkvmtkPolyDataCenterlines::DelaunayTolerance
protected

Definition at line 312 of file vtkvmtkPolyDataCenterlines.h.


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