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

Implicit function that interpolates scalar point data with a radial basis function. More...

#include <vtkvmtkRBFInterpolation2.h>

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

Public Types

enum  { THIN_PLATE_SPLINE , BIHARMONIC , TRIHARMONIC }
typedef vtkImplicitFunction Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkRBFInterpolation2 * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
void EvaluateGradient (double x[3], double n[3]) override
void ComputeCoefficients ()
vtkMTimeType GetMTime () override
double EvaluateFunction (double x[3]) override
double EvaluateFunction (double x, double y, double z) override
virtual void SetSource (vtkPolyData *)
virtual vtkPolyData * GetSource ()
virtual void SetRBFType (int)
virtual int GetRBFType ()
void SetRBFTypeToThinPlateSpline ()
void SetRBFTypeToBiharmonic ()
void SetRBFTypeToTriharmonic ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkRBFInterpolation2 ()
 ~vtkvmtkRBFInterpolation2 ()
double EvaluateRBF (double c[3], double x[3])

Protected Attributes

vtkPolyData * Source
int RBFType
vtkDoubleArray * Coefficients

Detailed Description

Implicit function that interpolates scalar point data with a radial basis function.

vtkvmtkRBFInterpolation2 solves for a set of per-point coefficients such that a sum of radial basis functions (RBFs) centered at the points of Source exactly reproduces the scalar point data of Source, then evaluates that sum as an implicit function at arbitrary query points. It is a variant of vtkvmtkRBFInterpolation. The coefficients are found by solving a dense linear system (one equation per source point) the first time EvaluateFunction() is called, or explicitly via ComputeCoefficients(). EvaluateGradient() is not implemented.

See also
vtkvmtkRBFInterpolation

Definition at line 47 of file vtkvmtkRBFInterpolation2.h.

Member Typedef Documentation

◆ Superclass

typedef vtkImplicitFunction vtkvmtkRBFInterpolation2::Superclass

Definition at line 50 of file vtkvmtkRBFInterpolation2.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
THIN_PLATE_SPLINE 
BIHARMONIC 
TRIHARMONIC 

Definition at line 107 of file vtkvmtkRBFInterpolation2.h.

Constructor & Destructor Documentation

◆ vtkvmtkRBFInterpolation2()

vtkvmtkRBFInterpolation2::vtkvmtkRBFInterpolation2 ( )
protected

Definition at line 34 of file vtkvmtkRBFInterpolation2.cxx.

◆ ~vtkvmtkRBFInterpolation2()

vtkvmtkRBFInterpolation2::~vtkvmtkRBFInterpolation2 ( )
protected

Definition at line 41 of file vtkvmtkRBFInterpolation2.cxx.

42{
43 if (this->Source)
44 {
45 this->Source->Delete();
46 this->Source = NULL;
47 }
48
49 if (this->Coefficients)
50 {
51 this->Coefficients->Delete();
52 this->Coefficients = NULL;
53 }
54}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkRBFInterpolation2::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkRBFInterpolation2 * vtkvmtkRBFInterpolation2::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 209 of file vtkvmtkRBFInterpolation2.cxx.

210{
211 this->Superclass::PrintSelf(os,indent);
212
213}

◆ New()

vtkvmtkRBFInterpolation2 * vtkvmtkRBFInterpolation2::New ( )
static

◆ EvaluateFunction() [1/2]

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

Evaluate polyball.

Definition at line 157 of file vtkvmtkRBFInterpolation2.cxx.

158{
159 if (!this->Source)
160 {
161 vtkErrorMacro("No Source specified!");
162 return 0.0;
163 }
164
165 int numberOfPoints = this->Source->GetNumberOfPoints();
166
167 if (!numberOfPoints)
168 {
169 vtkWarningMacro("Empty Source specified!");
170 return 0.0;
171 }
172
173 if (!this->Coefficients)
174 {
175 this->ComputeCoefficients();
176 }
177
178 double rbfValue = 0.0;
179 double center[3];
180 int i;
181 for (i=0; i<numberOfPoints; i++)
182 {
183 this->Source->GetPoint(i,center);
184 rbfValue += this->Coefficients->GetValue(i) * this->EvaluateRBF(center,x);
185 }
186
187 return rbfValue;
188}
double EvaluateRBF(double c[3], double x[3])

