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

Smooth a surface mesh by constraining the motion of selected point ids. More...

#include <vtkvmtkConstrainedLaplacianPolyDataFilter.h>

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

Public Types

typedef vtkPolyDataToPolyDataFilter Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkConstrainedLaplacianPolyDataFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetConvergence (double)
virtual double GetConvergence ()
virtual void SetRelaxationFactor (double)
virtual double GetRelaxationFactor ()
virtual void SetNumberOfIterations (int)
virtual int GetNumberOfIterations ()
virtual void SetBoundarySmoothing (int)
virtual int GetBoundarySmoothing ()
virtual void BoundarySmoothingOn ()
virtual void BoundarySmoothingOff ()
virtual void SetConstrainedPointIds (vtkIdList *)
virtual vtkIdList * GetConstrainedPointIds ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkConstrainedLaplacianPolyDataFilter ()
 ~vtkvmtkConstrainedLaplacianPolyDataFilter ()
void Execute ()

Protected Attributes

vtkIdList * ConstrainedPointIds
double Convergence
double RelaxationFactor
int NumberOfIterations
int BoundarySmoothing

Detailed Description

Smooth a surface mesh by constraining the motion of selected point ids.

vtkvmtkConstrainedLaplacianPolyDataFilter performs Laplacian smoothing of a manifold triangulated surface (vtkPolyData), moving each free point toward the centroid of its 1-ring neighborhood, while keeping the points listed in ConstrainedPointIds (and, unless BoundarySmoothing is on, all boundary points) fixed. Each iteration is a two-step (shrink, then partially compensating unshrink) update similar to Taubin smoothing, intended to reduce volume shrinkage relative to plain Laplacian smoothing. Iteration stops after NumberOfIterations passes or as soon as the largest point displacement observed in a pass falls below Convergence, whichever comes first.

Definition at line 44 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataToPolyDataFilter vtkvmtkConstrainedLaplacianPolyDataFilter::Superclass

Definition at line 47 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkConstrainedLaplacianPolyDataFilter()

◆ ~vtkvmtkConstrainedLaplacianPolyDataFilter()

vtkvmtkConstrainedLaplacianPolyDataFilter::~vtkvmtkConstrainedLaplacianPolyDataFilter ( )
protected

Definition at line 51 of file vtkvmtkConstrainedLaplacianPolyDataFilter.cxx.

52{
53 if (this->ConstrainedPointIds)
54 {
55 this->ConstrainedPointIds->Delete();
56 this->ConstrainedPointIds = NULL;
57 }
58}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkConstrainedLaplacianPolyDataFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkConstrainedLaplacianPolyDataFilter * vtkvmtkConstrainedLaplacianPolyDataFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 205 of file vtkvmtkConstrainedLaplacianPolyDataFilter.cxx.

206{
207 this->Superclass::PrintSelf(os,indent);
208}

◆ New()

vtkvmtkConstrainedLaplacianPolyDataFilter * vtkvmtkConstrainedLaplacianPolyDataFilter::New ( )
static

◆ SetConvergence()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::SetConvergence ( double )
virtual

Set/get the convergence criterion: iteration stops early, before NumberOfIterations is reached, as soon as the largest point displacement observed during a smoothing pass drops below this value. Default: 0.0 (disabled, so smoothing always runs the full NumberOfIterations passes).

◆ GetConvergence()

virtual double vtkvmtkConstrainedLaplacianPolyDataFilter::GetConvergence ( )
virtual

Set/get the convergence criterion: iteration stops early, before NumberOfIterations is reached, as soon as the largest point displacement observed during a smoothing pass drops below this value. Default: 0.0 (disabled, so smoothing always runs the full NumberOfIterations passes).

◆ SetRelaxationFactor()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::SetRelaxationFactor ( double )
virtual

Set/get the relaxation factor controlling the fraction of the Laplacian displacement applied at each of the two per-iteration update steps (shrink and partial unshrink). Default: 0.0 (no motion); typical values are small positive fractions.

◆ GetRelaxationFactor()

virtual double vtkvmtkConstrainedLaplacianPolyDataFilter::GetRelaxationFactor ( )
virtual

Set/get the relaxation factor controlling the fraction of the Laplacian displacement applied at each of the two per-iteration update steps (shrink and partial unshrink). Default: 0.0 (no motion); typical values are small positive fractions.

◆ SetNumberOfIterations()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::SetNumberOfIterations ( int )
virtual

