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

Displace points of a surface with an iterative algorithm based on stencil weighting. More...

#include <vtkvmtkPolyDataStencilFlowFilter.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataStencilFlowFilter * NewInstance () const
void SetStencilTypeToUmbrellaStencil ()
void SetStencilTypeToAreaWeightedUmbrellaStencil ()
void SetStencilTypeToFELaplaceBeltramiStencil ()
void SetStencilTypeToFVFELaplaceBeltramiStencil ()
virtual void SetStencilType (int)
virtual int GetStencilType ()
virtual void SetNumberOfIterations (int)
virtual int GetNumberOfIterations ()
virtual void SetRelaxationFactor (double)
virtual double GetRelaxationFactor ()
virtual void SetProcessBoundary (int)
virtual int GetProcessBoundary ()
virtual void ProcessBoundaryOn ()
virtual void ProcessBoundaryOff ()
virtual void SetConstrainOnSurface (int)
virtual int GetConstrainOnSurface ()
virtual void ConstrainOnSurfaceOn ()
virtual void ConstrainOnSurfaceOff ()
virtual void SetMaximumDisplacement (double)
virtual double GetMaximumDisplacement ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataStencilFlowFilter ()
 ~vtkvmtkPolyDataStencilFlowFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void ReleaseStencils ()

Protected Attributes

int StencilType
vtkvmtkStencils * Stencils
int NumberOfIterations
double RelaxationFactor
double MaximumDisplacement
int ProcessBoundary
int ConstrainOnSurface

Detailed Description

Displace points of a surface with an iterative algorithm based on stencil weighting.

vtkvmtkPolyDataStencilFlowFilter repeatedly rebuilds, at every point of the input surface, a local stencil (see StencilType) that expresses each point's position as a weighted combination of its neighbors, and moves the point towards that weighted average, scaled by RelaxationFactor, for NumberOfIterations iterations. Depending on the chosen stencil this implements Laplacian ("umbrella") smoothing, area-weighted smoothing, or finite-element/ finite-volume Laplace-Beltrami flows. Displacement per iteration can be capped (MaximumDisplacement), boundary points can be left untouched or processed (ProcessBoundary), and the moved points can optionally be reprojected onto the original surface (ConstrainOnSurface) to keep the flow tangential rather than deforming the shape. This underlies mesh-relaxation / smoothing steps used internally by higher-level vmtk surface processing (no direct pype script wraps it).

See also
vtkvmtkStencils, vtkvmtkStencil, vtkvmtkPolyDataUmbrellaStencil

Definition at line 47 of file vtkvmtkPolyDataStencilFlowFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataStencilFlowFilter::Superclass

Definition at line 51 of file vtkvmtkPolyDataStencilFlowFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataStencilFlowFilter()

◆ ~vtkvmtkPolyDataStencilFlowFilter()

vtkvmtkPolyDataStencilFlowFilter::~vtkvmtkPolyDataStencilFlowFilter ( )
protected

Member Function Documentation

◆ New()

vtkvmtkPolyDataStencilFlowFilter * vtkvmtkPolyDataStencilFlowFilter::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataStencilFlowFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataStencilFlowFilter * vtkvmtkPolyDataStencilFlowFilter::NewInstance ( ) const

◆ SetStencilType()

virtual void vtkvmtkPolyDataStencilFlowFilter::SetStencilType ( int )
virtual

Set/get the type of stencil used to compute, at each point, the weighted neighbor combination that drives the point displacement. One of the VTK_VMTK_*_STENCIL constants (see vtkvmtkConstants.h); convenience setters SetStencilTypeToUmbrellaStencil(), SetStencilTypeToAreaWeightedUmbrellaStencil(), SetStencilTypeToFELaplaceBeltramiStencil() and SetStencilTypeToFVFELaplaceBeltramiStencil() are provided. Default: VTK_VMTK_UMBRELLA_STENCIL.

◆ GetStencilType()

virtual int vtkvmtkPolyDataStencilFlowFilter::GetStencilType ( )
virtual

