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

Create an image where a polyball or polyball line is evaluated as a function. More...

#include <vtkvmtkPolyBallModeller.h>

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

Public Types

typedef vtkImageAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyBallModeller * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual int * GetSampleDimensions ()
virtual void GetSampleDimensions (int data[3])
virtual void SetSampleDimensions (int data[])
virtual void SetModelBounds (double data[])
virtual double * GetModelBounds ()
virtual void GetModelBounds (double data[6])
virtual void SetReferenceImage (vtkImageData *)
virtual vtkImageData * GetReferenceImage ()
virtual void SetRadiusArrayName (const char *)
virtual char * GetRadiusArrayName ()
virtual void SetUsePolyBallLine (int)
virtual int GetUsePolyBallLine ()
virtual void UsePolyBallLineOn ()
virtual void UsePolyBallLineOff ()
virtual void SetNegateFunction (int)
virtual int GetNegateFunction ()
virtual void NegateFunctionOn ()
virtual void NegateFunctionOff ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyBallModeller ()
 ~vtkvmtkPolyBallModeller ()
int FillInputPortInformation (int, vtkInformation *info) override
virtual int RequestInformation (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

int SampleDimensions [3]
double ModelBounds [6]
char * RadiusArrayName
int UsePolyBallLine
int NegateFunction
vtkImageData * ReferenceImage

Detailed Description

Create an image where a polyball or polyball line is evaluated as a function.

This creates an image which might look similar to a level set (0 at surface boundaries negative inside, positive outside), but it much more powerful. It is a finite approximation of the entire implicit sphere function solution within the bounds of the image volume.

Rasterizes the vtkvmtkPolyBallLine (or, if UsePolyBallLine is off, vtkvmtkPolyBall) tube function of the input centerlines into a regular image, sampled on a SampleDimensions grid over ModelBounds. This is the filter behind the vmtkcenterlinemodeller pype script; the resulting image is typically thresholded at zero to reconstruct a tubular surface, or used as a smooth distance-like field for other level-set operations.

See also
vtkvmtkPolyBallLine, vtkvmtkPolyBall

Definition at line 41 of file vtkvmtkPolyBallModeller.h.

Member Typedef Documentation

◆ Superclass

typedef vtkImageAlgorithm vtkvmtkPolyBallModeller::Superclass

Definition at line 44 of file vtkvmtkPolyBallModeller.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyBallModeller()

vtkvmtkPolyBallModeller::vtkvmtkPolyBallModeller ( )
protected

Definition at line 40 of file vtkvmtkPolyBallModeller.cxx.

41{
42 this->ReferenceImage = NULL;
43 this->ModelBounds[0] = 0.0;
44 this->ModelBounds[1] = 0.0;
45 this->ModelBounds[2] = 0.0;
46 this->ModelBounds[3] = 0.0;
47 this->ModelBounds[4] = 0.0;
48 this->ModelBounds[5] = 0.0;
49
50 this->SampleDimensions[0] = 50;
51 this->SampleDimensions[1] = 50;
52 this->SampleDimensions[2] = 50;
53
54 this->RadiusArrayName = NULL;
55
56 this->UsePolyBallLine = 0;
57 this->NegateFunction = 0;
58}

◆ ~vtkvmtkPolyBallModeller()

vtkvmtkPolyBallModeller::~vtkvmtkPolyBallModeller ( )
protected

Definition at line 60 of file vtkvmtkPolyBallModeller.cxx.

61{
62 if (this->ReferenceImage)
63 {
64 this->ReferenceImage->Delete();
65 this->ReferenceImage = NULL;
66 }
67
68 if (this->RadiusArrayName)
69 {
70 delete[] this->RadiusArrayName;
71 this->RadiusArrayName = NULL;
72 }
73}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyBallModeller::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyBallModeller * vtkvmtkPolyBallModeller::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 316 of file vtkvmtkPolyBallModeller.cxx.

317{
318 this->Superclass::PrintSelf(os,indent);
319
320 os << indent << "Sample Dimensions: (" << this->SampleDimensions[0] << ", "
321 << this->SampleDimensions[1] << ", "
322 << this->SampleDimensions[2] << ")\n";
323
324 os << indent << "ModelBounds: \n";
325 os << indent << " Xmin,Xmax: (" << this->ModelBounds[0] << ", " << this->ModelBounds[1] << ")\n";
326 os << indent << " Ymin,Ymax: (" << this->ModelBounds[2] << ", " << this->ModelBounds[3] << ")\n";
327 os << indent << " Zmin,Zmax: (" << this->ModelBounds[4] << ", " << this->ModelBounds[5] << ")\n";
328
329}

◆ New()

vtkvmtkPolyBallModeller * vtkvmtkPolyBallModeller::New ( )
static

◆ GetSampleDimensions() [1/2]

virtual int * vtkvmtkPolyBallModeller::GetSampleDimensions ( )
virtual

Specify i-j-k dimensions on which to sample polyball function.

◆ GetSampleDimensions() [2/2]

virtual void vtkvmtkPolyBallModeller::GetSampleDimensions ( int data[3])
virtual

Specify i-j-k dimensions on which to sample polyball function.

◆ SetSampleDimensions()

virtual void vtkvmtkPolyBallModeller::SetSampleDimensions ( int data[])
virtual

Specify i-j-k dimensions on which to sample polyball function.

◆ SetModelBounds()

virtual void vtkvmtkPolyBallModeller::SetModelBounds ( double data[])
virtual

Specify the position in space to perform the sampling.

◆ GetModelBounds() [1/2]

virtual double * vtkvmtkPolyBallModeller::GetModelBounds ( )
virtual

Specify the position in space to perform the sampling.

◆ GetModelBounds() [2/2]

virtual void vtkvmtkPolyBallModeller::GetModelBounds ( double data[6])
virtual

Specify the position in space to perform the sampling.

◆ SetReferenceImage()

virtual void vtkvmtkPolyBallModeller::SetReferenceImage ( vtkImageData * )
virtual

Set/Get an optional reference image: when set, its extent/spacing/origin are used in place of SampleDimensions/ModelBounds to define the output image geometry (e.g. to match an existing volume).

◆ GetReferenceImage()

virtual vtkImageData * vtkvmtkPolyBallModeller::GetReferenceImage ( )
virtual

Set/Get an optional reference image: when set, its extent/spacing/origin are used in place of SampleDimensions/ModelBounds to define the output image geometry (e.g. to match an existing volume).

◆ SetRadiusArrayName()

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

Set/Get the name of the point data array of the input centerlines holding the sphere radius at each point. Required input. Commonly named "MaximumInscribedSphereRadius".

◆ GetRadiusArrayName()

virtual char * vtkvmtkPolyBallModeller::GetRadiusArrayName ( )
virtual

Set/Get the name of the point data array of the input centerlines holding the sphere radius at each point. Required input. Commonly named "MaximumInscribedSphereRadius".

◆ SetUsePolyBallLine()

virtual void vtkvmtkPolyBallModeller::SetUsePolyBallLine ( int )
virtual

Toggle whether the tube function is evaluated with vtkvmtkPolyBallLine (continuous, linearly interpolated tubular envelope; default: on) or vtkvmtkPolyBall (discrete union of spheres, one per input point, when off).

◆ GetUsePolyBallLine()

virtual int vtkvmtkPolyBallModeller::GetUsePolyBallLine ( )
virtual

Toggle whether the tube function is evaluated with vtkvmtkPolyBallLine (continuous, linearly interpolated tubular envelope; default: on) or vtkvmtkPolyBall (discrete union of spheres, one per input point, when off).

◆ UsePolyBallLineOn()

virtual void vtkvmtkPolyBallModeller::UsePolyBallLineOn ( )
virtual

Toggle whether the tube function is evaluated with vtkvmtkPolyBallLine (continuous, linearly interpolated tubular envelope; default: on) or vtkvmtkPolyBall (discrete union of spheres, one per input point, when off).

◆ UsePolyBallLineOff()

virtual void vtkvmtkPolyBallModeller::UsePolyBallLineOff ( )
virtual

Toggle whether the tube function is evaluated with vtkvmtkPolyBallLine (continuous, linearly interpolated tubular envelope; default: on) or vtkvmtkPolyBall (discrete union of spheres, one per input point, when off).

◆ SetNegateFunction()

virtual void vtkvmtkPolyBallModeller::SetNegateFunction ( int )
virtual

Toggle negating the sampled function values (multiplying by -1) before writing them to the output image. Default: off.

◆ GetNegateFunction()

virtual int vtkvmtkPolyBallModeller::GetNegateFunction ( )
virtual

Toggle negating the sampled function values (multiplying by -1) before writing them to the output image. Default: off.

◆ NegateFunctionOn()

virtual void vtkvmtkPolyBallModeller::NegateFunctionOn ( )
virtual

Toggle negating the sampled function values (multiplying by -1) before writing them to the output image. Default: off.

◆ NegateFunctionOff()

virtual void vtkvmtkPolyBallModeller::NegateFunctionOff ( )
virtual

Toggle negating the sampled function values (multiplying by -1) before writing them to the output image. Default: off.

◆ FillInputPortInformation()

int vtkvmtkPolyBallModeller::FillInputPortInformation ( int ,
vtkInformation * info )
overrideprotected

Definition at line 157 of file vtkvmtkPolyBallModeller.cxx.

158{
159 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
160 return 1;
161}

◆ RequestInformation()

int vtkvmtkPolyBallModeller::RequestInformation ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 75 of file vtkvmtkPolyBallModeller.cxx.

79{
80 double spacing[3], origin[3];
81
82 vtkInformation* outInfo = outputVector->GetInformationObject(0);
83
84 vtkPolyData* input = vtkPolyData::SafeDownCast(this->GetInput());
85
86 if (this->RadiusArrayName == NULL)
87 {
88 vtkErrorMacro(<<"Error: RadiusArrayName not specified!");
89 return 1;
90 }
91
92 vtkDataArray* radiusArray = input->GetPointData()->GetArray(this->RadiusArrayName);
93 if (radiusArray == NULL)
94 {
95 vtkErrorMacro(<<"Error: RadiusArray with name specified does not exist!");
96 return 1;
97 }
98
99 int extent[6];
100
101 if (this->ReferenceImage)
102 {
103 this->ReferenceImage->GetOrigin(origin);
104 this->ReferenceImage->GetSpacing(spacing);
105 this->ReferenceImage->GetDimensions(this->SampleDimensions);
106 this->ReferenceImage->GetExtent(extent);
107 }
108 else
109 {
110 double maxRadius = radiusArray->GetRange()[1];
111
112 if ((this->ModelBounds[0] >= this->ModelBounds[1]) || (this->ModelBounds[2] >= this->ModelBounds[3]) || (this->ModelBounds[4] >= this->ModelBounds[5]))
113 {
114 double* bounds = input->GetBounds();
115 double maxDist = 2.0 * maxRadius;
116
117 int i;
118 for (i=0; i<3; i++)
119 {
120 this->ModelBounds[2*i] = bounds[2*i] - maxDist;
121 this->ModelBounds[2*i+1] = bounds[2*i+1] + maxDist;
122 }
123 }
124
125 int i;
126 for (i=0; i<3; i++)
127 {
128 origin[i] = this->ModelBounds[2*i];
129 if (this->SampleDimensions[i] <= 1)
130 {
131 spacing[i] = 1.0;
132 }
133 else
134 {
135 spacing[i] = (this->ModelBounds[2*i+1] - this->ModelBounds[2*i]) / (this->SampleDimensions[i] - 1);
136 }
137 }
138
139 extent[0] = 0;
140 extent[1] = this->SampleDimensions[0]-1;
141 extent[2] = 0;
142 extent[3] = this->SampleDimensions[1]-1;
143 extent[4] = 0;
144 extent[5] = this->SampleDimensions[2]-1;
145 }
146
147 outInfo->Set(vtkDataObject::ORIGIN(),origin,3);
148 outInfo->Set(vtkDataObject::SPACING(),spacing,3);
149
150 vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_DOUBLE, 1);
151 //outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),0, this->SampleDimensions[0]-1, 0, this->SampleDimensions[1]-1, 0, this->SampleDimensions[2]-1);
152 outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]);
153
154 return 1;
155}