Set/get the maximum number of Laplacian smoothing iterations to perform. Default: a very large integer (VTK_VMTK_LARGE_INTEGER), so in practice Convergence (if set) determines when smoothing stops.

◆ GetNumberOfIterations()

virtual int vtkvmtkConstrainedLaplacianPolyDataFilter::GetNumberOfIterations ( )
virtual

Set/get the maximum number of Laplacian smoothing iterations to perform. Default: a very large integer (VTK_VMTK_LARGE_INTEGER), so in practice Convergence (if set) determines when smoothing stops.

◆ SetBoundarySmoothing()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::SetBoundarySmoothing ( int )
virtual

Toggle smoothing of boundary points. When off (default), points on a free edge of the surface are left untouched regardless of ConstrainedPointIds.

◆ GetBoundarySmoothing()

virtual int vtkvmtkConstrainedLaplacianPolyDataFilter::GetBoundarySmoothing ( )
virtual

Toggle smoothing of boundary points. When off (default), points on a free edge of the surface are left untouched regardless of ConstrainedPointIds.

◆ BoundarySmoothingOn()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::BoundarySmoothingOn ( )
virtual

Toggle smoothing of boundary points. When off (default), points on a free edge of the surface are left untouched regardless of ConstrainedPointIds.

◆ BoundarySmoothingOff()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::BoundarySmoothingOff ( )
virtual

Toggle smoothing of boundary points. When off (default), points on a free edge of the surface are left untouched regardless of ConstrainedPointIds.

◆ SetConstrainedPointIds()

virtual void vtkvmtkConstrainedLaplacianPolyDataFilter::SetConstrainedPointIds ( vtkIdList * )
virtual

Set/get the ids of the points that must remain fixed (not be moved by smoothing), in addition to boundary points when BoundarySmoothing is off. If not set (default), only boundary points (if any) are constrained.

◆ GetConstrainedPointIds()

virtual vtkIdList * vtkvmtkConstrainedLaplacianPolyDataFilter::GetConstrainedPointIds ( )
virtual

Set/get the ids of the points that must remain fixed (not be moved by smoothing), in addition to boundary points when BoundarySmoothing is off. If not set (default), only boundary points (if any) are constrained.

◆ Execute()

void vtkvmtkConstrainedLaplacianPolyDataFilter::Execute ( )
protected

Definition at line 62 of file vtkvmtkConstrainedLaplacianPolyDataFilter.cxx.

