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

Apply gradient weighting to the neighborhood connections of a surface. More...

#include <vtkvmtkPolyDataGradientStencil.h>

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

Public Types

typedef vtkvmtkPolyDataManifoldStencil Superclass
Public Types inherited from vtkvmtkPolyDataManifoldStencil
typedef vtkvmtkStencil Superclass
Public Types inherited from vtkvmtkStencil
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)
vtkvmtkPolyDataGradientStencil * NewInstance () const
virtual vtkIdType GetItemType () override
void Build () override
Public Member Functions inherited from vtkvmtkPolyDataManifoldStencil
vtkvmtkPolyDataManifoldStencil * NewInstance () const
virtual double GetArea ()
virtual void ComputeArea ()
void DeepCopy (vtkvmtkPolyDataManifoldStencil *src)
virtual int GetUseExtendedNeighborhood ()
virtual void SetUseExtendedNeighborhood (int)
virtual void UseExtendedNeighborhoodOn ()
virtual void UseExtendedNeighborhoodOff ()
Public Member Functions inherited from vtkvmtkStencil
vtkvmtkStencil * NewInstance () const
vtkIdType GetNumberOfWeights ()
void ScaleWeights (double factor)
const double * GetCenterWeightTuple ()
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

Static Public Member Functions

static vtkvmtkPolyDataGradientStencil * New ()
static int IsTypeOf (const char *type)
static vtkvmtkPolyDataGradientStencil * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkPolyDataManifoldStencil
static int IsTypeOf (const char *type)
static vtkvmtkPolyDataManifoldStencil * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkStencil
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
 vtkvmtkPolyDataGradientStencil ()
 ~vtkvmtkPolyDataGradientStencil ()
void ScaleWithArea () override
void Gamma (double p0[3], double p1[3], double p2[3], double gamma[3])
Protected Member Functions inherited from vtkvmtkPolyDataManifoldStencil
 vtkvmtkPolyDataManifoldStencil ()
 ~vtkvmtkPolyDataManifoldStencil ()
void ScaleWithAreaFactor (double factor)
Protected Member Functions inherited from vtkvmtkStencil
 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 ()

Additional Inherited Members

Protected Attributes inherited from vtkvmtkPolyDataManifoldStencil
double Area
int UseExtendedNeighborhood
Protected Attributes inherited from vtkvmtkStencil
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

Apply gradient weighting to the neighborhood connections of a surface.

vtkvmtkPolyDataGradientStencil builds, for each mesh point, a 3-component-per-neighbor stencil (NumberOfComponents == 3) whose weights, when dotted with the scalar values at the center point and its one-ring neighbors, approximate the 3D surface gradient of that scalar field at the center point. For every triangle incident to an edge of the one-ring, the (area-weighted) contribution of each of its three vertices to the gradient is computed via the internal Gamma() helper – essentially the standard piecewise-linear finite-element gradient formula, weighted by 1/(4*triangle area) – and accumulated into CenterWeight (contribution of the center point) and the neighbor Weights. It is one of the stencil types built by vtkvmtkStencils and consumed, e.g., by gradient estimation on a surface (see also the finite-element based vtkvmtkPolyDataGradientFilter).

See also
vtkvmtkPolyDataManifoldStencil, vtkvmtkStencils, vtkvmtkPolyDataGradientFilter

Definition at line 43 of file vtkvmtkPolyDataGradientStencil.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataGradientStencil()

vtkvmtkPolyDataGradientStencil::vtkvmtkPolyDataGradientStencil ( )
protected

Definition at line 33 of file vtkvmtkPolyDataGradientStencil.cxx.

34{
35 this->Area = 0.0;
36 this->NumberOfComponents = 3;
37}
vtkIdType NumberOfComponents

◆ ~vtkvmtkPolyDataGradientStencil()

vtkvmtkPolyDataGradientStencil::~vtkvmtkPolyDataGradientStencil ( )
inlineprotected

Definition at line 56 of file vtkvmtkPolyDataGradientStencil.h.

56{};

Member Function Documentation

◆ New()

vtkvmtkPolyDataGradientStencil * vtkvmtkPolyDataGradientStencil::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

Reimplemented from vtkvmtkPolyDataManifoldStencil.

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataGradientStencil::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkvmtkPolyDataManifoldStencil.

◆ NewInstance()

vtkvmtkPolyDataGradientStencil * vtkvmtkPolyDataGradientStencil::NewInstance ( ) const

◆ GetItemType()

virtual vtkIdType vtkvmtkPolyDataGradientStencil::GetItemType ( )
inlineoverridevirtual

Get an identifier for the concrete item type (one of the VTK_VMTK_*_NEIGHBORHOOD / VTK_VMTK_*_STENCIL constants), used by owning vtkvmtkItems collections to instantiate the correct subclass.

Implements vtkvmtkItem.

Definition at line 50 of file vtkvmtkPolyDataGradientStencil.h.

@ VTK_VMTK_GRADIENT_STENCIL