Set/get the type of stencil used to compute, at each point, the weighted neighbor combination that drives the point displacement. One of the VTK_VMTK_*_STENCIL constants (see vtkvmtkConstants.h); convenience setters SetStencilTypeToUmbrellaStencil(), SetStencilTypeToAreaWeightedUmbrellaStencil(), SetStencilTypeToFELaplaceBeltramiStencil() and SetStencilTypeToFVFELaplaceBeltramiStencil() are provided. Default: VTK_VMTK_UMBRELLA_STENCIL.

◆ SetStencilTypeToUmbrellaStencil()

void vtkvmtkPolyDataStencilFlowFilter::SetStencilTypeToUmbrellaStencil ( )
inline

◆ SetStencilTypeToAreaWeightedUmbrellaStencil()

void vtkvmtkPolyDataStencilFlowFilter::SetStencilTypeToAreaWeightedUmbrellaStencil ( )
inline

Definition at line 66 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ SetStencilTypeToFELaplaceBeltramiStencil()

void vtkvmtkPolyDataStencilFlowFilter::SetStencilTypeToFELaplaceBeltramiStencil ( )
inline

Definition at line 68 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ SetStencilTypeToFVFELaplaceBeltramiStencil()

void vtkvmtkPolyDataStencilFlowFilter::SetStencilTypeToFVFELaplaceBeltramiStencil ( )
inline

Definition at line 70 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ SetNumberOfIterations()

virtual void vtkvmtkPolyDataStencilFlowFilter::SetNumberOfIterations ( int )
virtual

Set/get the number of relaxation iterations applied. At each iteration the stencil is rebuilt on the current (already displaced) point positions. Default: 100.

◆ GetNumberOfIterations()

virtual int vtkvmtkPolyDataStencilFlowFilter::GetNumberOfIterations ( )
virtual

Set/get the number of relaxation iterations applied. At each iteration the stencil is rebuilt on the current (already displaced) point positions. Default: 100.

◆ SetRelaxationFactor()

virtual void vtkvmtkPolyDataStencilFlowFilter::SetRelaxationFactor ( double )
virtual

Set/get the fraction of the stencil-weighted displacement applied to each point at every iteration; smaller values relax more gently and are more stable but converge more slowly. Default: 0.1.

◆ GetRelaxationFactor()

virtual double vtkvmtkPolyDataStencilFlowFilter::GetRelaxationFactor ( )
virtual

Set/get the fraction of the stencil-weighted displacement applied to each point at every iteration; smaller values relax more gently and are more stable but converge more slowly. Default: 0.1.

◆ SetProcessBoundary()

virtual void vtkvmtkPolyDataStencilFlowFilter::SetProcessBoundary ( int )
virtual

Toggle whether points lying on a boundary of the surface are displaced. When off (default), boundary points are left untouched so the outline of the surface is preserved; when on, they are moved like any other point using their (open) stencil.

◆ GetProcessBoundary()

virtual int vtkvmtkPolyDataStencilFlowFilter::GetProcessBoundary ( )
virtual

Toggle whether points lying on a boundary of the surface are displaced. When off (default), boundary points are left untouched so the outline of the surface is preserved; when on, they are moved like any other point using their (open) stencil.

◆ ProcessBoundaryOn()

virtual void vtkvmtkPolyDataStencilFlowFilter::ProcessBoundaryOn ( )
virtual

Toggle whether points lying on a boundary of the surface are displaced. When off (default), boundary points are left untouched so the outline of the surface is preserved; when on, they are moved like any other point using their (open) stencil.

◆ ProcessBoundaryOff()

virtual void vtkvmtkPolyDataStencilFlowFilter::ProcessBoundaryOff ( )
virtual

Toggle whether points lying on a boundary of the surface are displaced. When off (default), boundary points are left untouched so the outline of the surface is preserved; when on, they are moved like any other point using their (open) stencil.

◆ SetConstrainOnSurface()

virtual void vtkvmtkPolyDataStencilFlowFilter::SetConstrainOnSurface ( int )
virtual

Toggle projection of each displaced point back onto the closest point of the original input surface (using a cell locator), so that the flow moves points tangentially along the surface rather than deforming its shape. Default: off.

