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

Removes small protrusions (kites) from a surface based on a SizeFactor parameter. More...

#include <vtkvmtkPolyDataKiteRemovalFilter.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataKiteRemovalFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual double GetSizeFactor ()
virtual void SetSizeFactor (double)

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

double SizeFactor

Detailed Description

Removes small protrusions (kites) from a surface based on a SizeFactor parameter.

A "kite" is a small triangle (or connected group of triangles) whose area is much smaller than the surrounding local average, typically a meshing artifact. For every triangle, this filter compares its neighborhood's local average area against the global average area (scaled by SizeFactor) and removes/patches over triangles that fall below the threshold. This is the filter behind the vmtksurfacekiteremoval pype script, typically run before Taubin smoothing to avoid artifacts around degenerate small triangles.

Definition at line 36 of file vtkvmtkPolyDataKiteRemovalFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataKiteRemovalFilter::Superclass

Definition at line 39 of file vtkvmtkPolyDataKiteRemovalFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataKiteRemovalFilter()

vtkvmtkPolyDataKiteRemovalFilter::vtkvmtkPolyDataKiteRemovalFilter ( )
protected

◆ ~vtkvmtkPolyDataKiteRemovalFilter()

vtkvmtkPolyDataKiteRemovalFilter::~vtkvmtkPolyDataKiteRemovalFilter ( )
protected

Definition at line 44 of file vtkvmtkPolyDataKiteRemovalFilter.cxx.

45{
46}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataKiteRemovalFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataKiteRemovalFilter * vtkvmtkPolyDataKiteRemovalFilter::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 169 of file vtkvmtkPolyDataKiteRemovalFilter.cxx.

170{
171 this->Superclass::PrintSelf(os,indent);
172}

◆ New()

vtkvmtkPolyDataKiteRemovalFilter * vtkvmtkPolyDataKiteRemovalFilter::New ( )
static

◆ GetSizeFactor()

virtual double vtkvmtkPolyDataKiteRemovalFilter::GetSizeFactor ( )
virtual

Set/Get the ratio between a triangle's local neighborhood average area and the surface's global average triangle area, below which the triangle is considered a kite and removed. Default: 0.1.

◆ SetSizeFactor()

virtual void vtkvmtkPolyDataKiteRemovalFilter::SetSizeFactor ( double )
virtual

Set/Get the ratio between a triangle's local neighborhood average area and the surface's global average triangle area, below which the triangle is considered a kite and removed. Default: 0.1.

◆ RequestData()

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

Definition at line 48 of file vtkvmtkPolyDataKiteRemovalFilter.cxx.