◆ RequestData()

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

Definition at line 163 of file vtkvmtkPolyBallModeller.cxx.

167{
168 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
169 vtkInformation *outInfo = outputVector->GetInformationObject(0);
170
171 vtkPolyData *input = vtkPolyData::SafeDownCast(
172 inInfo->Get(vtkDataObject::DATA_OBJECT()));
173 vtkImageData *output = vtkImageData::SafeDownCast(
174 outInfo->Get(vtkDataObject::DATA_OBJECT()));
175
176 if (this->RadiusArrayName == NULL)
177 {
178 vtkErrorMacro(<<"Error: RadiusArrayName not specified!");
179 return 1;
180 }
181
182 if (input->GetPointData()->GetArray(this->RadiusArrayName) == NULL)
183 {
184 vtkErrorMacro(<<"Error: RadiusArray with name specified does not exist!");
185 return 1;
186 }
187
188 output->SetExtent(outInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
189 output->AllocateScalars(outInfo);
190
191 vtkDoubleArray *functionArray = vtkDoubleArray::SafeDownCast(output->GetPointData()->GetScalars());
192 functionArray->SetName(this->RadiusArrayName);
193
194 int numberOfOutputPoints = output->GetNumberOfPoints();
195
196#if 0
197 vtkImplicitFunction* function;
198 if (!this->UsePolyBallLine)
199 {
200 vtkvmtkPolyBall* polyBall = vtkvmtkPolyBall::New();
201 polyBall->SetInput(input);
203 function = polyBall;
204 }
205 else
206 {
207 vtkvmtkPolyBallLine* polyBall = vtkvmtkPolyBallLine::New();
208 polyBall->SetInput(input);
210 function = polyBall;
211 }
212
213 double point[3];
214 int i;
215 for (i=0; i<numberOfOutputPoints; i++)
216 {
217 output->GetPoint(i,point);
218 double polyBallFunction = function->EvaluateFunction(point);
219 functionArray->SetComponent(i,0,polyBallFunction);
220 }
221
222 function->Delete();
223#endif
224
225 if (!this->UsePolyBallLine)
226 {
227 functionArray->FillComponent(0,VTK_VMTK_LARGE_DOUBLE);
228 vtkDoubleArray* radiusArray = vtkDoubleArray::SafeDownCast(input->GetPointData()->GetArray(this->RadiusArrayName));
229 int numberOfInputPoints = input->GetNumberOfPoints();
230 int extent[6];
231 double x[3], p[3], r;
232 double boundingBox0[3], boundingBox1[3];
233 int ijk0[3], ijk1[3], ijk[3];
234 int ijkExtent[6];
235 double pcoords[3];
236 int inBounds0, inBounds1;
237 double radiusFactor = 2.0;
238 output->GetExtent(extent);
239 double sphereFunctionValue, currentSphereFunctionValue;
240 int n;
241 int i, j, k;
242 vtkIdType outputId;
243 for (n=0; n<numberOfInputPoints; n++)
244 {
245 input->GetPoint(n,p);
246 r = radiusArray->GetValue(n);
247 boundingBox0[0] = p[0] - radiusFactor * r;
248 boundingBox0[1] = p[1] - radiusFactor * r;
249 boundingBox0[2] = p[2] - radiusFactor * r;
250 boundingBox1[0] = p[0] + radiusFactor * r;
251 boundingBox1[1] = p[1] + radiusFactor * r;
252 boundingBox1[2] = p[2] + radiusFactor * r;
253 inBounds0 = output->ComputeStructuredCoordinates(boundingBox0,ijk0,pcoords);
254 inBounds1 = output->ComputeStructuredCoordinates(boundingBox1,ijk1,pcoords);
255 if (!inBounds0 && !inBounds1)
256 {
257 continue;
258 }
259 ijkExtent[0] = ijk0[0] < extent[0] ? extent[0] : ijk0[0];
260 ijkExtent[1] = ijk1[0] > extent[1] ? extent[1] : ijk1[0];
261 ijkExtent[2] = ijk0[1] < extent[2] ? extent[2] : ijk0[1];
262 ijkExtent[3] = ijk1[1] > extent[3] ? extent[3] : ijk1[1];
263 ijkExtent[4] = ijk0[2] < extent[4] ? extent[4] : ijk0[2];
264 ijkExtent[5] = ijk1[2] > extent[5] ? extent[5] : ijk1[2];
265 for (k=ijkExtent[4]; k<=ijkExtent[5]; k++)
266 {
267 for (j=ijkExtent[2]; j<=ijkExtent[3]; j++)
268 {
269 for (i=ijkExtent[0]; i<=ijkExtent[1]; i++)
270 {
271 ijk[0] = i;
272 ijk[1] = j;
273 ijk[2] = k;
274 outputId = output->ComputePointId(ijk);
275 output->GetPoint(outputId,x);
276 sphereFunctionValue = ((x[0] - p[0]) * (x[0] - p[0]) + (x[1] - p[1]) * (x[1] - p[1]) + (x[2] - p[2]) * (x[2] - p[2])) - r * r;
277 currentSphereFunctionValue = functionArray->GetComponent(outputId,0);
278 if (sphereFunctionValue < currentSphereFunctionValue)
279 {
280 functionArray->SetComponent(outputId,0,sphereFunctionValue);
281 }
282 }
283 }
284 }
285 }
286 }
287 else
288 {
289 vtkvmtkPolyBallLine* polyBallLine = vtkvmtkPolyBallLine::New();
290 polyBallLine->SetInput(input);
291 polyBallLine->SetPolyBallRadiusArrayName(this->RadiusArrayName);
292 double point[3];
293 int i;
294 for (i=0; i<numberOfOutputPoints; i++)
295 {
296 output->GetPoint(i,point);
297 double polyBallLineValue = polyBallLine->EvaluateFunction(point);
298 functionArray->SetComponent(i,0,polyBallLineValue);
299 }
300 }
301
302 if (this->NegateFunction)
303 {
304 int i;
305 for (i=0; i<numberOfOutputPoints; i++)
306 {
307 double functionValue = functionArray->GetComponent(i,0);
308 functionValue *= -1.0;
309 functionArray->SetComponent(i,0,functionValue);
310 }
311 }
312
313 return 1;
314}
virtual void SetInput(vtkPolyData *)
virtual void SetPolyBallRadiusArrayName(const char *)
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
virtual void SetPolyBallRadiusArrayName(const char *)
static vtkvmtkPolyBall * New()
virtual void SetInput(vtkPolyData *)
#define VTK_VMTK_LARGE_DOUBLE

Member Data Documentation

◆ SampleDimensions

int vtkvmtkPolyBallModeller::SampleDimensions[3]
protected

Definition at line 115 of file vtkvmtkPolyBallModeller.h.

◆ ModelBounds

double vtkvmtkPolyBallModeller::ModelBounds[6]
protected

Definition at line 116 of file vtkvmtkPolyBallModeller.h.

◆ RadiusArrayName

char* vtkvmtkPolyBallModeller::RadiusArrayName
protected

Definition at line 118 of file vtkvmtkPolyBallModeller.h.

◆ UsePolyBallLine

int vtkvmtkPolyBallModeller::UsePolyBallLine
protected

Definition at line 120 of file vtkvmtkPolyBallModeller.h.

◆ NegateFunction

int vtkvmtkPolyBallModeller::NegateFunction
protected

Definition at line 122 of file vtkvmtkPolyBallModeller.h.

◆ ReferenceImage

vtkImageData* vtkvmtkPolyBallModeller::ReferenceImage
protected

Definition at line 124 of file vtkvmtkPolyBallModeller.h.


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