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

Implements vtkImplicitFunction to evaluate the minimum sphere function from a collection of points with attached sphere radii as point data. More...

#include <vtkvmtkPolyBall.h>

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

Public Types

typedef vtkImplicitFunction Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyBall * 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 *)
virtual vtkPolyData * GetInput ()
void SetInputData (vtkPolyData *input)
vtkPolyData * GetInputData ()
virtual void SetPolyBallRadiusArrayName (const char *)
virtual char * GetPolyBallRadiusArrayName ()
virtual vtkIdType GetLastPolyBallCenterId ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

vtkPolyData * Input
char * PolyBallRadiusArrayName
vtkIdType LastPolyBallCenterId

Detailed Description

Implements vtkImplicitFunction to evaluate the minimum sphere function from a collection of points with attached sphere radii as point data.

Implicit functions are real valued functions defined in 3D space, w = F(x,y,z). Two primitive operations are required: the ability to evaluate the function, and the function gradient at a given point. The implicit function divides space into three regions: on the surface (F(x,y,z)=w), outside of the surface (F(x,y,z)>c), and inside the surface (F(x,y,z)<c). (When c is zero, positive values are outside, negative values are inside, and zero is on the surface. Note also that the function gradient points from inside to outside.)

A polyball is just an implicit function which takes a data set containing a bunch of points in R^3 with sphere radii defined on top of them and evaluates the minimum sphere function across the entire collection for a particular point. The sphere function is zero at the sphere surface, negative inside the sphere, and positive outside the sphere. This is implemented as a brute force calculation; in order to find the minimum sphere function across the collection, the sphere function is evaluated at the query point for every point in the input data set.

Definition at line 35 of file vtkvmtkPolyBall.h.

Member Typedef Documentation

◆ Superclass

typedef vtkImplicitFunction vtkvmtkPolyBall::Superclass

Definition at line 38 of file vtkvmtkPolyBall.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyBall()

vtkvmtkPolyBall::vtkvmtkPolyBall ( )
protected

Definition at line 29 of file vtkvmtkPolyBall.cxx.

30{
31 this->Input = NULL;
32 this->PolyBallRadiusArrayName = NULL;
33 this->LastPolyBallCenterId = -1;
34}
vtkPolyData * Input
char * PolyBallRadiusArrayName
vtkIdType LastPolyBallCenterId

◆ ~vtkvmtkPolyBall()

vtkvmtkPolyBall::~vtkvmtkPolyBall ( )
protected

Definition at line 36 of file vtkvmtkPolyBall.cxx.

37{
38 if (this->Input)
39 {
40 this->Input->Delete();
41 this->Input = NULL;
42 }
43
45 {
46 delete[] this->PolyBallRadiusArrayName;
47 this->PolyBallRadiusArrayName = NULL;
48 }
49}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyBall::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyBall * vtkvmtkPolyBall::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 113 of file vtkvmtkPolyBall.cxx.

114{
115 this->Superclass::PrintSelf(os,indent);
116
117}

◆ New()

vtkvmtkPolyBall * vtkvmtkPolyBall::New ( )
static

◆ EvaluateFunction() [1/2]

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

Evaluate polyball.

Definition at line 51 of file vtkvmtkPolyBall.cxx.

