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

Second version of polyline where distance to the line is first computed and then the radius at the closest point is subtracted. More...

#include <vtkvmtkPolyBallLine2.h>

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

Public Types

typedef vtkImplicitFunction Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyBallLine2 * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
void EvaluateGradient (double x[3], double n[3]) override
double EvaluateFunction (double x[3]) override
double EvaluateFunction (double x, double y, double z) override
virtual void SetInput (vtkPolyData *inp)
virtual vtkPolyData * GetInput ()
void SetInputData (vtkPolyData *input)
vtkPolyData * GetInputData ()
virtual void SetInputCellIds (vtkIdList *cellIds)
virtual vtkIdList * GetInputCellIds ()
virtual void SetInputCellId (vtkIdType cellId)
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 vtkvmtkPolyBallLine2 * New ()
static int IsTypeOf (const char *type)
static vtkvmtkPolyBallLine2 * SafeDownCast (vtkObjectBase *o)
static double ComplexDot (double x[4], double y[4])

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyBallLine2 ()
 ~vtkvmtkPolyBallLine2 ()
void BuildLocator ()

Protected Attributes

vtkPolyData * Input
vtkIdList * InputCellIds
vtkIdType InputCellId
char * PolyBallRadiusArrayName
vtkIdType LastPolyBallCellId
vtkIdType LastPolyBallCellSubId
double LastPolyBallCellPCoord
double LastPolyBallCenter [3]
double LastPolyBallCenterRadius
int UseRadiusInformation
vtkTriangleFilter * Triangulator
vtkCellLocator * Locator
vtkPolyData * LocalInput
vtkPolyData * TriangulatedInput
bool ShouldBuildLocator
unsigned long LocatorMTime

Detailed Description

Second version of polyline where distance to the line is first computed and then the radius at the closest point is subtracted.

This is another version of a polyball line. Here the distance to the line is first computed and then the radius at the closest point is subtracted. This way each line segment only influences its voronoi cell.

Definition at line 41 of file vtkvmtkPolyBallLine2.h.

Member Typedef Documentation

◆ Superclass

typedef vtkImplicitFunction vtkvmtkPolyBallLine2::Superclass

Definition at line 46 of file vtkvmtkPolyBallLine2.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyBallLine2()

vtkvmtkPolyBallLine2::vtkvmtkPolyBallLine2 ( )
protected

Definition at line 37 of file vtkvmtkPolyBallLine2.cxx.

38{
39 this->Input = NULL;
40 this->InputCellIds = NULL;
41 this->InputCellId = -1;
42 this->PolyBallRadiusArrayName = NULL;
43 this->UseRadiusInformation = 1;
44 this->LocalInput = NULL;
45 this->TriangulatedInput = NULL;
46 this->Triangulator = vtkTriangleFilter::New();
47 this->Triangulator->PassLinesOn();
48 this->Locator = vtkCellLocator::New();
49 this->ShouldBuildLocator = true;
50 this->LocatorMTime = 0;
51}
vtkTriangleFilter * Triangulator

◆ ~vtkvmtkPolyBallLine2()

vtkvmtkPolyBallLine2::~vtkvmtkPolyBallLine2 ( )
protected

Definition at line 53 of file vtkvmtkPolyBallLine2.cxx.

54{
55 if (this->LocalInput && (this->LocalInput != this->Input))
56 {
57 this->LocalInput->Delete();
58 this->LocalInput = NULL;
59 }
60
61 if (this->Input)
62 {
63 this->Input->Delete();
64 this->Input = NULL;
65 }
66
67 if (this->InputCellIds)
68 {
69 this->InputCellIds->Delete();
70 this->InputCellIds = NULL;
71 }
72
74 {
75 delete[] this->PolyBallRadiusArrayName;
76 this->PolyBallRadiusArrayName = NULL;
77 }
78
79 if (this->Triangulator)
80 {
81 this->Triangulator->Delete();
82 this->Triangulator = NULL;
83 }
84
85 if (this->Locator)
86 {
87 this->Locator->Delete();
88 this->Locator = NULL;
89 }
90}

Member Function Documentation

◆ New()

vtkvmtkPolyBallLine2 * vtkvmtkPolyBallLine2::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyBallLine2::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyBallLine2 * vtkvmtkPolyBallLine2::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 233 of file vtkvmtkPolyBallLine2.cxx.

