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

Provides a collection of functions that compute point ids which are n-spheres away from a reference point. More...

#include <vtkvmtkCenterlineSphereDistance.h>

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

Public Types

typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCenterlineSphereDistance * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkCenterlineSphereDistance * SafeDownCast (vtkObjectBase *o)
static vtkvmtkCenterlineSphereDistance * New ()
static void FindTouchingSphereCenter (vtkPolyData *centerlines, const char *radiusArrayName, vtkIdType cellId, vtkIdType subId, double pcoord, vtkIdType &touchingSubId, double &touchingPCoord, bool forward=true)
static void FindNTouchingSphereCenter (vtkPolyData *centerlines, const char *radiusArrayName, vtkIdType cellId, vtkIdType subId, double pcoord, int numberOfTouchingSpheres, vtkIdType &touchingSubId, double &touchingPCoord, bool forward=true)

Protected Member Functions

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

Detailed Description

Provides a collection of functions that compute point ids which are n-spheres away from a reference point.

Allows us to find points which are n-touching spheres upstream or downstream from a reference point. In this description, "touching sphere" refers to the the points on the centerline (one upstream, one downstream) which lie closest to ("touch") the surface of a sphere whose barycenter is located at the reference points location. In practice, this means that we use the centerline's MaximumInscribedSphereRadius point data as the "sphere" radius/surface.

This metric is used because it is a well behaved way to normalize the comparison of distance as vessel radius scales.

Purely a static utility class (never instantiated) used internally by the "branch extractor" family of filters (e.g. vtkvmtkCenterlineBranchExtractor, vtkvmtkCenterlineEndpointExtractor) to locate splitting points a given number of local vessel radii away from a reference location.

See also
vtkvmtkCenterlineBranchExtractor, vtkvmtkCenterlineEndpointExtractor

Definition at line 43 of file vtkvmtkCenterlineSphereDistance.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkCenterlineSphereDistance()

vtkvmtkCenterlineSphereDistance::vtkvmtkCenterlineSphereDistance ( )
inlineprotected

Definition at line 66 of file vtkvmtkCenterlineSphereDistance.h.

66{};

◆ ~vtkvmtkCenterlineSphereDistance()

vtkvmtkCenterlineSphereDistance::~vtkvmtkCenterlineSphereDistance ( )
inlineprotected

Definition at line 67 of file vtkvmtkCenterlineSphereDistance.h.

67{};

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCenterlineSphereDistance::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCenterlineSphereDistance * vtkvmtkCenterlineSphereDistance::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 261 of file vtkvmtkCenterlineSphereDistance.cxx.

262{
263 this->Superclass::PrintSelf(os,indent);
264}

◆ New()

vtkvmtkCenterlineSphereDistance * vtkvmtkCenterlineSphereDistance::New ( )
static

◆ FindTouchingSphereCenter()

void vtkvmtkCenterlineSphereDistance::FindTouchingSphereCenter ( vtkPolyData * centerlines,
const char * radiusArrayName,
vtkIdType cellId,
vtkIdType subId,
double pcoord,
vtkIdType & touchingSubId,
double & touchingPCoord,
bool forward = true )
static

Starting from the point at (cellId, subId, pcoord) on centerlines, walk forward (or backward, if forward is false) until reaching the point whose maximum inscribed sphere (radius taken from the radiusArrayName point data array) just touches the sphere centered at the starting point. The result is returned in touchingSubId/touchingPCoord.

Definition at line 73 of file vtkvmtkCenterlineSphereDistance.cxx.