◆ EvaluateFunction() [2/2]

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

Evaluate polyball.

Definition at line 60 of file vtkvmtkRBFInterpolation2.h.

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

◆ EvaluateGradient()

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

Evaluate polyball gradient. Not implemented; issues a warning and leaves n untouched.

Definition at line 190 of file vtkvmtkRBFInterpolation2.cxx.

191{
192 vtkWarningMacro("RBF gradient computation not implemented.");
193}

◆ ComputeCoefficients()

void vtkvmtkRBFInterpolation2::ComputeCoefficients ( )

Solve the dense linear system that determines the per-point RBF coefficients required to interpolate the scalar point data of Source. Called automatically by EvaluateFunction() the first time it is invoked after Source (or its data) changes; may also be called explicitly to force recomputation.

Definition at line 82 of file vtkvmtkRBFInterpolation2.cxx.

83{
84 if (this->Coefficients)
85 {
86 this->Coefficients->Delete();
87 this->Coefficients = NULL;
88 }
89
90 if (!this->Source)
91 {
92 vtkErrorMacro("No Source specified!");
93 return;
94 }
95
96 vtkDataArray *sourceScalars = this->Source->GetPointData()->GetScalars();
97
98 if (!sourceScalars)
99 {
100 vtkErrorMacro("No scalars to interpolate!");
101 return;
102 }
103
104 int numberOfPoints = this->Source->GetNumberOfPoints();
105 if (!numberOfPoints)
106 {
107 vtkWarningMacro("Empty Source specified!");
108 return;
109 }
110
111 this->Coefficients = vtkDoubleArray::New();
112 this->Coefficients->SetNumberOfValues(numberOfPoints);
113
114 double **A, *x;
115 x = new double[numberOfPoints];
116 A = new double* [numberOfPoints];
117
118 int i;
119 for (i=0; i<numberOfPoints; i++)
120 {
121 A[i] = new double[numberOfPoints];
122 x[i] = sourceScalars->GetComponent(i,0);
123 }
124
125 double center[3];
126 int j;
127 for (i=0; i<numberOfPoints; i++)
128 {
129 this->Source->GetPoint(i,center);
130 for (j=0; j<numberOfPoints; j++)
131 {
132 A[i][j] = this->EvaluateRBF(center,this->Source->GetPoint(j));
133 }
134 }
135
136 int ret = vtkMath::SolveLinearSystem(A,x,numberOfPoints);
137
138 if (!ret)
139 {
140 vtkErrorMacro(<<"Cannot compute coefficients: error during linear system solve");
141 }
142
143 for (i=0; i<numberOfPoints; i++)
144 {
145 this->Coefficients->SetValue(i,x[i]);
146 }
147
148 delete[] x;
149 for (i=0; i<numberOfPoints; i++)
150 {
151 delete[] A[i];
152 }
153 delete[] A;
154
155}

◆ SetSource()

virtual void vtkvmtkRBFInterpolation2::SetSource ( vtkPolyData * )
virtual

Set/get the source poly data whose points and point scalars define the interpolation problem: the RBFs are centered at the Source points and their coefficients are solved for so that the interpolant reproduces the Source point scalars exactly.

◆ GetSource()

virtual vtkPolyData * vtkvmtkRBFInterpolation2::GetSource ( )
virtual

Set/get the source poly data whose points and point scalars define the interpolation problem: the RBFs are centered at the Source points and their coefficients are solved for so that the interpolant reproduces the Source point scalars exactly.

◆ SetRBFType()

virtual void vtkvmtkRBFInterpolation2::SetRBFType ( int )
virtual

