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

Compute, for each point of a surface, the minimum distance to the surface of a set of spheres. More...

#include <vtkvmtkPolyDataDistanceToSpheres.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataDistanceToSpheres * NewInstance () const
virtual void SetSpheres (vtkPolyData *)
virtual vtkPolyData * GetSpheres ()
virtual void SetDistanceOffset (double)
virtual double GetDistanceOffset ()
virtual void SetDistanceScale (double)
virtual double GetDistanceScale ()
virtual void SetMinDistance (double)
virtual double GetMinDistance ()
virtual void SetMaxDistance (double)
virtual double GetMaxDistance ()
virtual void SetDistanceToSpheresArrayName (const char *)
virtual char * GetDistanceToSpheresArrayName ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataDistanceToSpheres ()
 ~vtkvmtkPolyDataDistanceToSpheres ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

char * DistanceToSpheresArrayName
vtkPolyData * Spheres
double DistanceOffset
double DistanceScale
double MinDistance
double MaxDistance

Detailed Description

Compute, for each point of a surface, the minimum distance to the surface of a set of spheres.

Spheres is a poly data whose points define sphere centers and whose point scalars (if present) define the corresponding sphere radii (radius 0 if no scalars are present, reducing spheres to points). For each input point, vtkvmtkPolyDataDistanceToSpheres computes the distance to the nearest sphere surface (Euclidean distance to the center minus the radius, clamped to be non-negative), transforms it as (DistanceOffset + DistanceScale * rawDistance) clamped between MinDistance and MaxDistance (a non-positive MaxDistance, the default, means unbounded), and writes the minimum such value over all spheres to a point data array named DistanceToSpheresArrayName. If that array already exists on the input, its values are combined with the newly computed ones by taking the minimum, so the filter can be chained to progressively refine a distance field from several sphere sets.

Definition at line 51 of file vtkvmtkPolyDataDistanceToSpheres.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataDistanceToSpheres::Superclass

Definition at line 55 of file vtkvmtkPolyDataDistanceToSpheres.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataDistanceToSpheres()

vtkvmtkPolyDataDistanceToSpheres::vtkvmtkPolyDataDistanceToSpheres ( )
protected

◆ ~vtkvmtkPolyDataDistanceToSpheres()

vtkvmtkPolyDataDistanceToSpheres::~vtkvmtkPolyDataDistanceToSpheres ( )
protected

Definition at line 53 of file vtkvmtkPolyDataDistanceToSpheres.cxx.

54{
56 {
57 delete[] this->DistanceToSpheresArrayName;
58 this->DistanceToSpheresArrayName = NULL;
59 }
60
61 if (this->Spheres)
62 {
63 this->Spheres->Delete();
64 this->Spheres = NULL;
65 }
66}

Member Function Documentation

◆ New()

vtkvmtkPolyDataDistanceToSpheres * vtkvmtkPolyDataDistanceToSpheres::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataDistanceToSpheres::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataDistanceToSpheres * vtkvmtkPolyDataDistanceToSpheres::NewInstance ( ) const

◆ SetSpheres()

virtual void vtkvmtkPolyDataDistanceToSpheres::SetSpheres ( vtkPolyData * )
virtual

Set/get the poly data whose points and (optional) point scalars define the sphere centers and radii to compute the distance to.

◆ GetSpheres()

virtual vtkPolyData * vtkvmtkPolyDataDistanceToSpheres::GetSpheres ( )
virtual

Set/get the poly data whose points and (optional) point scalars define the sphere centers and radii to compute the distance to.

◆ SetDistanceOffset()

virtual void vtkvmtkPolyDataDistanceToSpheres::SetDistanceOffset ( double )
virtual

Set/get the constant added to the raw distance-to-sphere-surface value before scaling and clamping. Default: 0.

◆ GetDistanceOffset()

virtual double vtkvmtkPolyDataDistanceToSpheres::GetDistanceOffset ( )
virtual

Set/get the constant added to the raw distance-to-sphere-surface value before scaling and clamping. Default: 0.

◆ SetDistanceScale()

virtual void vtkvmtkPolyDataDistanceToSpheres::SetDistanceScale ( double )
virtual

Set/get the factor the raw distance-to-sphere-surface value is multiplied by (after adding DistanceOffset). Default: 1.

◆ GetDistanceScale()

virtual double vtkvmtkPolyDataDistanceToSpheres::GetDistanceScale ( )
virtual

Set/get the factor the raw distance-to-sphere-surface value is multiplied by (after adding DistanceOffset). Default: 1.

◆ SetMinDistance()

virtual void vtkvmtkPolyDataDistanceToSpheres::SetMinDistance ( double )
virtual

Set/get the lower bound the (offset and scaled) distance is clamped to. Default: 0.

◆ GetMinDistance()

virtual double vtkvmtkPolyDataDistanceToSpheres::GetMinDistance ( )
virtual

Set/get the lower bound the (offset and scaled) distance is clamped to. Default: 0.

◆ SetMaxDistance()

virtual void vtkvmtkPolyDataDistanceToSpheres::SetMaxDistance ( double )
virtual

Set/get the upper bound the (offset and scaled) distance is clamped to. A non-positive value (the default, -1) means unbounded.