234{
235 this->Superclass::PrintSelf(os,indent);
236
237}

◆ EvaluateFunction() [1/2]

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

Evaluate polyball.

Definition at line 126 of file vtkvmtkPolyBallLine2.cxx.

127{
128 if (!this->Input)
129 {
130 vtkErrorMacro(<<"No Input specified!");
131 return 0.0;
132 }
133
134 if (this->Input->GetNumberOfPoints()==0)
135 {
136 vtkWarningMacro(<<"Empty Input specified!");
137 return 0.0;
138 }
139
140 if (this->UseRadiusInformation)
141 {
142 if (!this->PolyBallRadiusArrayName)
143 {
144 vtkErrorMacro(<<"No PolyBallRadiusArrayName specified!");
145 return 0.0;
146 }
147 }
148
149 this->ShouldBuildLocator = this->ShouldBuildLocator || (this->LocatorMTime != this->Input->GetMTime());
150
151 //Rebuild the locator if needed
152 if (this->ShouldBuildLocator)
153 {
154 this->BuildLocator();
155 }
156
157 //Find the cell closest to x
158 double dist2;
159 double closPt[3];
160 vtkIdType closCellId;
161 int subId;
162 this->Locator->FindClosestPoint(x,closPt,closCellId,subId,dist2);
163
164 double value;
165
166 if (this->UseRadiusInformation)
167 {
168 vtkDataArray *polyballRadiusArray = this->TriangulatedInput->GetPointData()->GetArray(this->PolyBallRadiusArrayName);
169
170 if (polyballRadiusArray==NULL)
171 {
172 vtkErrorMacro(<<"PolyBallRadiusArray with name specified does not exist!");
173 return 0.0;
174 }
175
176 vtkIdType cellType = this->TriangulatedInput->GetCellType(closCellId);
177
178 if (cellType != VTK_LINE)
179 {
180 vtkErrorMacro(<<"Error wrong cell type in polyline!");
181 return 0.0;
182 }
183
184 vtkIdList *linePointsIds = vtkIdList::New();
185 this->TriangulatedInput->GetCellPoints(closCellId, linePointsIds);
186 double *point0;
187 double *point1;
188 double vector0[3], vector1[3];
189 double radius0, radius1;
190 point0 = this->TriangulatedInput->GetPoint(linePointsIds->GetId(0));
191 point1 = this->TriangulatedInput->GetPoint(linePointsIds->GetId(1));
192
193 for (int i=0;i<3;i++)
194 {
195 vector0[i] = point1[i] - point0[i];
196 vector1[i] = closPt[i] - point0[i];
197 }
198
199 double num = vtkMath::Dot(vector0,vector1);
200 double den = vtkMath::Dot(vector0,vector0);
201
202 double t=0;
203
204 //t should be between 0 and 1 since we took the closest point
205 if (den!=0.)
206 {
207 t = num/den;
208 }
209
210 radius0 = polyballRadiusArray->GetComponent(linePointsIds->GetId(0),0);
211 radius1 = polyballRadiusArray->GetComponent(linePointsIds->GetId(1),0);
212
213 double radius = radius0 + t*(radius1 - radius0);
214
215 value = sqrt(dist2) - radius;
216
217 linePointsIds->Delete();
218 }
219 else
220 {
221 value = sqrt(dist2);
222 }
223
224 return value;
225}

◆ EvaluateFunction() [2/2]

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

Evaluate polyball.

Definition at line 54 of file vtkvmtkPolyBallLine2.h.

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

◆ EvaluateGradient()

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

Evaluate polyball gradient.

Definition at line 227 of file vtkvmtkPolyBallLine2.cxx.

228{
229 vtkWarningMacro("Poly ball gradient computation not yet implemented!");
230 // TODO
231}

◆ SetInput()

void vtkvmtkPolyBallLine2::SetInput ( vtkPolyData * inp)
virtual

Set / get input poly data.

Definition at line 92 of file vtkvmtkPolyBallLine2.cxx.

93{
94 if (this->LocalInput == this->Input)
95 {
96 this->LocalInput = NULL;
97 }
98 //The locator needs to be rebuilt
99 this->ShouldBuildLocator = true;
100 vtkSetObjectBodyMacro(Input,vtkPolyData,inp);
101}