◆ GetConstrainOnSurface()

virtual int vtkvmtkPolyDataStencilFlowFilter::GetConstrainOnSurface ( )
virtual

Toggle projection of each displaced point back onto the closest point of the original input surface (using a cell locator), so that the flow moves points tangentially along the surface rather than deforming its shape. Default: off.

◆ ConstrainOnSurfaceOn()

virtual void vtkvmtkPolyDataStencilFlowFilter::ConstrainOnSurfaceOn ( )
virtual

Toggle projection of each displaced point back onto the closest point of the original input surface (using a cell locator), so that the flow moves points tangentially along the surface rather than deforming its shape. Default: off.

◆ ConstrainOnSurfaceOff()

virtual void vtkvmtkPolyDataStencilFlowFilter::ConstrainOnSurfaceOff ( )
virtual

Toggle projection of each displaced point back onto the closest point of the original input surface (using a cell locator), so that the flow moves points tangentially along the surface rather than deforming its shape. Default: off.

◆ SetMaximumDisplacement()

virtual void vtkvmtkPolyDataStencilFlowFilter::SetMaximumDisplacement ( double )
virtual

Set/get the maximum length of the per-iteration displacement vector applied to any point; larger displacements are clamped (direction preserved, magnitude capped) before being applied. Default: VTK_VMTK_LARGE_DOUBLE (effectively unbounded).

◆ GetMaximumDisplacement()

virtual double vtkvmtkPolyDataStencilFlowFilter::GetMaximumDisplacement ( )
virtual

Set/get the maximum length of the per-iteration displacement vector applied to any point; larger displacements are clamped (direction preserved, magnitude capped) before being applied. Default: VTK_VMTK_LARGE_DOUBLE (effectively unbounded).

◆ RequestData()

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

Definition at line 66 of file vtkvmtkPolyDataStencilFlowFilter.cxx.

