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

Implements vtkImplicitFunction to evaluate the minimum sphere function for an envelope created by an interpolation of sphere radii along a centerline. More...

#include <vtkvmtkPolyBallLine.h>

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

Public Types

typedef vtkImplicitFunction Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyBallLine * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
double EvaluateFunction (double x[3]) override
double EvaluateFunction (double x, double y, double z) override
void EvaluateGradient (double x[3], double n[3]) override
virtual vtkIdType GetLastPolyBallCellId ()
virtual vtkIdType GetLastPolyBallCellSubId ()
virtual double GetLastPolyBallCellPCoord ()
virtual double * GetLastPolyBallCenter ()
virtual void GetLastPolyBallCenter (double data[3])
virtual double GetLastPolyBallCenterRadius ()
virtual void SetInput (vtkPolyData *)
virtual vtkPolyData * GetInput ()
virtual void SetInputCellIds (vtkIdList *)
virtual vtkIdList * GetInputCellIds ()
virtual void SetInputCellId (vtkIdType)
virtual vtkIdType GetInputCellId ()
virtual void SetPolyBallRadiusArrayName (const char *)
virtual char * GetPolyBallRadiusArrayName ()
virtual void SetUseRadiusInformation (int)
virtual int GetUseRadiusInformation ()
virtual void UseRadiusInformationOn ()
virtual void UseRadiusInformationOff ()

Static Public Member Functions

static vtkvmtkPolyBallLine * New ()
static int IsTypeOf (const char *type)
static vtkvmtkPolyBallLine * SafeDownCast (vtkObjectBase *o)
static double ComplexDot (double x[4], double y[4])

Protected Member Functions

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

Protected Attributes

vtkPolyData * Input
vtkIdList * InputCellIds
vtkIdType InputCellId
char * PolyBallRadiusArrayName
vtkIdType LastPolyBallCellId
vtkIdType LastPolyBallCellSubId
double LastPolyBallCellPCoord
double LastPolyBallCenter [3]
double LastPolyBallCenterRadius
int UseRadiusInformation

Detailed Description

Implements vtkImplicitFunction to evaluate the minimum sphere function for an envelope created by an interpolation of sphere radii along a centerline.

See detailed description of implicit function in the documentation for vtkvmtkPolyBall class.

Similar to vtkvmtkPolyBall, the core function of this class is to evaluate the minimum sphere function from on input centerline with associated sphere radii and a query point location. Unlike vtkvmtkPolyBall, this class constructs a continuous tubular envelope whose shape is defined by the linear interpolation of the circular boundary profiles (with radius equal to the associated sphere radii) between every consecutive point on the line. As the boundary profiles are constructed from the centerline sphere radii, the tubular envelope generated is guaranteed to lie completely within the surface volume. When evaluated, this is essentially equivalent to evaluating a polyball function for an infinitely large collection of spheres along an input dataset.

This is the implicit function underlying vtkvmtkPolyBallModeller (used by the vmtkcenterlinemodeller pype script to rasterize a "tube function" image from centerlines with maximum inscribed sphere radii), and it is also used directly wherever vmtk needs to test whether a point lies inside the tubular structure swept by a set of centerlines (e.g. flow extension generation, centerline-based surface clipping). The Input poly data is expected to be a vtkPolyData composed of line/polyline cells whose points carry a point data array (see PolyBallRadiusArrayName) with the sphere radius at each point, such as the MaximumInscribedSphereRadius array produced by vmtkcenterlines / vtkvmtkPolyDataCenterlines.

See also
vtkvmtkPolyBall, vtkvmtkPolyBallModeller

Definition at line 55 of file vtkvmtkPolyBallLine.h.

Member Typedef Documentation

◆ Superclass

typedef vtkImplicitFunction vtkvmtkPolyBallLine::Superclass

Definition at line 60 of file vtkvmtkPolyBallLine.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyBallLine()

vtkvmtkPolyBallLine::vtkvmtkPolyBallLine ( )
protected

Definition at line 31 of file vtkvmtkPolyBallLine.cxx.

32{
33 this->Input = NULL;
34 this->InputCellIds = NULL;
35 this->InputCellId = -1;
36 this->PolyBallRadiusArrayName = NULL;
37 this->LastPolyBallCellId = -1;
38 this->LastPolyBallCellSubId = -1;
39 this->LastPolyBallCellPCoord = 0.0;
40 this->LastPolyBallCenter[0] = this->LastPolyBallCenter[1] = this->LastPolyBallCenter[2] = 0.0;
41 this->LastPolyBallCenterRadius = 0.0;
42 this->UseRadiusInformation = 1;
43}