◆ GetInput()

virtual vtkPolyData * vtkvmtkPolyBallLine2::GetInput ( )
virtual

Set / get input poly data.

◆ SetInputData()

void vtkvmtkPolyBallLine2::SetInputData ( vtkPolyData * input)
inline

Set / get input poly data.

Definition at line 69 of file vtkvmtkPolyBallLine2.h.

69{ SetInput(input); }
virtual void SetInput(vtkPolyData *inp)

◆ GetInputData()

vtkPolyData * vtkvmtkPolyBallLine2::GetInputData ( )
inline

Set / get input poly data.

Definition at line 70 of file vtkvmtkPolyBallLine2.h.

70{ return GetInput(); }
virtual vtkPolyData * GetInput()

◆ SetInputCellIds()

void vtkvmtkPolyBallLine2::SetInputCellIds ( vtkIdList * cellIds)
virtual

Set / get input cell ids used for the function.

Definition at line 103 of file vtkvmtkPolyBallLine2.cxx.

104{
105 //The locator needs to be rebuilt
106 this->ShouldBuildLocator = true;
107 vtkSetObjectBodyMacro(InputCellIds,vtkIdList,cellIds);
108}

◆ GetInputCellIds()

virtual vtkIdList * vtkvmtkPolyBallLine2::GetInputCellIds ( )
virtual

Set / get input cell ids used for the function.

◆ SetInputCellId()

void vtkvmtkPolyBallLine2::SetInputCellId ( vtkIdType cellId)
virtual

Set / get a single input cell id used for the function.

Definition at line 110 of file vtkvmtkPolyBallLine2.cxx.

111{
112 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting InputCellId to " << cellId);
113 if (this->InputCellId != cellId)
114 {
115 //The locator needs to be rebuilt
116 this->ShouldBuildLocator = true;
117 this->InputCellId = cellId;
118 this->Modified();
119 }
120}

◆ GetInputCellId()

virtual vtkIdType vtkvmtkPolyBallLine2::GetInputCellId ( )
virtual

Set / get a single input cell id used for the function.

◆ SetPolyBallRadiusArrayName()

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

Set / get poly ball radius array name. Commonly named "MaximumInscribedSphereRadius".

◆ GetPolyBallRadiusArrayName()

virtual char * vtkvmtkPolyBallLine2::GetPolyBallRadiusArrayName ( )
virtual

Set / get poly ball radius array name. Commonly named "MaximumInscribedSphereRadius".

◆ SetUseRadiusInformation()

virtual void vtkvmtkPolyBallLine2::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. Default: on.

◆ GetUseRadiusInformation()

virtual int vtkvmtkPolyBallLine2::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. Default: on.

◆ UseRadiusInformationOn()

virtual void vtkvmtkPolyBallLine2::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. Default: on.

◆ UseRadiusInformationOff()

virtual void vtkvmtkPolyBallLine2::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. Default: on.

◆ ComplexDot()

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

Minkowski-style inner product of two 4-vectors (x,y,z,r), computed as x[0]*y[0] + x[1]*y[1] + x[2]*y[2] - x[3]*y[3]. Used for sphere/power- distance calculations where the fourth component represents a radius.

Definition at line 121 of file vtkvmtkPolyBallLine2.cxx.

122{
123 return x[0]*y[0] + x[1]*y[1] + x[2]*y[2] - x[3]*y[3];
124}

◆ BuildLocator()

void vtkvmtkPolyBallLine2::BuildLocator ( )
protected

Definition at line 239 of file vtkvmtkPolyBallLine2.cxx.