◆ Build()

void vtkvmtkPolyDataGradientStencil::Build ( )
overridevirtual

Build the stencil.

Reimplemented from vtkvmtkPolyDataManifoldStencil.

Definition at line 63 of file vtkvmtkPolyDataGradientStencil.cxx.

64{
65 double point[3], point1[3], point2[3];
66 vtkIdType j, firstId, lastId;
67
68 this->Superclass::Build();
69
70 vtkPolyData* pdata = vtkPolyData::SafeDownCast(this->DataSet);
71
72 if (!this->IsBoundary)
73 {
74 firstId = 0;
75 lastId = this->NPoints-1;
76 }
77 else
78 {
79 firstId = 0;
80 lastId = this->NPoints-2;
81 }
82
83 pdata->GetPoint(this->DataSetPointId,point);
84
85 for (j=0; j<3*this->NPoints; j++)
86 this->Weights[j] = 0.0;
87
88 this->CenterWeight[0] = 0.0;
89 this->CenterWeight[1] = 0.0;
90 this->CenterWeight[2] = 0.0;
91
92 double gamma[3];
93 for (j=firstId; j<=lastId; j++)
94 {
95 pdata->GetPoint(this->PointIds[j],point1);
96
97 int jplus = (j+1) % this->NPoints;
98 pdata->GetPoint(this->PointIds[jplus],point2);
99
100 double areaWeight = 1.0 / (4.0 * vtkvmtkMath::TriangleArea(point,point1,point2));
101
102 this->Gamma(point,point1,point2,gamma);
103 this->CenterWeight[0] += gamma[0] * areaWeight;
104 this->CenterWeight[1] += gamma[1] * areaWeight;
105 this->CenterWeight[2] += gamma[2] * areaWeight;
106
107 this->Gamma(point,point2,point1,gamma);
108 this->CenterWeight[0] += gamma[0] * areaWeight;
109 this->CenterWeight[1] += gamma[1] * areaWeight;
110 this->CenterWeight[2] += gamma[2] * areaWeight;
111
112 this->Gamma(point1,point,point2,gamma);
113 this->Weights[3*j+0] += gamma[0] * areaWeight;
114 this->Weights[3*j+1] += gamma[1] * areaWeight;
115 this->Weights[3*j+2] += gamma[2] * areaWeight;
116
117 this->Gamma(point1,point2,point,gamma);
118 this->Weights[3*j+0] += gamma[0] * areaWeight;
119 this->Weights[3*j+1] += gamma[1] * areaWeight;
120 this->Weights[3*j+2] += gamma[2] * areaWeight;
121
122 this->Gamma(point2,point1,point,gamma);
123 this->Weights[3*jplus+0] += gamma[0] * areaWeight;
124 this->Weights[3*jplus+1] += gamma[1] * areaWeight;
125 this->Weights[3*jplus+2] += gamma[2] * areaWeight;
126
127 this->Gamma(point2,point,point1,gamma);
128 this->Weights[3*jplus+0] += gamma[0] * areaWeight;
129 this->Weights[3*jplus+1] += gamma[1] * areaWeight;
130 this->Weights[3*jplus+2] += gamma[2] * areaWeight;
131 }
132
133 this->ComputeArea();
134 this->ScaleWithArea();
135}
static double TriangleArea(double point0[3], double point1[3], double point2[3])
void Gamma(double p0[3], double p1[3], double p2[3], double gamma[3])
double * CenterWeight

◆ ScaleWithArea()

void vtkvmtkPolyDataGradientStencil::ScaleWithArea ( )
overrideprotectedvirtual

Normalize the stencil's Weights/CenterWeight by the area computed by ComputeArea(), typically via the protected ScaleWithAreaFactor helper. Must be implemented by every concrete stencil subclass; called internally at the end of Build().

Implements vtkvmtkPolyDataManifoldStencil.

Definition at line 39 of file vtkvmtkPolyDataGradientStencil.cxx.

40{
41 this->ScaleWithAreaFactor(1.0);
42}

◆ Gamma()

void vtkvmtkPolyDataGradientStencil::Gamma ( double p0[3],
double p1[3],
double p2[3],
double gamma[3] )
protected

Definition at line 44 of file vtkvmtkPolyDataGradientStencil.cxx.

45{
46 double p01[3], p12[3], p20[3];
47 p01[0] = p0[0] - p1[0];
48 p01[1] = p0[1] - p1[1];
49 p01[2] = p0[2] - p1[2];
50 p12[0] = p1[0] - p2[0];
51 p12[1] = p1[1] - p2[1];
52 p12[2] = p1[2] - p2[2];
53 p20[0] = p2[0] - p0[0];
54 p20[1] = p2[1] - p0[1];
55 p20[2] = p2[2] - p0[2];
56
57 double dot = vtkMath::Dot(p01,p12);
58 gamma[0] = dot * p20[0];
59 gamma[1] = dot * p20[1];
60 gamma[2] = dot * p20[2];
61}

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