◆ GetMaxDistance()

virtual double vtkvmtkPolyDataDistanceToSpheres::GetMaxDistance ( )
virtual

Set/get the upper bound the (offset and scaled) distance is clamped to. A non-positive value (the default, -1) means unbounded.

◆ SetDistanceToSpheresArrayName()

virtual void vtkvmtkPolyDataDistanceToSpheres::SetDistanceToSpheresArrayName ( const char * )
virtual

Set/get the name of the output point data array holding the computed distance values. If an array by this name already exists on the input, its values are combined with the newly computed ones by taking the minimum. Commonly named "DistanceToSpheres".

◆ GetDistanceToSpheresArrayName()

virtual char * vtkvmtkPolyDataDistanceToSpheres::GetDistanceToSpheresArrayName ( )
virtual

Set/get the name of the output point data array holding the computed distance values. If an array by this name already exists on the input, its values are combined with the newly computed ones by taking the minimum. Commonly named "DistanceToSpheres".

◆ RequestData()

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

Definition at line 68 of file vtkvmtkPolyDataDistanceToSpheres.cxx.

72{
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
75
76 vtkPolyData *input = vtkPolyData::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkPolyData *output = vtkPolyData::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
80
82 {
83 vtkErrorMacro(<<"DistanceToSpheresArrayName not set.");
84 return 1;
85 }
86
87 if (!this->Spheres)
88 {
89 vtkErrorMacro(<<"Spheres not set");
90 return 1;
91 }
92
93 int numberOfInputPoints = input->GetNumberOfPoints();
94
95 output->DeepCopy(input);
96
97
98 vtkDataArray* distanceToSpheresArray = output->GetPointData()->GetArray(this->DistanceToSpheresArrayName);
99
100 bool createArray = !distanceToSpheresArray;
101
102 if (createArray)
103 {
104 distanceToSpheresArray = vtkDoubleArray::New();
105 distanceToSpheresArray->SetName(this->DistanceToSpheresArrayName);
106 distanceToSpheresArray->SetNumberOfComponents(1);
107 distanceToSpheresArray->SetNumberOfTuples(numberOfInputPoints);
108 distanceToSpheresArray->FillComponent(0, VTK_VMTK_LARGE_DOUBLE);
109
110 output->GetPointData()->AddArray(distanceToSpheresArray);
111 }
112
113 int numberOfSpheres = this->Spheres->GetNumberOfPoints();
114
115 vtkDataArray* scalarArray = this->Spheres->GetPointData()->GetScalars();
116
117 double maxd = this->MaxDistance > 0 ? this->MaxDistance : VTK_VMTK_LARGE_DOUBLE;
118
119 double point[3], sphereCenter[3];
120 double sphereRadius = 0.;
121 double distanceToSpheres;
122 for (int i=0; i<numberOfInputPoints; i++)
123 {
124 distanceToSpheres=distanceToSpheresArray->GetComponent(i,0);
125 input->GetPoint(i,point);
126 for (int j=0; j<numberOfSpheres; j++)
127 {
128 this->Spheres->GetPoint(j,sphereCenter);
129 if (scalarArray) sphereRadius = scalarArray->GetComponent(j,0);
130 double newDist = sqrt(vtkMath::Distance2BetweenPoints(point,sphereCenter)) - sphereRadius;
131 if (newDist<0.) newDist = 0.;
132 //Scale and offset the distance
133 newDist = this->DistanceOffset + this->DistanceScale*newDist;
134 if (newDist<this->MinDistance) newDist = this->MinDistance;
135 if (newDist>maxd) newDist = maxd;
136 if (newDist<distanceToSpheres) distanceToSpheres = newDist;
137 }
138 distanceToSpheresArray->SetComponent(i,0,distanceToSpheres);
139 }
140
141 if (createArray) distanceToSpheresArray->Delete();
142
143 return 1;
144}
#define VTK_VMTK_LARGE_DOUBLE

Member Data Documentation

◆ DistanceToSpheresArrayName

char* vtkvmtkPolyDataDistanceToSpheres::DistanceToSpheresArrayName
protected

Definition at line 120 of file vtkvmtkPolyDataDistanceToSpheres.h.

◆ Spheres

vtkPolyData* vtkvmtkPolyDataDistanceToSpheres::Spheres
protected

Definition at line 122 of file vtkvmtkPolyDataDistanceToSpheres.h.

◆ DistanceOffset

double vtkvmtkPolyDataDistanceToSpheres::DistanceOffset
protected

Definition at line 124 of file vtkvmtkPolyDataDistanceToSpheres.h.

◆ DistanceScale

double vtkvmtkPolyDataDistanceToSpheres::DistanceScale
protected

Definition at line 125 of file vtkvmtkPolyDataDistanceToSpheres.h.

◆ MinDistance

double vtkvmtkPolyDataDistanceToSpheres::MinDistance
protected

Definition at line 126 of file vtkvmtkPolyDataDistanceToSpheres.h.

◆ MaxDistance

double vtkvmtkPolyDataDistanceToSpheres::MaxDistance
protected

Definition at line 127 of file vtkvmtkPolyDataDistanceToSpheres.h.


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