VMTK
Loading...
Searching...
No Matches
vtkvmtkStencil Class Referenceabstract

Serves as an abstract base for a weighting scheme applied to a single point's neighborhood of a data set. More...

#include <vtkvmtkStencil.h>

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

Public Types

typedef vtkvmtkNeighborhood Superclass
Public Types inherited from vtkvmtkNeighborhood
typedef vtkvmtkDataSetItem Superclass
Public Types inherited from vtkvmtkDataSetItem
typedef vtkvmtkItem Superclass
Public Types inherited from vtkvmtkItem
typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkStencil * NewInstance () const
vtkIdType GetNumberOfWeights ()
void ScaleWeights (double factor)
const double * GetCenterWeightTuple ()
virtual void Build () override=0
virtual void DeepCopy (vtkvmtkItem *src) override
virtual void SetNumberOfComponents (vtkIdType)
virtual vtkIdType GetNumberOfComponents ()
double GetWeight (vtkIdType i)
void SetWeight (vtkIdType i, double weight)
double GetWeight (vtkIdType i, vtkIdType component)
void SetWeight (vtkIdType i, vtkIdType component, double weight)
double GetCenterWeight ()
void SetCenterWeight (double weight)
double GetCenterWeight (vtkIdType component)
void SetCenterWeight (vtkIdType component, double weightComponent)
virtual void SetWeightScaling (int)
virtual int GetWeightScaling ()
virtual void WeightScalingOn ()
virtual void WeightScalingOff ()
virtual void SetNegateWeights (int)
virtual int GetNegateWeights ()
virtual void NegateWeightsOn ()
virtual void NegateWeightsOff ()
Public Member Functions inherited from vtkvmtkNeighborhood
vtkvmtkNeighborhood * NewInstance () const
virtual bool GetIsBoundary ()
vtkIdType GetNumberOfPoints ()
vtkIdType GetPointId (vtkIdType i)
vtkIdType * GetPointer (vtkIdType i)
Public Member Functions inherited from vtkvmtkDataSetItem
vtkvmtkDataSetItem * NewInstance () const
void SetDataSet (vtkDataSet *dataSet)
vtkDataSet * GetDataSet ()
virtual void SetDataSetPointId (vtkIdType)
virtual vtkIdType GetDataSetPointId ()
virtual void SetReallocateOnBuild (int)
virtual int GetReallocateOnBuild ()
virtual void ReallocateOnBuildOn ()
virtual void ReallocateOnBuildOff ()
Public Member Functions inherited from vtkvmtkItem
vtkvmtkItem * NewInstance () const
virtual vtkIdType GetItemType ()=0

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkStencil * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkNeighborhood
static int IsTypeOf (const char *type)
static vtkvmtkNeighborhood * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkDataSetItem
static int IsTypeOf (const char *type)
static vtkvmtkDataSetItem * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkItem
static int IsTypeOf (const char *type)
static vtkvmtkItem * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkStencil ()
 ~vtkvmtkStencil ()
void ResizePointList (vtkIdType ptId, int size)
void ChangeWeightSign ()
Protected Member Functions inherited from vtkvmtkNeighborhood
 vtkvmtkNeighborhood ()
 ~vtkvmtkNeighborhood ()
void ResizePointList (vtkIdType ptId, int size)
Protected Member Functions inherited from vtkvmtkDataSetItem
 vtkvmtkDataSetItem ()
 ~vtkvmtkDataSetItem ()
Protected Member Functions inherited from vtkvmtkItem
 vtkvmtkItem ()
 ~vtkvmtkItem ()

Protected Attributes

vtkIdType NumberOfComponents
double * Weights
double * CenterWeight
int WeightScaling
int NegateWeights
Protected Attributes inherited from vtkvmtkNeighborhood
vtkIdType NPoints
vtkIdType * PointIds
bool IsBoundary
Protected Attributes inherited from vtkvmtkDataSetItem
vtkDataSet * DataSet
vtkIdType DataSetPointId
int ReallocateOnBuild

Detailed Description

Serves as an abstract base for a weighting scheme applied to a single point's neighborhood of a data set.

vtkvmtkStencil extends vtkvmtkNeighborhood by attaching a weight to every neighbor point (and to the center point itself, via CenterWeight), supporting multiple weight components per point (NumberOfComponents) for vector-valued stencils such as gradient operators. Concrete subclasses implement Build() to compute the actual weights for a given point according to a specific numerical scheme (e.g. uniform umbrella/Laplacian weights in vtkvmtkPolyDataUmbrellaStencil, area-weighted, or finite-element/finite-volume Laplace-Beltrami weights). Weights can optionally be sign-negated (NegateWeights) and rescaled (WeightScaling, via ScaleWeights) once computed. Stencils are the per-point building blocks copied into the rows of a vtkvmtkSparseMatrix (see vtkvmtkSparseMatrixRow::CopyStencil) to assemble discrete differential operators over a mesh.