Set/get the type of radial basis function used, one of THIN_PLATE_SPLINE (r^2 log r, the default), BIHARMONIC (r), or TRIHARMONIC (r^3), where r is the distance to an RBF center.

◆ GetRBFType()

virtual int vtkvmtkRBFInterpolation2::GetRBFType ( )
virtual

Set/get the type of radial basis function used, one of THIN_PLATE_SPLINE (r^2 log r, the default), BIHARMONIC (r), or TRIHARMONIC (r^3), where r is the distance to an RBF center.

◆ SetRBFTypeToThinPlateSpline()

void vtkvmtkRBFInterpolation2::SetRBFTypeToThinPlateSpline ( )
inline

Set/get the type of radial basis function used, one of THIN_PLATE_SPLINE (r^2 log r, the default), BIHARMONIC (r), or TRIHARMONIC (r^3), where r is the distance to an RBF center.

Definition at line 98 of file vtkvmtkRBFInterpolation2.h.

virtual void SetRBFType(int)

◆ SetRBFTypeToBiharmonic()

void vtkvmtkRBFInterpolation2::SetRBFTypeToBiharmonic ( )
inline

Set/get the type of radial basis function used, one of THIN_PLATE_SPLINE (r^2 log r, the default), BIHARMONIC (r), or TRIHARMONIC (r^3), where r is the distance to an RBF center.

Definition at line 100 of file vtkvmtkRBFInterpolation2.h.

101 { this->SetRBFType(BIHARMONIC); }

◆ SetRBFTypeToTriharmonic()

void vtkvmtkRBFInterpolation2::SetRBFTypeToTriharmonic ( )
inline

Set/get the type of radial basis function used, one of THIN_PLATE_SPLINE (r^2 log r, the default), BIHARMONIC (r), or TRIHARMONIC (r^3), where r is the distance to an RBF center.

Definition at line 102 of file vtkvmtkRBFInterpolation2.h.

103 { this->SetRBFType(TRIHARMONIC); }

◆ GetMTime()

vtkMTimeType vtkvmtkRBFInterpolation2::GetMTime ( )
override

Returns this object's MTime, taking into account the MTime of Source.

Definition at line 195 of file vtkvmtkRBFInterpolation2.cxx.

196{
197 unsigned long mTime=this->Superclass::GetMTime();
198 unsigned long sourceMTime;
199
200 if (this->Source != NULL)
201 {
202 sourceMTime = this->Source->GetMTime();
203 mTime = ( sourceMTime > mTime ? sourceMTime : mTime );
204 }
205
206 return mTime;
207}

◆ EvaluateRBF()

double vtkvmtkRBFInterpolation2::EvaluateRBF ( double c[3],
double x[3] )
protected

Definition at line 56 of file vtkvmtkRBFInterpolation2.cxx.

57{
58 if (this->RBFType == THIN_PLATE_SPLINE)
59 {
60 double r2 = vtkMath::Distance2BetweenPoints(c,x);
61 if (!r2)
62 {
63 return 0.0;
64 }
65 return r2 * log(sqrt(r2));
66 }
67 else if (this->RBFType == BIHARMONIC)
68 {
69 return sqrt(vtkMath::Distance2BetweenPoints(c,x));
70 }
71 else if (this->RBFType == TRIHARMONIC)
72 {
73 return pow(vtkMath::Distance2BetweenPoints(c,x),1.5);
74 }
75 else
76 {
77 vtkErrorMacro(<<"Error: Unsupported RBFType!");
78 return 0.0;
79 }
80}

Member Data Documentation

◆ Source

vtkPolyData* vtkvmtkRBFInterpolation2::Source
protected

Definition at line 126 of file vtkvmtkRBFInterpolation2.h.

◆ RBFType

int vtkvmtkRBFInterpolation2::RBFType
protected

Definition at line 127 of file vtkvmtkRBFInterpolation2.h.

◆ Coefficients

vtkDoubleArray* vtkvmtkRBFInterpolation2::Coefficients
protected

Definition at line 129 of file vtkvmtkRBFInterpolation2.h.


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