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

Iteratively smooth a centerline with a Laplacian kernel. More...

#include <vtkvmtkCenterlineSmoothing.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkCenterlineSmoothing * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetSmoothingFactor (double)
virtual double GetSmoothingFactor ()
virtual void SetNumberOfSmoothingIterations (int)
virtual int GetNumberOfSmoothingIterations ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkCenterlineSmoothing * SafeDownCast (vtkObjectBase *o)
static vtkvmtkCenterlineSmoothing * New ()
static void SmoothLine (vtkPoints *linePoints, vtkPoints *smoothLinePoints, int numberOfIterations=10, double relaxation=0.1)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkCenterlineSmoothing ()
 ~vtkvmtkCenterlineSmoothing ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

double SmoothingFactor
int NumberOfSmoothingIterations

Detailed Description

Iteratively smooth a centerline with a Laplacian kernel.

Applies Laplacian (moving-average) smoothing to the points of every line/polyline cell of the input centerlines, independently for each cell: each point is repeatedly nudged towards the midpoint of its two neighbors by a fraction (SmoothingFactor) of the difference, repeated NumberOfSmoothingIterations times. This is the filter behind the vmtkcenterlinesmoothing pype script; it's commonly used before differential-geometry computations (curvature, torsion) which are sensitive to point-to-point noise.

See also
vtkvmtkCenterlineGeometry

Definition at line 42 of file vtkvmtkCenterlineSmoothing.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkCenterlineSmoothing::Superclass

Definition at line 45 of file vtkvmtkCenterlineSmoothing.h.

Constructor & Destructor Documentation

◆ vtkvmtkCenterlineSmoothing()

vtkvmtkCenterlineSmoothing::vtkvmtkCenterlineSmoothing ( )
protected

◆ ~vtkvmtkCenterlineSmoothing()

vtkvmtkCenterlineSmoothing::~vtkvmtkCenterlineSmoothing ( )
protected

Definition at line 41 of file vtkvmtkCenterlineSmoothing.cxx.

42{
43}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkCenterlineSmoothing::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkCenterlineSmoothing * vtkvmtkCenterlineSmoothing::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 114 of file vtkvmtkCenterlineSmoothing.cxx.

115{
116 this->Superclass::PrintSelf(os,indent);
117}

◆ New()

vtkvmtkCenterlineSmoothing * vtkvmtkCenterlineSmoothing::New ( )
static

◆ SetSmoothingFactor()

virtual void vtkvmtkCenterlineSmoothing::SetSmoothingFactor ( double )
virtual

Set/Get the relaxation factor applied at each smoothing iteration: at each step, every point moves this fraction of the way towards the midpoint of its two neighbors. Default: 0.01.

◆ GetSmoothingFactor()

virtual double vtkvmtkCenterlineSmoothing::GetSmoothingFactor ( )
virtual

Set/Get the relaxation factor applied at each smoothing iteration: at each step, every point moves this fraction of the way towards the midpoint of its two neighbors. Default: 0.01.

◆ SetNumberOfSmoothingIterations()

virtual void vtkvmtkCenterlineSmoothing::SetNumberOfSmoothingIterations ( int )
virtual

Set/Get the number of Laplacian smoothing iterations applied to each line. Default: 100.

◆ GetNumberOfSmoothingIterations()

virtual int vtkvmtkCenterlineSmoothing::GetNumberOfSmoothingIterations ( )
virtual

Set/Get the number of Laplacian smoothing iterations applied to each line. Default: 100.

◆ SmoothLine()

void vtkvmtkCenterlineSmoothing::SmoothLine ( vtkPoints * linePoints,
vtkPoints * smoothLinePoints,
int numberOfIterations = 10,
double relaxation = 0.1 )
static

Apply Laplacian smoothing to a single polyline, given as an ordered set of points, storing the result in smoothLinePoints (resized/filled by this call). Static utility usable standalone, also used internally by RequestData.

Definition at line 87 of file vtkvmtkCenterlineSmoothing.cxx.

88{
89 int numberOfPoints = linePoints->GetNumberOfPoints();
90
91 smoothLinePoints->DeepCopy(linePoints);
92
93 double point0[3];
94 double point1[3];
95 double point2[3];
96
97 for (int i=0; i<numberOfIterations; i++)
98 {
99 for (int j=1; j<numberOfPoints-1; j++)
100 {
101 smoothLinePoints->GetPoint(j-1,point0);
102 smoothLinePoints->GetPoint(j ,point1);
103 smoothLinePoints->GetPoint(j+1,point2);
104
105 point1[0] += relaxation * (0.5 * (point0[0] + point2[0]) - point1[0]);
106 point1[1] += relaxation * (0.5 * (point0[1] + point2[1]) - point1[1]);
107 point1[2] += relaxation * (0.5 * (point0[2] + point2[2]) - point1[2]);
108
109 smoothLinePoints->SetPoint(j,point1);
110 }
111 }
112}

◆ RequestData()

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

Definition at line 45 of file vtkvmtkCenterlineSmoothing.cxx.

49{
50 // get the info objects
51 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
52 vtkInformation *outInfo = outputVector->GetInformationObject(0);
53
54 // get the input and output
55 vtkPolyData *input = vtkPolyData::SafeDownCast(
56 inInfo->Get(vtkDataObject::DATA_OBJECT()));
57 vtkPolyData *output = vtkPolyData::SafeDownCast(
58 outInfo->Get(vtkDataObject::DATA_OBJECT()));
59
60 output->DeepCopy(input);
61
62 for (int i=0; i<input->GetNumberOfCells(); i++)
63 {
64 vtkCell* line = input->GetCell(i);
65 if (line->GetCellType() != VTK_LINE && line->GetCellType() != VTK_POLY_LINE)
66 {
67 continue;
68 }
69
70 vtkPoints* smoothLinePoints = vtkPoints::New();
71 this->SmoothLine(line->GetPoints(),smoothLinePoints,this->NumberOfSmoothingIterations,this->SmoothingFactor);
72
73 int numberOfLinePoints = smoothLinePoints->GetNumberOfPoints();
74
75 for (int j=0; j<numberOfLinePoints; j++)
76 {
77 vtkIdType pointId = line->GetPointId(j);
78 output->GetPoints()->SetPoint(pointId,smoothLinePoints->GetPoint(j));
79 }
80
81 smoothLinePoints->Delete();
82 }
83
84 return 1;
85}
static void SmoothLine(vtkPoints *linePoints, vtkPoints *smoothLinePoints, int numberOfIterations=10, double relaxation=0.1)

Member Data Documentation

◆ SmoothingFactor

double vtkvmtkCenterlineSmoothing::SmoothingFactor
protected

Definition at line 80 of file vtkvmtkCenterlineSmoothing.h.

◆ NumberOfSmoothingIterations

int vtkvmtkCenterlineSmoothing::NumberOfSmoothingIterations
protected

Definition at line 81 of file vtkvmtkCenterlineSmoothing.h.


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