See also
vtkvmtkNeighborhood, vtkvmtkStencils, vtkvmtkSparseMatrix, vtkvmtkPolyDataUmbrellaStencil

Definition at line 44 of file vtkvmtkStencil.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkStencil()

vtkvmtkStencil::vtkvmtkStencil ( )
protected

Definition at line 29 of file vtkvmtkStencil.cxx.

30 {
31 this->Weights = NULL;
32 this->CenterWeight = NULL;
33 this->NumberOfComponents = 1;
34 this->WeightScaling = 1;
35 this->NegateWeights = 1;
36 }
vtkIdType NumberOfComponents
double * CenterWeight

◆ ~vtkvmtkStencil()

vtkvmtkStencil::~vtkvmtkStencil ( )
protected

Definition at line 38 of file vtkvmtkStencil.cxx.

39 {
40 if (this->CenterWeight != NULL)
41 {
42 delete[] this->CenterWeight;
43 this->CenterWeight = NULL;
44 }
45
46 if (this->Weights != NULL)
47 {
48 delete[] this->Weights;
49 this->Weights = NULL;
50 }
51 }

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

◆ SafeDownCast()

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

◆ NewInstanceInternal()

◆ NewInstance()

vtkvmtkStencil * vtkvmtkStencil::NewInstance ( ) const

◆ SetNumberOfComponents()

virtual void vtkvmtkStencil::SetNumberOfComponents ( vtkIdType )
virtual

Set/get the number of weight components stored per neighbor point (and per center weight component); 1 for a scalar stencil (e.g. Laplacian smoothing), 3 for a vector-valued stencil (e.g. gradient). Default: 1.

◆ GetNumberOfComponents()

virtual vtkIdType vtkvmtkStencil::GetNumberOfComponents ( )
virtual

Set/get the number of weight components stored per neighbor point (and per center weight component); 1 for a scalar stencil (e.g. Laplacian smoothing), 3 for a vector-valued stencil (e.g. gradient). Default: 1.

◆ GetWeight() [1/2]

double vtkvmtkStencil::GetWeight ( vtkIdType i)
inline