240{
241 if (!this->Input)
242 {
243 vtkErrorMacro(<<"No Input specified!");
244 return;
245 }
246
247 if (this->Input->GetNumberOfPoints()==0)
248 {
249 vtkWarningMacro(<<"Empty Input specified!");
250 return;
251 }
252
253 this->LocatorMTime = this->Input->GetMTime();
254
255 if (this->LocalInput && (this->LocalInput != this->Input))
256 {
257 this->LocalInput->Delete();
258 }
259
260 //If only part of the cells are used, copy these cells to LocalInput
261 if (this->InputCellIds || this->InputCellId)
262 {
263 this->LocalInput = vtkPolyData::New();
264 this->LocalInput->DeepCopy(this->Input);
265
266 if (this->InputCellIds)
267 {
268 //Remove the cells whose id is not the list
269 for (int i=0; i<this->LocalInput->GetNumberOfCells(); i++)
270 {
271 if (!this->InputCellIds->IsId(i))
272 {
273 this->LocalInput->DeleteCell(i);
274 }
275 }
276 }
277
278 else if (this->InputCellId != -1)
279 {
280 //Remove the cells whose is not InputCellId
281 for (int i=0; i<this->LocalInput->GetNumberOfCells(); i++)
282 {
283 if (i!=this->InputCellId)
284 {
285 this->LocalInput->DeleteCell(i);
286 }
287 }
288 }
289 }
290 else
291 {
292 this->LocalInput = this->Input;
293 }
294
295 //Triangulate the input for improved performance
296 this->Triangulator->SetInputData(this->LocalInput);
297 this->Triangulator->Update();
298 this->TriangulatedInput = this->Triangulator->GetOutput();
299
300 //Build the locator
301 this->Locator->SetDataSet(this->TriangulatedInput);
302 this->Locator->BuildLocator();
303
304 this->ShouldBuildLocator = false;
305}

Member Data Documentation

◆ Input

vtkPolyData* vtkvmtkPolyBallLine2::Input
protected

Definition at line 121 of file vtkvmtkPolyBallLine2.h.

◆ InputCellIds

vtkIdList* vtkvmtkPolyBallLine2::InputCellIds
protected

Definition at line 122 of file vtkvmtkPolyBallLine2.h.

◆ InputCellId

vtkIdType vtkvmtkPolyBallLine2::InputCellId
protected

Definition at line 123 of file vtkvmtkPolyBallLine2.h.

◆ PolyBallRadiusArrayName

char* vtkvmtkPolyBallLine2::PolyBallRadiusArrayName
protected

Definition at line 125 of file vtkvmtkPolyBallLine2.h.

◆ LastPolyBallCellId

vtkIdType vtkvmtkPolyBallLine2::LastPolyBallCellId
protected

Definition at line 126 of file vtkvmtkPolyBallLine2.h.

◆ LastPolyBallCellSubId

vtkIdType vtkvmtkPolyBallLine2::LastPolyBallCellSubId
protected

Definition at line 127 of file vtkvmtkPolyBallLine2.h.

◆ LastPolyBallCellPCoord

double vtkvmtkPolyBallLine2::LastPolyBallCellPCoord
protected

Definition at line 128 of file vtkvmtkPolyBallLine2.h.

◆ LastPolyBallCenter

double vtkvmtkPolyBallLine2::LastPolyBallCenter[3]
protected

Definition at line 129 of file vtkvmtkPolyBallLine2.h.

◆ LastPolyBallCenterRadius

double vtkvmtkPolyBallLine2::LastPolyBallCenterRadius
protected

Definition at line 130 of file vtkvmtkPolyBallLine2.h.

◆ UseRadiusInformation

int vtkvmtkPolyBallLine2::UseRadiusInformation
protected

Definition at line 132 of file vtkvmtkPolyBallLine2.h.

◆ Triangulator

vtkTriangleFilter* vtkvmtkPolyBallLine2::Triangulator
protected

Definition at line 135 of file vtkvmtkPolyBallLine2.h.

◆ Locator

vtkCellLocator* vtkvmtkPolyBallLine2::Locator
protected

Definition at line 138 of file vtkvmtkPolyBallLine2.h.

◆ LocalInput

vtkPolyData* vtkvmtkPolyBallLine2::LocalInput
protected

Definition at line 141 of file vtkvmtkPolyBallLine2.h.

◆ TriangulatedInput

vtkPolyData* vtkvmtkPolyBallLine2::TriangulatedInput
protected

Definition at line 144 of file vtkvmtkPolyBallLine2.h.

◆ ShouldBuildLocator

bool vtkvmtkPolyBallLine2::ShouldBuildLocator
protected

Definition at line 147 of file vtkvmtkPolyBallLine2.h.

◆ LocatorMTime

unsigned long vtkvmtkPolyBallLine2::LocatorMTime
protected

Definition at line 150 of file vtkvmtkPolyBallLine2.h.


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