52{
53 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
54 vtkInformation *outInfo = outputVector->GetInformationObject(0);
55
56 vtkPolyData *input = vtkPolyData::SafeDownCast(
57 inInfo->Get(vtkDataObject::DATA_OBJECT()));
58 vtkPolyData *output = vtkPolyData::SafeDownCast(
59 outInfo->Get(vtkDataObject::DATA_OBJECT()));
60
61 vtkTriangleFilter* triangleFilter = vtkTriangleFilter::New();
62 triangleFilter->SetInputData(input);
63 triangleFilter->PassLinesOff();
64 triangleFilter->PassVertsOff();
65 triangleFilter->Update();
66
67 vtkPolyData* surface = vtkPolyData::New();
68 surface->CopyStructure(triangleFilter->GetOutput());
69 surface->GetPointData()->PassData(triangleFilter->GetOutput()->GetPointData());
70 surface->GetCellData()->PassData(triangleFilter->GetOutput()->GetCellData());
71 surface->GetFieldData()->PassData(triangleFilter->GetOutput()->GetFieldData());
72 surface->BuildCells();
73 surface->BuildLinks();
74
75 double averageTriangleArea = 0.0;
76 int numberOfCells = surface->GetNumberOfCells();
77 double point[3], point1[3], point2[3];
78 vtkIdList* cellPointIds = vtkIdList::New();
79 for (vtkIdType cellId=0; cellId<numberOfCells; cellId++)
80 {
81 cellPointIds->Initialize();
82 surface->GetCellPoints(cellId,cellPointIds);
83 surface->GetPoint(cellPointIds->GetId(0),point);
84 surface->GetPoint(cellPointIds->GetId(1),point1);
85 surface->GetPoint(cellPointIds->GetId(2),point2);
86 averageTriangleArea += vtkTriangle::TriangleArea(point,point1,point2);
87 }
88 averageTriangleArea /= numberOfCells;
89
90 int numberOfPoints = surface->GetNumberOfPoints();
91 vtkIdList* cellIds = vtkIdList::New();
92 for (int pointId=0; pointId<numberOfPoints; pointId++)
93 {
94 surface->GetPoint(pointId,point);
95 cellIds->Initialize();
96 surface->GetPointCells(pointId,cellIds);
97 if (cellIds->GetNumberOfIds() != 4)
98 {
99 continue;
100 }
101 double localAverageTriangleArea = 0.0;
102 int numberOfCellIds = cellIds->GetNumberOfIds();
103 int i, j;
104 for (i=0; i<numberOfCellIds; i++)
105 {
106 vtkIdType cellId = cellIds->GetId(i);
107 cellPointIds->Initialize();
108 surface->GetCellPoints(cellId,cellPointIds);
109 surface->GetPoint(cellPointIds->GetId(0),point);
110 surface->GetPoint(cellPointIds->GetId(1),point1);
111 surface->GetPoint(cellPointIds->GetId(2),point2);
112 localAverageTriangleArea += vtkTriangle::TriangleArea(point,point1,point2);
113 }
114 localAverageTriangleArea /= numberOfCellIds;
115 if (localAverageTriangleArea < VTK_VMTK_DOUBLE_TOL)
116 {
117 continue;
118 }
119 if (localAverageTriangleArea > this->SizeFactor * averageTriangleArea)
120 {
121 continue;
122 }
123 for (i=0; i<numberOfCellIds; i++)
124 {
125 vtkIdType cellId = cellIds->GetId(i);
126 cellPointIds->Initialize();
127 surface->GetCellPoints(cellId,cellPointIds);
128 surface->GetPoint(cellPointIds->GetId(0),point);
129 surface->GetPoint(cellPointIds->GetId(1),point1);
130 surface->GetPoint(cellPointIds->GetId(2),point2);
131 double area = vtkTriangle::TriangleArea(point,point1,point2);
132 if (area > this->SizeFactor * averageTriangleArea)
133 {
134 continue;
135 }
136 int numberOfCellPointIds = cellPointIds->GetNumberOfIds();
137 for (j=0; j<numberOfCellPointIds; j++)
138 {
139 vtkIdType cellPointId = cellPointIds->GetId(j);
140 surface->GetPoints()->SetPoint(cellPointId,point);
141 }
142 }
143 }
144
145 vtkCleanPolyData* cleaner = vtkCleanPolyData::New();
146 cleaner->SetInputData(surface);
147
148 vtkTriangleFilter* triangleFilter2 = vtkTriangleFilter::New();
149 triangleFilter2->SetInputConnection(cleaner->GetOutputPort());
150 triangleFilter2->PassLinesOff();
151 triangleFilter2->PassVertsOff();
152 triangleFilter2->Update();
153
154 output->CopyStructure(triangleFilter2->GetOutput());
155 output->GetPointData()->PassData(triangleFilter2->GetOutput()->GetPointData());
156 output->GetCellData()->PassData(triangleFilter2->GetOutput()->GetCellData());
157 output->GetFieldData()->PassData(triangleFilter2->GetOutput()->GetFieldData());
158
159 triangleFilter->Delete();
160 triangleFilter2->Delete();
161 cleaner->Delete();
162 surface->Delete();
163 cellPointIds->Delete();
164 cellIds->Delete();
165
166 return 1;
167}
#define VTK_VMTK_DOUBLE_TOL

Member Data Documentation

◆ SizeFactor

double vtkvmtkPolyDataKiteRemovalFilter::SizeFactor
protected

Definition at line 59 of file vtkvmtkPolyDataKiteRemovalFilter.h.


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