74{
75 touchingSubId = -1;
76 touchingPCoord = 0.0;
77
78 vtkCell* centerline = centerlines->GetCell(cellId);
79
80 if (centerline->GetCellType() != VTK_LINE && centerline->GetCellType() != VTK_POLY_LINE)
81 {
82 return;
83 }
84
85 if (!radiusArrayName)
86 {
87 return;
88 }
89
90 vtkDataArray* radiusArray = centerlines->GetPointData()->GetArray(radiusArrayName);
91
92 if (!radiusArray)
93 {
94 return;
95 }
96
97 vtkIdList* subIds = vtkIdList::New();
98
99 int k;
100 if (forward)
101 {
102 for (k=0; k<subId; k++)
103 {
104 subIds->InsertNextId(k);
105 }
106 }
107 else
108 {
109 for (k=centerline->GetNumberOfPoints()-2; k>subId; k--)
110 {
111 subIds->InsertNextId(k);
112 }
113 }
114
115 double point[3], point0[3], point1[3];
116 centerline->GetPoints()->GetPoint(subId,point0);
117 centerline->GetPoints()->GetPoint(subId+1,point1);
118 for (k=0; k<3; k++)
119 {
120 point[k] = point0[k] + pcoord*(point1[k] - point0[k]);
121 }
122
123 vtkIdType centerId0, centerId1;
124 double center0[3], center1[3], radius0, radius1;
125 vtkIdType currentSubId;
126 double currentPCoord;
127 double sphereDistance0, sphereDistance1;
128
129 touchingSubId = -1;
130 touchingPCoord = 0.0;
131
132 int i;
133 for (i=0; i<subIds->GetNumberOfIds(); i++)
134 {
135 currentSubId = subIds->GetId(i);
136
137 centerId0 = centerline->GetPointId(currentSubId);
138 centerId1 = centerline->GetPointId(currentSubId+1);
139 centerlines->GetPoint(centerId0,center0);
140 centerlines->GetPoint(centerId1,center1);
141 radius0 = radiusArray->GetComponent(centerId0,0);
142 radius1 = radiusArray->GetComponent(centerId1,0);
143 sphereDistance0 = vtkvmtkMath::EvaluateSphereFunction(center0,radius0,point);
144 sphereDistance1 = vtkvmtkMath::EvaluateSphereFunction(center1,radius1,point);
145
146 if (forward)
147 {
148 if ((sphereDistance0 > 0.0) && (sphereDistance1 <= 0.0))
149 {
150 touchingSubId = currentSubId;
151 break;
152 }
153 }
154 else
155 {
156 if ((sphereDistance0 <= 0.0) && (sphereDistance1 > 0.0))
157 {
158 touchingSubId = currentSubId;
159 break;
160 }
161 }
162 }
163
164 if (touchingSubId == -1)
165 {
166 centerId0 = centerline->GetPointId(subId);
167 centerId1 = centerline->GetPointId(subId+1);
168 centerlines->GetPoint(centerId0,center0);
169 centerlines->GetPoint(centerId1,center1);
170 radius0 = radiusArray->GetComponent(centerId0,0);
171 radius1 = radiusArray->GetComponent(centerId1,0);
172
173 sphereDistance0 = vtkvmtkMath::EvaluateSphereFunction(center0,radius0,point);
174 sphereDistance1 = vtkvmtkMath::EvaluateSphereFunction(center1,radius1,point);
175
176 if ((sphereDistance0<=0.0) && (sphereDistance1<=0.0))
177 {
178 touchingSubId = -1;
179 subIds->Delete();
180 return;
181 }
182
183 touchingSubId = subId;
184 }
185
186 // optimize between (touchingSubId, touchingSubId+1)
187
188 // linear search, step proportional to sphere radius.
189
190 centerId0 = centerline->GetPointId(touchingSubId);
191 centerId1 = centerline->GetPointId(touchingSubId+1);
192 centerlines->GetPoint(centerId0,center0);
193 centerlines->GetPoint(centerId1,center1);
194 radius0 = radiusArray->GetComponent(centerId0,0);
195 radius1 = radiusArray->GetComponent(centerId1,0);
196
197 double segmentLength, stepSize, pcoordStepSize;
198 int numberOfSteps;
199 double subCenter0[3], subCenter1[3], subRadius0, subRadius1;
200 segmentLength = vtkMath::Distance2BetweenPoints(center0,center1);
201 stepSize = 1E-6 * (radius0 + radius1) / 2.0;
202 const double maxNumberOfSteps = 1e5;
203 numberOfSteps = (int)ceil(std::min(segmentLength / stepSize, maxNumberOfSteps));
204 stepSize = segmentLength / numberOfSteps;
205 pcoordStepSize = 1.0 / (double)numberOfSteps;
206
207 touchingPCoord = 0.0;
208 currentPCoord = 0.0;
209 for (i=0; i<numberOfSteps; i++)
210 {
211 for (int k=0; k<3; k++)
212 {
213 subCenter0[k] = center0[k] + currentPCoord*(center1[k] - center0[k]);
214 subCenter1[k] = center0[k] + (currentPCoord+pcoordStepSize)*(center1[k] - center0[k]);
215 }
216 subRadius0 = radius0 + currentPCoord*(radius1 - radius0);
217 subRadius1 = radius0 + (currentPCoord+pcoordStepSize)*(radius1 - radius0);
218
219 sphereDistance0 = vtkvmtkMath::EvaluateSphereFunction(subCenter0,subRadius0,point);
220 sphereDistance1 = vtkvmtkMath::EvaluateSphereFunction(subCenter1,subRadius1,point);
221
222 if (forward)
223 {
224 if ((sphereDistance0 > 0.0) && (sphereDistance1 <= 0.0))
225 {
226 touchingPCoord = currentPCoord;
227 break;
228 }
229 }
230 else
231 {
232 if ((sphereDistance0 <= 0.0) && (sphereDistance1 > 0.0))
233 {
234 touchingPCoord = currentPCoord+pcoordStepSize;
235 break;
236 }
237 }
238 currentPCoord += pcoordStepSize;
239 }
240
241 if (forward)
242 {
243 if ((touchingSubId == subId) && (touchingPCoord > pcoord))
244 {
245 touchingSubId = -1;
246 touchingPCoord = 0.0;
247 }
248 }
249 else
250 {
251 if ((touchingSubId == subId) && (touchingPCoord < pcoord))
252 {
253 touchingSubId = -1;
254 touchingPCoord = 0.0;
255 }
256 }
257
258 subIds->Delete();
259}
static double EvaluateSphereFunction(double center[3], double radius, double point[3])