52{
53 double px[3], pr;
54 int i;
55 double sphereFunctionValue, minSphereFunctionValue;
56 vtkDataArray* polyballRadiusArray;
57
58 if (!this->Input)
59 {
60 vtkErrorMacro("No Input specified!");
61 return 0.0;
62 }
63
64 if (this->Input->GetNumberOfPoints()==0)
65 {
66 vtkWarningMacro("Empty Input specified!");
67 }
68
69 if (!this->PolyBallRadiusArrayName)
70 {
71 vtkErrorMacro("No PolyBallRadiusArrayName specified!");
72 return 0.0;
73 }
74
75 if (!this->Input->GetPointData()->GetArray(this->PolyBallRadiusArrayName))
76 {
77 vtkErrorMacro("PolyBallRadiusArray with name specified does not exist!");
78 return 0.0;
79 }
80
81 polyballRadiusArray = this->Input->GetPointData()->GetArray(this->PolyBallRadiusArrayName);
82 minSphereFunctionValue = VTK_VMTK_LARGE_DOUBLE;
83 for (i=0; i<this->Input->GetNumberOfPoints(); i++)
84 {
85 // this next line actually copies the xyz location of point i into px[3].
86 // luca reports that odd bug happened when only retrieving pointers.
87 this->Input->GetPoint(i,px);
88 pr = polyballRadiusArray->GetComponent(i,0);
89 // x, y, z -> location of query point in R3
90 // px, py, pz => location of point with sphere radius == pr
91 // f = ((x - px)^2 + (y - py)^2 + (z - pz)^2) - pr^2
92 sphereFunctionValue = ((x[0] - px[0]) * (x[0] - px[0]) + (x[1] - px[1]) * (x[1] - px[1]) + (x[2] - px[2]) * (x[2] - px[2])) - pr*pr;
93 if (sphereFunctionValue - minSphereFunctionValue < VTK_VMTK_DOUBLE_TOL)
94 {
95 minSphereFunctionValue = sphereFunctionValue;
96 this->LastPolyBallCenterId = i;
97 }
98 }
99
100 return minSphereFunctionValue;
101}
#define VTK_VMTK_DOUBLE_TOL
#define VTK_VMTK_LARGE_DOUBLE

◆ EvaluateFunction() [2/2]

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

Evaluate polyball.

Definition at line 48 of file vtkvmtkPolyBall.h.

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

◆ EvaluateGradient()

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

Evaluate polyball gradient.

Definition at line 103 of file vtkvmtkPolyBall.cxx.

104{
105 vtkWarningMacro("Poly ball gradient computation not implemented yet!");
106
107 // TODO
108 // n[0] = 2.0 * (x[0] - this->Center[0]);
109 // n[1] = 2.0 * (x[1] - this->Center[1]);
110 // n[2] = 2.0 * (x[2] - this->Center[2]);
111}

◆ SetInput()

virtual void vtkvmtkPolyBall::SetInput ( vtkPolyData * )
virtual

Set / get input poly data.

◆ GetInput()

virtual vtkPolyData * vtkvmtkPolyBall::GetInput ( )
virtual

Set / get input poly data.

◆ SetInputData()

void vtkvmtkPolyBall::SetInputData ( vtkPolyData * input)
inline

Set / get input poly data.

Definition at line 63 of file vtkvmtkPolyBall.h.

63{ SetInput(input); }
virtual void SetInput(vtkPolyData *)

◆ GetInputData()

vtkPolyData * vtkvmtkPolyBall::GetInputData ( )
inline

Set / get input poly data.

Definition at line 64 of file vtkvmtkPolyBall.h.

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

◆ SetPolyBallRadiusArrayName()

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

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

◆ GetPolyBallRadiusArrayName()

virtual char * vtkvmtkPolyBall::GetPolyBallRadiusArrayName ( )
virtual

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

◆ GetLastPolyBallCenterId()

virtual vtkIdType vtkvmtkPolyBall::GetLastPolyBallCenterId ( )
virtual

Get the id of the last nearest poly ball center.

Member Data Documentation

◆ Input

vtkPolyData* vtkvmtkPolyBall::Input
protected

Definition at line 87 of file vtkvmtkPolyBall.h.

◆ PolyBallRadiusArrayName

char* vtkvmtkPolyBall::PolyBallRadiusArrayName
protected

Definition at line 88 of file vtkvmtkPolyBall.h.

◆ LastPolyBallCenterId

vtkIdType vtkvmtkPolyBall::LastPolyBallCenterId
protected

Definition at line 89 of file vtkvmtkPolyBall.h.


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