70{
71 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
72 vtkInformation *outInfo = outputVector->GetInformationObject(0);
73
74 vtkPolyData *input = vtkPolyData::SafeDownCast(
75 inInfo->Get(vtkDataObject::DATA_OBJECT()));
76 vtkPolyData *output = vtkPolyData::SafeDownCast(
77 outInfo->Get(vtkDataObject::DATA_OBJECT()));
78
79 output->CopyStructure(input);
80 output->GetPointData()->PassData(input->GetPointData());
81 output->GetCellData()->PassData(input->GetCellData());
82 output->GetFieldData()->PassData(input->GetFieldData());
83
84 if (this->Stencils)
85 {
86 this->ReleaseStencils();
87 }
88
90 this->Stencils->SetItemType(this->StencilType);
91 this->Stencils->SetDataSet(input);
92 this->Stencils->ReallocateOnBuildOff();
93 this->Stencils->WeightScalingOn();
94
95 vtkCellLocator *cellLocator = NULL;
96 double* weights = NULL;
97 if (this->ConstrainOnSurface)
98 {
99 weights = new double[input->GetMaxCellSize()];
100 cellLocator = vtkCellLocator::New();
101 cellLocator->SetDataSet(input);
102 cellLocator->BuildLocator();
103 }
104
105 vtkIdType numberOfPoints = input->GetNumberOfPoints();
106
107 double displacement[3], stencilPoint[3], weight;
108 double point[3], newPoint[3];
109
110 vtkIdList* constrainCellIds = vtkIdList::New();
111 constrainCellIds->SetNumberOfIds(input->GetNumberOfPoints());
112 for (vtkIdType pointId=0; pointId<numberOfPoints; pointId++)
113 {
114 constrainCellIds->SetId(pointId,0);
115 }
116
117 for (int iteration=0; iteration<this->NumberOfIterations; iteration++)
118 {
119 this->Stencils->Build();
120 for (vtkIdType pointId=0; pointId<numberOfPoints; pointId++)
121 {
122 vtkvmtkStencil* stencil = this->Stencils->GetStencil(pointId);
123 if (stencil->GetIsBoundary() && (!this->ProcessBoundary))
124 {
125 continue;
126 }
127 displacement[0] = displacement[1] = displacement[2] = 0.0;
128 int numberOfStencilPoints = stencil->GetNumberOfPoints();
129 for (int j=0; j<numberOfStencilPoints; j++)
130 {
131 output->GetPoint(stencil->GetPointId(j),stencilPoint);
132 weight = stencil->GetWeight(j);
133 displacement[0] += weight * stencilPoint[0];
134 displacement[1] += weight * stencilPoint[1];
135 displacement[2] += weight * stencilPoint[2];
136 }
137 weight = stencil->GetCenterWeight();
138 output->GetPoint(pointId,point);
139 displacement[0] -= weight * point[0];
140 displacement[1] -= weight * point[1];
141 displacement[2] -= weight * point[2];
142
143 if (vtkMath::Norm(displacement) > this->MaximumDisplacement)
144 {
145 vtkMath::Normalize(displacement);
146 displacement[0] *= this->MaximumDisplacement;
147 displacement[1] *= this->MaximumDisplacement;
148 displacement[2] *= this->MaximumDisplacement;
149 }
150
151 newPoint[0] = point[0] + this->RelaxationFactor * displacement[0];
152 newPoint[1] = point[1] + this->RelaxationFactor * displacement[1];
153 newPoint[2] = point[2] + this->RelaxationFactor * displacement[2];
154
155 if (this->ConstrainOnSurface)
156 {
157 double closestPoint[3];
158 vtkIdType cellId;
159 int subId;
160 double dist2, pcoords[3];
161 if (input->GetCell(constrainCellIds->GetId(pointId))->EvaluatePosition(newPoint,closestPoint,subId,pcoords,dist2,weights)==0)
162 {
163 cellLocator->FindClosestPoint(newPoint,closestPoint,cellId,subId,dist2);
164 constrainCellIds->SetId(pointId,cellId);
165 }
166 newPoint[0] = closestPoint[0];
167 newPoint[1] = closestPoint[1];
168 newPoint[2] = closestPoint[2];
169 }
170
171 output->GetPoints()->SetPoint(pointId,newPoint);
172 }
173 }
174
175 constrainCellIds->Delete();
176
177 if (weights)
178 {
179 delete[] weights;
180 weights = NULL;
181 }
182
183 if (cellLocator)
184 {
185 cellLocator->Delete();
186 cellLocator = NULL;
187 }
188
189 return 1;
190}
vtkIdType GetPointId(vtkIdType i)
virtual bool GetIsBoundary()
double GetCenterWeight()
double GetWeight(vtkIdType i)
static vtkvmtkStencils * New()

◆ ReleaseStencils()

void vtkvmtkPolyDataStencilFlowFilter::ReleaseStencils ( )
protected

Definition at line 57 of file vtkvmtkPolyDataStencilFlowFilter.cxx.

58{
59 if (this->Stencils)
60 {
61 this->Stencils->UnRegister(this);
62 this->Stencils = NULL;
63 }
64}

Member Data Documentation

◆ StencilType

int vtkvmtkPolyDataStencilFlowFilter::StencilType
protected

Definition at line 132 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ Stencils

vtkvmtkStencils* vtkvmtkPolyDataStencilFlowFilter::Stencils
protected

Definition at line 133 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ NumberOfIterations

int vtkvmtkPolyDataStencilFlowFilter::NumberOfIterations
protected

Definition at line 135 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ RelaxationFactor

double vtkvmtkPolyDataStencilFlowFilter::RelaxationFactor
protected

Definition at line 136 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ MaximumDisplacement

double vtkvmtkPolyDataStencilFlowFilter::MaximumDisplacement
protected

Definition at line 138 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ ProcessBoundary

int vtkvmtkPolyDataStencilFlowFilter::ProcessBoundary
protected

Definition at line 140 of file vtkvmtkPolyDataStencilFlowFilter.h.

◆ ConstrainOnSurface

int vtkvmtkPolyDataStencilFlowFilter::ConstrainOnSurface
protected

Definition at line 141 of file vtkvmtkPolyDataStencilFlowFilter.h.


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