◆ FindNTouchingSphereCenter()

void vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter ( vtkPolyData * centerlines,
const char * radiusArrayName,
vtkIdType cellId,
vtkIdType subId,
double pcoord,
int numberOfTouchingSpheres,
vtkIdType & touchingSubId,
double & touchingPCoord,
bool forward = true )
static

Like FindTouchingSphereCenter, but repeats the touching-sphere walk numberOfTouchingSpheres times in a row (each new sphere touching the previous one), returning the final position in touchingSubId/touchingPCoord.

Definition at line 43 of file vtkvmtkCenterlineSphereDistance.cxx.

44{
45 vtkIdType dummySubId0, dummySubId1;
46 double dummyPCoord0, dummyPCoord1;
47
48 if (numberOfTouchingSpheres == 0)
49 {
50 touchingSubId = subId;
51 touchingPCoord = pcoord;
52 return;
53 }
54
55 dummySubId0 = subId;
56 dummyPCoord0 = pcoord;
57
58 for (int i=0; i<numberOfTouchingSpheres; i++)
59 {
60 vtkvmtkCenterlineSphereDistance::FindTouchingSphereCenter(centerlines,radiusArrayName,cellId,dummySubId0,dummyPCoord0,dummySubId1,dummyPCoord1,forward);
61 if (dummySubId1 == -1)
62 {
63 break;
64 }
65 dummySubId0 = dummySubId1;
66 dummyPCoord0 = dummyPCoord1;
67 }
68
69 touchingSubId = dummySubId1;
70 touchingPCoord = dummyPCoord1;
71}
static void FindTouchingSphereCenter(vtkPolyData *centerlines, const char *radiusArrayName, vtkIdType cellId, vtkIdType subId, double pcoord, vtkIdType &touchingSubId, double &touchingPCoord, bool forward=true)

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