63{
64 vtkPolyData *input;
65 vtkPolyData *output;
66 vtkPoints *newPoints;
67 vtkbvgNeighborhoods* neighborhoods;
68 vtkbvgNeighborhood *neighborhood;
69 vtkIdType n, i, j, step;
70 vtkIdType neighborhoodPointId;
71 double point[3], newPoint[3];
72 double neighborhoodPoint[3];
73 double laplacianPoint[3];
74 double displacement[3], displacementNorm;
75 double maxDisplacementNorm;
76 vtkIdType numberOfPoints;
77 vtkIdType numberOfNeighborhoodPoints;
78 vtkIdType numberOfConstrainedPoints;
79 vtkIdType constrainedStatus;
80 vtkIdType constrainedPointId;
81 vtkCharArray *constrainedStatusArray;
82
83 newPoints = vtkPoints::New();
84 constrainedStatusArray = vtkCharArray::New();
85 constrainedStatusArray->SetNumberOfComponents(1);
86
87 input = this->GetInput();
88 output = this->GetOutput();
89
90 newPoints->DeepCopy(input->GetPoints());
91
92 numberOfPoints = input->GetNumberOfPoints();
93
94 constrainedStatusArray->SetNumberOfTuples(numberOfPoints);
95 constrainedStatusArray->FillComponent(0,0.0);
96
97 if (this->ConstrainedPointIds)
98 {
99 numberOfConstrainedPoints = this->ConstrainedPointIds->GetNumberOfIds();
100 for (i=0; i<numberOfConstrainedPoints; i++)
101 {
102 constrainedPointId = this->ConstrainedPointIds->GetId(i);
103 constrainedStatusArray->SetValue(constrainedPointId,1);
104 }
105 }
106
107 output->SetPoints(newPoints);
108 output->SetVerts(input->GetVerts());
109 output->SetLines(input->GetLines());
110 output->SetPolys(input->GetPolys());
111 output->SetStrips(input->GetStrips());
112 output->GetPointData()->PassData(input->GetPointData());
113 output->GetCellData()->PassData(input->GetCellData());
114
115 neighborhoods = vtkbvgNeighborhoods::New();
116 neighborhoods->SetDataSet(input);
117 neighborhoods->SetNeighborhoodTypeToPolyDataManifoldNeighborhood();
118 neighborhoods->Build();
119
120 for (n=0; n<this->NumberOfIterations; n++)
121 {
122 maxDisplacementNorm = 0.0;
123 for (step=0; step<2; step++)
124 {
125 for (i=0; i<numberOfPoints; i++)
126 {
127 constrainedStatus = constrainedStatusArray->GetValue(i);
128 if (constrainedStatus == 1)
129 {
130 continue;
131 }
132
133 neighborhood = neighborhoods->GetNeighborhood(i);
134
135 if (neighborhood->GetIsBoundary() && !this->BoundarySmoothing)
136 {
137 continue;
138 }
139
140 newPoints->GetPoint(i,point);
141 laplacianPoint[0] = laplacianPoint[1] = laplacianPoint[2] = 0.0;
142 numberOfNeighborhoodPoints = neighborhood->GetNumberOfPoints();
143 for (j=0; j<numberOfNeighborhoodPoints; j++)
144 {
145 newPoints->GetPoint(neighborhood->GetPointId(j),neighborhoodPoint);
146 laplacianPoint[0] += neighborhoodPoint[0];
147 laplacianPoint[1] += neighborhoodPoint[1];
148 laplacianPoint[2] += neighborhoodPoint[2];
149 }
150 laplacianPoint[0] /= (double)numberOfNeighborhoodPoints;
151 laplacianPoint[1] /= (double)numberOfNeighborhoodPoints;
152 laplacianPoint[2] /= (double)numberOfNeighborhoodPoints;
153
154 displacement[0] = laplacianPoint[0] - point[0];
155 displacement[1] = laplacianPoint[1] - point[1];
156 displacement[2] = laplacianPoint[2] - point[2];
157
158 displacementNorm = vtkMath::Norm(displacement);
159 if (displacementNorm > maxDisplacementNorm)
160 {
161 maxDisplacementNorm = displacementNorm;
162 }
163
164 if (step == 0)
165 {
166 newPoint[0] = point[0] + this->RelaxationFactor * displacement[0];
167 newPoint[1] = point[1] + this->RelaxationFactor * displacement[1];
168 newPoint[2] = point[2] + this->RelaxationFactor * displacement[2];
169 newPoints->SetPoint(i,newPoint);
170 }
171 else if (step == 1)
172 {
173 for (j=0; j<numberOfNeighborhoodPoints; j++)
174 {
175 neighborhoodPointId = neighborhood->GetPointId(j);
176
177 if ((constrainedStatusArray->GetValue(neighborhoodPointId) == 1) || neighborhoods->GetNeighborhood(neighborhoodPointId)->GetIsBoundary())
178 {
179 continue;
180 }
181
182 newPoints->GetPoint(neighborhoodPointId,neighborhoodPoint);
183
184 newPoint[0] = neighborhoodPoint[0] - this->RelaxationFactor * displacement[0] / (double)numberOfNeighborhoodPoints;
185 newPoint[1] = neighborhoodPoint[1] - this->RelaxationFactor * displacement[1] / (double)numberOfNeighborhoodPoints;
186 newPoint[2] = neighborhoodPoint[2] - this->RelaxationFactor * displacement[2] / (double)numberOfNeighborhoodPoints;
187
188 newPoints->SetPoint(neighborhoodPointId,newPoint);
189 }
190 }
191 }
192 }
193
194 if (maxDisplacementNorm < this->Convergence)
195 {
196 break;
197 }
198 }
199
200 neighborhoods->Delete();
201 newPoints->Delete();
202 constrainedStatusArray->Delete();
203}

Member Data Documentation

◆ ConstrainedPointIds

vtkIdList* vtkvmtkConstrainedLaplacianPolyDataFilter::ConstrainedPointIds
protected

Definition at line 108 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.

◆ Convergence

double vtkvmtkConstrainedLaplacianPolyDataFilter::Convergence
protected

Definition at line 110 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.

◆ RelaxationFactor

double vtkvmtkConstrainedLaplacianPolyDataFilter::RelaxationFactor
protected

Definition at line 111 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.

◆ NumberOfIterations

int vtkvmtkConstrainedLaplacianPolyDataFilter::NumberOfIterations
protected

Definition at line 112 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.

◆ BoundarySmoothing

int vtkvmtkConstrainedLaplacianPolyDataFilter::BoundarySmoothing
protected

Definition at line 113 of file vtkvmtkConstrainedLaplacianPolyDataFilter.h.


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