◆ ~vtkvmtkPolyBallLine()

vtkvmtkPolyBallLine::~vtkvmtkPolyBallLine ( )
protected

Definition at line 45 of file vtkvmtkPolyBallLine.cxx.

46{
47 if (this->Input)
48 {
49 this->Input->Delete();
50 this->Input = NULL;
51 }
52
53 if (this->InputCellIds)
54 {
55 this->InputCellIds->Delete();
56 this->InputCellIds = NULL;
57 }
58
60 {
61 delete[] this->PolyBallRadiusArrayName;
62 this->PolyBallRadiusArrayName = NULL;
63 }
64}

Member Function Documentation

◆ New()

vtkvmtkPolyBallLine * vtkvmtkPolyBallLine::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyBallLine::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyBallLine * vtkvmtkPolyBallLine::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 247 of file vtkvmtkPolyBallLine.cxx.

248{
249 this->Superclass::PrintSelf(os,indent);
250
251}

◆ EvaluateFunction() [1/2]

double vtkvmtkPolyBallLine::EvaluateFunction ( double x[3])
override

Evaluate the polyball-line function at point x: the squared distance from x to the closest point on the tubular envelope's medial axis, minus the squared interpolated radius at that closest point. Negative values are inside the envelope, positive values are outside, zero is on the surface. As a side effect, the identity of the closest centerline segment and interpolated sphere are cached and can be retrieved with GetLastPolyBallCellId, GetLastPolyBallCellSubId, GetLastPolyBallCellPCoord, GetLastPolyBallCenter and GetLastPolyBallCenterRadius.

Definition at line 71 of file vtkvmtkPolyBallLine.cxx.