Get/set the (single-component) weight of the i-th neighbor point of the stencil (0-based index into the neighborhood's point list, as with vtkvmtkNeighborhood::GetPointId).

Definition at line 65 of file vtkvmtkStencil.h.

65{return this->Weights[i];};

◆ SetWeight() [1/2]

void vtkvmtkStencil::SetWeight ( vtkIdType i,
double weight )
inline

Get/set the (single-component) weight of the i-th neighbor point of the stencil (0-based index into the neighborhood's point list, as with vtkvmtkNeighborhood::GetPointId).

Definition at line 66 of file vtkvmtkStencil.h.

66{this->Weights[i] = weight;};

◆ GetWeight() [2/2]

double vtkvmtkStencil::GetWeight ( vtkIdType i,
vtkIdType component )
inline

Get/set the weight of the given component of the i-th neighbor point, for multi-component stencils (see NumberOfComponents).

Definition at line 74 of file vtkvmtkStencil.h.

74{return this->Weights[this->NumberOfComponents * i + component];};

◆ SetWeight() [2/2]

void vtkvmtkStencil::SetWeight ( vtkIdType i,
vtkIdType component,
double weight )
inline

Get/set the weight of the given component of the i-th neighbor point, for multi-component stencils (see NumberOfComponents).

Definition at line 75 of file vtkvmtkStencil.h.

75{this->Weights[this->NumberOfComponents * i + component] = weight;};

◆ GetNumberOfWeights()

vtkIdType vtkvmtkStencil::GetNumberOfWeights ( )
inline

Get the total number of weight values stored for this stencil (NumberOfComponents times the number of neighbor points).

Definition at line 82 of file vtkvmtkStencil.h.

82{return this->NumberOfComponents * this->NPoints;};

◆ ScaleWeights()

void vtkvmtkStencil::ScaleWeights ( double factor)

Multiply every neighbor weight and center weight component by factor (only if WeightScaling is on; a no-op otherwise). Guards against overflow/underflow: near-zero factors zero out all weights, near-infinite factors clamp them to VTK_VMTK_LARGE_DOUBLE, and any resulting weight below VTK_VMTK_DOUBLE_TOL is snapped to zero.

Definition at line 78 of file vtkvmtkStencil.cxx.

79 {
80 vtkIdType j;
81
82 if (!this->WeightScaling)
83 {
84 return;
85 }
86
87 if (std::fabs(factor)<VTK_VMTK_DOUBLE_TOL)
88 {
89 for (j=0; j<this->NumberOfComponents*this->NPoints; j++)
90 {
91 this->Weights[j] = 0.0;
92 }
93 for (j=0; j<this->NumberOfComponents; j++)
94 {
95 this->CenterWeight[j] = 0.0;
96 }
97 return;
98 }
99 else if (std::fabs(factor)>VTK_VMTK_LARGE_DOUBLE)
100 {
101 for (j=0; j<this->NumberOfComponents*this->NPoints; j++)
102 {
104 }
105 for (j=0; j<this->NumberOfComponents; j++)
106 {
108 }
109 return;
110 }
111
112 for (j=0; j<this->NumberOfComponents*this->NPoints; j++)
113 {
114 this->Weights[j] *= factor;
115 if (std::fabs(this->Weights[j])<VTK_VMTK_DOUBLE_TOL)
116 {
117 this->Weights[j] = 0.0;
118 }
119 }
120
121 for (j=0; j<this->NumberOfComponents; j++)
122 {
123 this->CenterWeight[j] *= factor;
124 if (std::fabs(this->CenterWeight[j])<VTK_VMTK_DOUBLE_TOL)
125 {
126 this->CenterWeight[j] = 0.0;
127 }
128 }
129
130 }
#define VTK_VMTK_DOUBLE_TOL
#define VTK_VMTK_LARGE_DOUBLE

◆ GetCenterWeight() [1/2]

double vtkvmtkStencil::GetCenterWeight ( )
inline

Get/set the (single-component) weight assigned to the stencil's center point.

Definition at line 96 of file vtkvmtkStencil.h.

96{return this->CenterWeight[0];};

◆ SetCenterWeight() [1/2]

void vtkvmtkStencil::SetCenterWeight ( double weight)
inline

Get/set the (single-component) weight assigned to the stencil's center point.

Definition at line 97 of file vtkvmtkStencil.h.

97{this->CenterWeight[0] = weight;};

◆ GetCenterWeightTuple()

const double * vtkvmtkStencil::GetCenterWeightTuple ( )
inline

Get a pointer to the full center-weight tuple (NumberOfComponents values).

Definition at line 103 of file vtkvmtkStencil.h.

103{return this->CenterWeight;};

◆ GetCenterWeight() [2/2]

double vtkvmtkStencil::GetCenterWeight ( vtkIdType component)
inline

Get/set the weight of the given component of the stencil's center point, for multi-component stencils (see NumberOfComponents).

Definition at line 110 of file vtkvmtkStencil.h.

110{return this->CenterWeight[component];};

◆ SetCenterWeight() [2/2]

void vtkvmtkStencil::SetCenterWeight ( vtkIdType component,
double weightComponent )
inline

Get/set the weight of the given component of the stencil's center point, for multi-component stencils (see NumberOfComponents).

Definition at line 111 of file vtkvmtkStencil.h.

111{this->CenterWeight[component] = weightComponent;};

◆ Build()

◆ DeepCopy()

void vtkvmtkStencil::DeepCopy ( vtkvmtkItem * src)
overridevirtual

Standard DeepCopy method.

Reimplemented from vtkvmtkNeighborhood.

Definition at line 132 of file vtkvmtkStencil.cxx.

133 {
134 this->Superclass::DeepCopy(src);
135
137
138 if (stencilSrc==NULL)
139 {
140 vtkErrorMacro(<<"Trying to deep copy a non-stencil item");
141 }
142
143 if (this->CenterWeight != NULL)
144 {
145 delete[] this->CenterWeight;
146 this->CenterWeight = NULL;
147 }
148
149 if (this->Weights != NULL)
150 {
151 delete[] this->Weights;
152 this->Weights = NULL;
153 }
154
155 this->NumberOfComponents = stencilSrc->NumberOfComponents;
156
157 if (stencilSrc->NPoints>0)
158 {
159 this->Weights = new double[stencilSrc->NumberOfComponents*stencilSrc->NPoints];
160 memcpy(this->Weights, stencilSrc->Weights, this->NumberOfComponents*this->NPoints * sizeof(double));
161 }
162
163 this->CenterWeight = new double[stencilSrc->NumberOfComponents];
164 memcpy(this->CenterWeight, stencilSrc->CenterWeight, this->NumberOfComponents * sizeof(double));
165
166 this->WeightScaling = stencilSrc->WeightScaling;
167 }
virtual void DeepCopy(vtkvmtkItem *src) override
static vtkvmtkStencil * SafeDownCast(vtkObjectBase *o)

◆ SetWeightScaling()

virtual void vtkvmtkStencil::SetWeightScaling ( int )
virtual

Toggle whether ScaleWeights() actually rescales the stencil weights when called; if off, ScaleWeights() is a no-op. Default: on.

◆ GetWeightScaling()

virtual int vtkvmtkStencil::GetWeightScaling ( )
virtual

Toggle whether ScaleWeights() actually rescales the stencil weights when called; if off, ScaleWeights() is a no-op. Default: on.

◆ WeightScalingOn()

virtual void vtkvmtkStencil::WeightScalingOn ( )
virtual

Toggle whether ScaleWeights() actually rescales the stencil weights when called; if off, ScaleWeights() is a no-op. Default: on.

◆ WeightScalingOff()

virtual void vtkvmtkStencil::WeightScalingOff ( )
virtual

Toggle whether ScaleWeights() actually rescales the stencil weights when called; if off, ScaleWeights() is a no-op. Default: on.

◆ SetNegateWeights()

virtual void vtkvmtkStencil::SetNegateWeights ( int )
virtual

Toggle whether neighbor weights are sign-negated by ChangeWeightSign() after being computed by a subclass's Build(); most differential-operator stencils are built with a natural sign convention and are negated here so that applying the stencil yields the desired displacement/ operator sign. Default: on.

◆ GetNegateWeights()

virtual int vtkvmtkStencil::GetNegateWeights ( )
virtual

Toggle whether neighbor weights are sign-negated by ChangeWeightSign() after being computed by a subclass's Build(); most differential-operator stencils are built with a natural sign convention and are negated here so that applying the stencil yields the desired displacement/ operator sign. Default: on.

◆ NegateWeightsOn()

virtual void vtkvmtkStencil::NegateWeightsOn ( )
virtual

Toggle whether neighbor weights are sign-negated by ChangeWeightSign() after being computed by a subclass's Build(); most differential-operator stencils are built with a natural sign convention and are negated here so that applying the stencil yields the desired displacement/ operator sign. Default: on.

◆ NegateWeightsOff()

virtual void vtkvmtkStencil::NegateWeightsOff ( )
virtual

Toggle whether neighbor weights are sign-negated by ChangeWeightSign() after being computed by a subclass's Build(); most differential-operator stencils are built with a natural sign convention and are negated here so that applying the stencil yields the desired displacement/ operator sign. Default: on.

◆ ResizePointList()

void vtkvmtkStencil::ResizePointList ( vtkIdType ptId,
int size )
protected

Definition at line 66 of file vtkvmtkStencil.cxx.

67 {
68 this->Superclass::ResizePointList(ptId,size);
69
70 double *weights;
71
72 weights = new double[this->NumberOfComponents*this->NPoints];
73 memcpy(weights, this->Weights,this->NumberOfComponents*this->NPoints*sizeof(double));
74 delete [] this->Weights;
75 this->Weights = weights;
76}
void ResizePointList(vtkIdType ptId, int size)

◆ ChangeWeightSign()

void vtkvmtkStencil::ChangeWeightSign ( )
protected

Definition at line 53 of file vtkvmtkStencil.cxx.

54{
55 if (!this->NegateWeights)
56 {
57 return;
58 }
59
60 for (int j=0; j<this->NumberOfComponents*this->NPoints; j++)
61 {
62 this->Weights[j] *= -1.0;
63 }
64}

Member Data Documentation

◆ NumberOfComponents

vtkIdType vtkvmtkStencil::NumberOfComponents
protected

Definition at line 157 of file vtkvmtkStencil.h.

◆ Weights

double* vtkvmtkStencil::Weights
protected

Definition at line 158 of file vtkvmtkStencil.h.

◆ CenterWeight

double* vtkvmtkStencil::CenterWeight
protected

Definition at line 159 of file vtkvmtkStencil.h.

◆ WeightScaling

int vtkvmtkStencil::WeightScaling
protected

Definition at line 161 of file vtkvmtkStencil.h.

◆ NegateWeights

int vtkvmtkStencil::NegateWeights
protected

Definition at line 163 of file vtkvmtkStencil.h.


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