72{
73 vtkIdType i, k;
74 vtkIdType npts;
75 const vtkIdType *pts;
76 double polyballFunctionValue, minPolyBallFunctionValue;
77 double point0[3], point1[3];
78 double radius0, radius1;
79 double vector0[4], vector1[4], closestPoint[4];
80 double t;
81 double num, den;
82 vtkDataArray *polyballRadiusArray = NULL;
83
84 if (!this->Input)
85 {
86 vtkErrorMacro(<<"No Input specified!");
87 return 0.0;
88 }
89
90 if (this->Input->GetNumberOfPoints()==0)
91 {
92 vtkWarningMacro(<<"Empty Input specified!");
93 return 0.0;
94 }
95
96 if (this->UseRadiusInformation)
97 {
98 if (!this->PolyBallRadiusArrayName)
99 {
100 vtkErrorMacro(<<"No PolyBallRadiusArrayName specified!");
101 return 0.0;
102 }
103
104 polyballRadiusArray = this->Input->GetPointData()->GetArray(this->PolyBallRadiusArrayName);
105
106 if (polyballRadiusArray==NULL)
107 {
108 vtkErrorMacro(<<"PolyBallRadiusArray with name specified does not exist!");
109 return 0.0;
110 }
111 }
112
113 if (this->Input->GetLines()==NULL)
114 {
115 vtkWarningMacro(<<"No lines in Input dataset.");
116 return 0.0;
117 }
118
119 this->Input->BuildCells();
120
121 minPolyBallFunctionValue = VTK_VMTK_LARGE_DOUBLE;
122
123 closestPoint[0] = closestPoint[1] = closestPoint[2] = closestPoint[2] = 0.0;
124
125 this->LastPolyBallCellId = -1;
126 this->LastPolyBallCellSubId = -1;
127 this->LastPolyBallCellPCoord = 0.0;
128 this->LastPolyBallCenter[0] = this->LastPolyBallCenter[1] = this->LastPolyBallCenter[2] = 0.0;
129 this->LastPolyBallCenterRadius = 0.0;
130
131 vtkIdList* cellIds = vtkIdList::New();
132
133 if (this->InputCellIds)
134 {
135 cellIds->DeepCopy(this->InputCellIds);
136 }
137 else if (this->InputCellId != -1)
138 {
139 cellIds->InsertNextId(this->InputCellId);
140 }
141 else
142 {
143 cellIds->SetNumberOfIds(this->Input->GetNumberOfCells());
144 for (k=0; k<this->Input->GetNumberOfCells(); k++)
145 {
146 cellIds->SetId(k,k);
147 }
148 }
149
150 for (k=0; k<cellIds->GetNumberOfIds(); k++)
151 {
152 vtkIdType cellId = cellIds->GetId(k);
153
154 if (this->Input->GetCellType(cellId)!=VTK_LINE && this->Input->GetCellType(cellId)!=VTK_POLY_LINE)
155 {
156 continue;
157 }
158
159 this->Input->GetCellPoints(cellId,npts,pts);
160
161 for (i=0; i<npts-1; i++)
162 {
163 this->Input->GetPoint(pts[i],point0);
164 this->Input->GetPoint(pts[i+1],point1);
165 if (this->UseRadiusInformation)
166 {
167 radius0 = polyballRadiusArray->GetComponent(pts[i],0);
168 radius1 = polyballRadiusArray->GetComponent(pts[i+1],0);
169 }
170 else
171 {
172 radius0 = 0.0;
173 radius1 = 0.0;
174 }
175 vector0[0] = point1[0] - point0[0];
176 vector0[1] = point1[1] - point0[1];
177 vector0[2] = point1[2] - point0[2];
178 vector0[3] = radius1 - radius0;
179 vector1[0] = x[0] - point0[0];
180 vector1[1] = x[1] - point0[1];
181 vector1[2] = x[2] - point0[2];
182 vector1[3] = 0.0 - radius0;
183
184// cout<<x[0]<<" "<<x[1]<<" "<<x[2]<<" "<<point0[0]<<" "<<point0[1]<<" "<<point0[2]<<" "<<point1[0]<<" "<<point1[1]<<" "<<point1[2]<<" "<<endl;
185
186 num = this->ComplexDot(vector0,vector1);
187 den = this->ComplexDot(vector0,vector0);
188
189 if (fabs(den)<VTK_VMTK_DOUBLE_TOL)
190 {
191 continue;
192 }
193
194 t = num / den;
195
197 {
198 t = 0.0;
199 closestPoint[0] = point0[0];
200 closestPoint[1] = point0[1];
201 closestPoint[2] = point0[2];
202 closestPoint[3] = radius0;
203 }
204 else if (1.0-t<VTK_VMTK_DOUBLE_TOL)
205 {
206 t = 1.0;
207 closestPoint[0] = point1[0];
208 closestPoint[1] = point1[1];
209 closestPoint[2] = point1[2];
210 closestPoint[3] = radius1;
211 }
212 else
213 {
214 closestPoint[0] = point0[0] + t * vector0[0];
215 closestPoint[1] = point0[1] + t * vector0[1];
216 closestPoint[2] = point0[2] + t * vector0[2];
217 closestPoint[3] = radius0 + t * vector0[3];
218 }
219
220 polyballFunctionValue = (x[0]-closestPoint[0])*(x[0]-closestPoint[0]) + (x[1]-closestPoint[1])*(x[1]-closestPoint[1]) + (x[2]-closestPoint[2])*(x[2]-closestPoint[2]) - closestPoint[3]*closestPoint[3];
221
222 if (polyballFunctionValue<minPolyBallFunctionValue)
223 {
224 minPolyBallFunctionValue = polyballFunctionValue;
225 this->LastPolyBallCellId = cellId;
226 this->LastPolyBallCellSubId = i;
227 this->LastPolyBallCellPCoord = t;
228 this->LastPolyBallCenter[0] = closestPoint[0];
229 this->LastPolyBallCenter[1] = closestPoint[1];
230 this->LastPolyBallCenter[2] = closestPoint[2];
231 this->LastPolyBallCenterRadius = closestPoint[3];
232 }
233 }
234 }
235
236 cellIds->Delete();
237
238 return minPolyBallFunctionValue;
239}
static double ComplexDot(double x[4], double y[4])
#define VTK_VMTK_DOUBLE_TOL
#define VTK_VMTK_LARGE_DOUBLE

◆ EvaluateFunction() [2/2]

double vtkvmtkPolyBallLine::EvaluateFunction ( double x,
double y,
double z )
inlineoverride

Definition at line 71 of file vtkvmtkPolyBallLine.h.

72 {return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ;

◆ EvaluateGradient()

void vtkvmtkPolyBallLine::EvaluateGradient ( double x[3],
double n[3] )
override

Evaluate the gradient of the polyball-line function at point x. Not implemented: calling this currently only emits a warning and leaves n unchanged.

Definition at line 241 of file vtkvmtkPolyBallLine.cxx.

242{
243 vtkWarningMacro("Poly ball gradient computation not yet implemented!");
244 // TODO
245}

◆ SetInput()

virtual void vtkvmtkPolyBallLine::SetInput ( vtkPolyData * )
virtual

Set/get the input poly data whose line/polyline cells define the centerline(s) used to build the tubular envelope. Each point of Input should carry a sphere radius value in the array named PolyBallRadiusArrayName when UseRadiusInformation is on.

◆ GetInput()

virtual vtkPolyData * vtkvmtkPolyBallLine::GetInput ( )
virtual

Set/get the input poly data whose line/polyline cells define the centerline(s) used to build the tubular envelope. Each point of Input should carry a sphere radius value in the array named PolyBallRadiusArrayName when UseRadiusInformation is on.

◆ SetInputCellIds()

virtual void vtkvmtkPolyBallLine::SetInputCellIds ( vtkIdList * )
virtual

Set/get the subset of Input cell ids over which the function is evaluated. When set, only these cells contribute to the minimum sphere function; this is useful to restrict evaluation to a single branch or a group of centerlines. If both InputCellIds and InputCellId are unset (default), all line cells in Input are used.

◆ GetInputCellIds()

virtual vtkIdList * vtkvmtkPolyBallLine::GetInputCellIds ( )
virtual

Set/get the subset of Input cell ids over which the function is evaluated. When set, only these cells contribute to the minimum sphere function; this is useful to restrict evaluation to a single branch or a group of centerlines. If both InputCellIds and InputCellId are unset (default), all line cells in Input are used.

◆ SetInputCellId()

virtual void vtkvmtkPolyBallLine::SetInputCellId ( vtkIdType )
virtual

Set/get a single Input cell id over which the function is evaluated. Ignored if InputCellIds is set. Default is -1, meaning no single-cell restriction (all cells, or those in InputCellIds, are used).

◆ GetInputCellId()

virtual vtkIdType vtkvmtkPolyBallLine::GetInputCellId ( )
virtual

Set/get a single Input cell id over which the function is evaluated. Ignored if InputCellIds is set. Default is -1, meaning no single-cell restriction (all cells, or those in InputCellIds, are used).

◆ SetPolyBallRadiusArrayName()

virtual void vtkvmtkPolyBallLine::SetPolyBallRadiusArrayName ( const char * )
virtual

Set/get the name of the point data array of Input holding the sphere radius at each centerline point (e.g. the MaximumInscribedSphereRadius array produced by centerline extraction). Required whenever UseRadiusInformation is on. Commonly named "MaximumInscribedSphereRadius".

◆ GetPolyBallRadiusArrayName()

virtual char * vtkvmtkPolyBallLine::GetPolyBallRadiusArrayName ( )
virtual

Set/get the name of the point data array of Input holding the sphere radius at each centerline point (e.g. the MaximumInscribedSphereRadius array produced by centerline extraction). Required whenever UseRadiusInformation is on. Commonly named "MaximumInscribedSphereRadius".

◆ GetLastPolyBallCellId()

virtual vtkIdType vtkvmtkPolyBallLine::GetLastPolyBallCellId ( )
virtual

Get the id, within Input, of the cell containing the closest sphere/segment found by the most recent EvaluateFunction call.

◆ GetLastPolyBallCellSubId()

virtual vtkIdType vtkvmtkPolyBallLine::GetLastPolyBallCellSubId ( )
virtual

Get the sub-id (index of the line segment within its cell, i.e. the segment between points i and i+1) of the closest segment found by the most recent EvaluateFunction call.

◆ GetLastPolyBallCellPCoord()

virtual double vtkvmtkPolyBallLine::GetLastPolyBallCellPCoord ( )
virtual

Get the parametric coordinate (in [0,1], measured from the start of the closest segment) of the closest sphere center found by the most recent EvaluateFunction call.

◆ GetLastPolyBallCenter() [1/2]

virtual double * vtkvmtkPolyBallLine::GetLastPolyBallCenter ( )
virtual

Get the (x,y,z) coordinates of the closest interpolated sphere center found by the most recent EvaluateFunction call.

◆ GetLastPolyBallCenter() [2/2]

virtual void vtkvmtkPolyBallLine::GetLastPolyBallCenter ( double data[3])
virtual

◆ GetLastPolyBallCenterRadius()

virtual double vtkvmtkPolyBallLine::GetLastPolyBallCenterRadius ( )
virtual

Get the radius of the closest interpolated sphere found by the most recent EvaluateFunction call.

◆ SetUseRadiusInformation()

virtual void vtkvmtkPolyBallLine::SetUseRadiusInformation ( int )
virtual

Toggle use of the per-point sphere radii stored in PolyBallRadiusArrayName when evaluating the function. When off, radii are treated as zero everywhere, so the function reduces to the squared distance to the polyline (its zero level set degenerates to the centerline itself rather than a tubular envelope). Default: on.

◆ GetUseRadiusInformation()

virtual int vtkvmtkPolyBallLine::GetUseRadiusInformation ( )
virtual

Toggle use of the per-point sphere radii stored in PolyBallRadiusArrayName when evaluating the function. When off, radii are treated as zero everywhere, so the function reduces to the squared distance to the polyline (its zero level set degenerates to the centerline itself rather than a tubular envelope). Default: on.

◆ UseRadiusInformationOn()

virtual void vtkvmtkPolyBallLine::UseRadiusInformationOn ( )
virtual

Toggle use of the per-point sphere radii stored in PolyBallRadiusArrayName when evaluating the function. When off, radii are treated as zero everywhere, so the function reduces to the squared distance to the polyline (its zero level set degenerates to the centerline itself rather than a tubular envelope). Default: on.

◆ UseRadiusInformationOff()

virtual void vtkvmtkPolyBallLine::UseRadiusInformationOff ( )
virtual

Toggle use of the per-point sphere radii stored in PolyBallRadiusArrayName when evaluating the function. When off, radii are treated as zero everywhere, so the function reduces to the squared distance to the polyline (its zero level set degenerates to the centerline itself rather than a tubular envelope). Default: on.

◆ ComplexDot()

double vtkvmtkPolyBallLine::ComplexDot ( double x[4],
double y[4] )
static

Dot product in Minkowski (3+1)-D space: the sum of the products of the first three (spatial) components minus the product of the fourth (radius) components, i.e. x[0]*y[0] + x[1]*y[1] + x[2]*y[2] - x[3]*y[3]. Used internally to project the query point onto the cone swept by the linearly interpolated sphere radii along each centerline segment; exposed as a static utility for reuse.

Definition at line 66 of file vtkvmtkPolyBallLine.cxx.

67{
68 return x[0]*y[0] + x[1]*y[1] + x[2]*y[2] - x[3]*y[3];
69}

Member Data Documentation

◆ Input

vtkPolyData* vtkvmtkPolyBallLine::Input
protected

Definition at line 154 of file vtkvmtkPolyBallLine.h.

◆ InputCellIds

vtkIdList* vtkvmtkPolyBallLine::InputCellIds
protected

Definition at line 155 of file vtkvmtkPolyBallLine.h.

◆ InputCellId

vtkIdType vtkvmtkPolyBallLine::InputCellId
protected

Definition at line 156 of file vtkvmtkPolyBallLine.h.

◆ PolyBallRadiusArrayName

char* vtkvmtkPolyBallLine::PolyBallRadiusArrayName
protected

Definition at line 158 of file vtkvmtkPolyBallLine.h.

◆ LastPolyBallCellId

vtkIdType vtkvmtkPolyBallLine::LastPolyBallCellId
protected

Definition at line 159 of file vtkvmtkPolyBallLine.h.

◆ LastPolyBallCellSubId

vtkIdType vtkvmtkPolyBallLine::LastPolyBallCellSubId
protected

Definition at line 160 of file vtkvmtkPolyBallLine.h.

◆ LastPolyBallCellPCoord

double vtkvmtkPolyBallLine::LastPolyBallCellPCoord
protected

Definition at line 161 of file vtkvmtkPolyBallLine.h.

◆ LastPolyBallCenter

double vtkvmtkPolyBallLine::LastPolyBallCenter[3]
protected

Definition at line 162 of file vtkvmtkPolyBallLine.h.

◆ LastPolyBallCenterRadius

double vtkvmtkPolyBallLine::LastPolyBallCenterRadius
protected

Definition at line 163 of file vtkvmtkPolyBallLine.h.

◆ UseRadiusInformation

int vtkvmtkPolyBallLine::UseRadiusInformation
protected

Definition at line 165 of file vtkvmtkPolyBallLine.h.


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