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

Extract internal tetrahedra from a Delaunay tessellation of a surface. More...

#include <vtkvmtkInternalTetrahedraExtractor.h>

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

Public Types

typedef vtkUnstructuredGridAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkInternalTetrahedraExtractor * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetOutwardNormalsArrayName (const char *)
virtual char * GetOutwardNormalsArrayName ()
virtual void SetUseCaps (int)
virtual int GetUseCaps ()
virtual void UseCapsOn ()
virtual void UseCapsOff ()
virtual void SetCapCenterIds (vtkIdList *)
virtual vtkIdList * GetCapCenterIds ()
virtual void SetTolerance (double)
virtual double GetTolerance ()
virtual void SetRemoveSubresolutionTetrahedra (int)
virtual int GetRemoveSubresolutionTetrahedra ()
virtual void RemoveSubresolutionTetrahedraOn ()
virtual void RemoveSubresolutionTetrahedraOff ()
virtual void SetSubresolutionFactor (double)
virtual double GetSubresolutionFactor ()
virtual void SetSurface (vtkPolyData *)
virtual vtkPolyData * GetSurface ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

int UseCaps
vtkIdList * CapCenterIds
char * OutwardNormalsArrayName
double Tolerance
int RemoveSubresolutionTetrahedra
vtkPolyData * Surface
double SubresolutionFactor

Detailed Description

Extract internal tetrahedra from a Delaunay tessellation of a surface.

This class takes in input the Delaunay tessellation of a point set and extracts internal tetrahedra based on outward oriented point normals (to be provided as input point data array). A tetrahedron \(T_i\) is retained if

\[(x_j - c_i) \cdot n_j \geq 0 \qquad \forall x_j \in T_i \]

where \(x_i\) are the vertices of \(T_i\), \(c_i\) its circumcenter and \(n_j\) the normals at the vertices. It is possible to properly handle capped regions (generated with vtkCapPolyData) by activating UseCaps and providing the ids of cap centers.

See also
vtkCapPolyData

Definition at line 37 of file vtkvmtkInternalTetrahedraExtractor.h.

Member Typedef Documentation

◆ Superclass

typedef vtkUnstructuredGridAlgorithm vtkvmtkInternalTetrahedraExtractor::Superclass

Definition at line 40 of file vtkvmtkInternalTetrahedraExtractor.h.

Constructor & Destructor Documentation

◆ vtkvmtkInternalTetrahedraExtractor()

◆ ~vtkvmtkInternalTetrahedraExtractor()

vtkvmtkInternalTetrahedraExtractor::~vtkvmtkInternalTetrahedraExtractor ( )
protected

Definition at line 49 of file vtkvmtkInternalTetrahedraExtractor.cxx.

50{
51 if (this->CapCenterIds)
52 {
53 this->CapCenterIds->Delete();
54 this->CapCenterIds = NULL;
55 }
57 {
58 delete [] this->OutwardNormalsArrayName;
59 this->OutwardNormalsArrayName = NULL;
60 }
61 if (this->Surface)
62 {
63 this->Surface->Delete();
64 this->Surface = NULL;
65 }
66}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkInternalTetrahedraExtractor::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkInternalTetrahedraExtractor * vtkvmtkInternalTetrahedraExtractor::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 329 of file vtkvmtkInternalTetrahedraExtractor.cxx.

330{
331 this->Superclass::PrintSelf(os,indent);
332}

◆ New()

vtkvmtkInternalTetrahedraExtractor * vtkvmtkInternalTetrahedraExtractor::New ( )
static

◆ SetOutwardNormalsArrayName()

virtual void vtkvmtkInternalTetrahedraExtractor::SetOutwardNormalsArrayName ( const char * )
virtual

Set/Get the name of the array containing outward oriented point normals.

◆ GetOutwardNormalsArrayName()

virtual char * vtkvmtkInternalTetrahedraExtractor::GetOutwardNormalsArrayName ( )
virtual

Set/Get the name of the array containing outward oriented point normals.

◆ SetUseCaps()

virtual void vtkvmtkInternalTetrahedraExtractor::SetUseCaps ( int )
virtual

Turn on/off special handling of caps.

◆ GetUseCaps()

virtual int vtkvmtkInternalTetrahedraExtractor::GetUseCaps ( )
virtual

Turn on/off special handling of caps.

◆ UseCapsOn()

virtual void vtkvmtkInternalTetrahedraExtractor::UseCapsOn ( )
virtual

Turn on/off special handling of caps.

◆ UseCapsOff()

virtual void vtkvmtkInternalTetrahedraExtractor::UseCapsOff ( )
virtual

Turn on/off special handling of caps.

◆ SetCapCenterIds()

virtual void vtkvmtkInternalTetrahedraExtractor::SetCapCenterIds ( vtkIdList * )
virtual

Set/Get the ids of cap centers.

◆ GetCapCenterIds()

virtual vtkIdList * vtkvmtkInternalTetrahedraExtractor::GetCapCenterIds ( )
virtual

Set/Get the ids of cap centers.

◆ SetTolerance()

virtual void vtkvmtkInternalTetrahedraExtractor::SetTolerance ( double )
virtual

Set/Get the numerical tolerance used when testing the retention inequality for each tetrahedron. Default: VTK_VMTK_DOUBLE_TOL.

◆ GetTolerance()

virtual double vtkvmtkInternalTetrahedraExtractor::GetTolerance ( )
virtual

Set/Get the numerical tolerance used when testing the retention inequality for each tetrahedron. Default: VTK_VMTK_DOUBLE_TOL.

◆ SetRemoveSubresolutionTetrahedra()

virtual void vtkvmtkInternalTetrahedraExtractor::SetRemoveSubresolutionTetrahedra ( int )
virtual

Turn on/off removal of surface slivers.

◆ GetRemoveSubresolutionTetrahedra()

virtual int vtkvmtkInternalTetrahedraExtractor::GetRemoveSubresolutionTetrahedra ( )
virtual

Turn on/off removal of surface slivers.

◆ RemoveSubresolutionTetrahedraOn()

virtual void vtkvmtkInternalTetrahedraExtractor::RemoveSubresolutionTetrahedraOn ( )
virtual

Turn on/off removal of surface slivers.

◆ RemoveSubresolutionTetrahedraOff()

virtual void vtkvmtkInternalTetrahedraExtractor::RemoveSubresolutionTetrahedraOff ( )
virtual

Turn on/off removal of surface slivers.

◆ SetSubresolutionFactor()

virtual void vtkvmtkInternalTetrahedraExtractor::SetSubresolutionFactor ( double )
virtual

Set/Get the factor, relative to local feature size, below which a surface tetrahedron is considered a sub-resolution sliver and removed when RemoveSubresolutionTetrahedra is on. Requires Surface to be set. Default: 1.0.

◆ GetSubresolutionFactor()

virtual double vtkvmtkInternalTetrahedraExtractor::GetSubresolutionFactor ( )
virtual

Set/Get the factor, relative to local feature size, below which a surface tetrahedron is considered a sub-resolution sliver and removed when RemoveSubresolutionTetrahedra is on. Requires Surface to be set. Default: 1.0.

◆ SetSurface()

virtual void vtkvmtkInternalTetrahedraExtractor::SetSurface ( vtkPolyData * )
virtual

Set/Get the original (uncapped or capped) surface used as reference when RemoveSubresolutionTetrahedra is on, to identify and discard degenerate surface slivers.

◆ GetSurface()

virtual vtkPolyData * vtkvmtkInternalTetrahedraExtractor::GetSurface ( )
virtual

Set/Get the original (uncapped or capped) surface used as reference when RemoveSubresolutionTetrahedra is on, to identify and discard degenerate surface slivers.

◆ RequestData()

int vtkvmtkInternalTetrahedraExtractor::RequestData ( vtkInformation * request,
vtkInformationVector ** inputVector,
vtkInformationVector * outputVector )
overrideprotectedvirtual

Definition at line 68 of file vtkvmtkInternalTetrahedraExtractor.cxx.

72{
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
75
76 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
80
81 // Declare
82 double circumcenter[3];
83 double p0[3], p1[3], p2[3], p3[3];
84 double v0[3], v1[3], v2[3], v3[3], n0[3], n1[3], n2[3], n3[3];
85 double dot0, dot1, dot2, dot3;
86 bool boundaryTetra;
87 bool allDotPositive, allDotMinusOnePositive;
88 vtkIdType i, j;
89 vtkCellArray* newTetras;
90 vtkIdList* newCellTypes;
91 vtkIntArray* keepCell;
92 vtkDataArray* outwardPointNormals;
93 vtkTetra* tetra;
94
95 if (!this->OutwardNormalsArrayName)
96 {
97 vtkErrorMacro(<< "No normals array name specified!");
98 return 1;
99 }
100
101 outwardPointNormals = input->GetPointData()->GetArray(this->OutwardNormalsArrayName);
102
103 if (!outwardPointNormals)
104 {
105 vtkErrorMacro(<< "Array with name specified does not exist!");
106 return 1;
107 }
108
109 if (outwardPointNormals->GetNumberOfComponents()!=3)
110 {
111 vtkErrorMacro(<< "Normals have NumberOfComponents != 3!");
112 return 1;
113 }
114
115 if (outwardPointNormals->GetNumberOfTuples()!=input->GetNumberOfPoints())
116 {
117 vtkErrorMacro(<< "Number of normals does not match input number of points !");
118 return 1;
119 }
120
121 if ((this->UseCaps)&&(!this->CapCenterIds))
122 {
123 vtkErrorMacro(<< "UseCapsOn but no CapCenterIds specified !");
124 return 1;
125 }
126
127 if (this->RemoveSubresolutionTetrahedra && !this->Surface)
128 {
129 vtkErrorMacro(<< "RemoveSubresolutionTetrahedraOn but no Surface specified !");
130 return 1;
131 }
132
133 if (this->RemoveSubresolutionTetrahedra && this->Surface->GetNumberOfPoints() != input->GetNumberOfPoints())
134 {
135 vtkErrorMacro(<< "NumberOfPoints of Surface is different than that of input Delaunay tessellation, the Delaunay tessellation doesn't look like it has been produced from the Surface !");
136 return 1;
137 }
138
139 // Allocate
140 newTetras = vtkCellArray::New();
141 newCellTypes = vtkIdList::New();
142 keepCell = vtkIntArray::New();
143 keepCell->SetNumberOfTuples(input->GetNumberOfCells());
144
145 // Execute
146
147 //skeleton: dual of inner delaunay tets (Attali, Sk0)(not necessarily internal) or inner voronoi elements (Sk2)(not necessarily homotpic).
148 //actual choice: Sk2.
149
150 double tolerance = this->Tolerance;
151
152 for (i=0; i<input->GetNumberOfCells(); i++)
153 {
154 tetra = vtkTetra::SafeDownCast(input->GetCell(i));
155
156 if (!tetra)
157 {
158 continue;
159 }
160
161 boundaryTetra = false;
162 if (this->UseCaps)
163 {
164 for (j=0; j<tetra->GetNumberOfPoints(); j++)
165 {
166 if (this->CapCenterIds->IsId(tetra->GetPointId(j))!=-1)
167 {
168 boundaryTetra = true;
169 }
170 }
171 }
172
173 tetra->GetPoints()->GetPoint(0,p0);
174 tetra->GetPoints()->GetPoint(1,p1);
175 tetra->GetPoints()->GetPoint(2,p2);
176 tetra->GetPoints()->GetPoint(3,p3);
177 vtkTetra::Circumsphere(p0,p1,p2,p3,circumcenter);
178
179 for (j=0; j<3; j++)
180 {
181 v0[j] = p0[j] - circumcenter[j];
182 v1[j] = p1[j] - circumcenter[j];
183 v2[j] = p2[j] - circumcenter[j];
184 v3[j] = p3[j] - circumcenter[j];
185 }
186
187 outwardPointNormals->GetTuple(tetra->GetPointId(0),n0);
188 outwardPointNormals->GetTuple(tetra->GetPointId(1),n1);
189 outwardPointNormals->GetTuple(tetra->GetPointId(2),n2);
190 outwardPointNormals->GetTuple(tetra->GetPointId(3),n3);
191
192 dot0 = vtkMath::Dot(v0,n0);
193 dot1 = vtkMath::Dot(v1,n1);
194 dot2 = vtkMath::Dot(v2,n2);
195 dot3 = vtkMath::Dot(v3,n3);
196
197 allDotPositive = false;
198 allDotMinusOnePositive = false;
199
200 if ((dot0>tolerance)&&(dot1>tolerance)&&(dot2>tolerance)&&(dot3>tolerance))
201 {
202 allDotPositive = true;
203 }
204 else if (((dot0>tolerance)&&(dot1>tolerance)&&(dot2>tolerance))||
205 ((dot0>tolerance)&&(dot1>tolerance)&&(dot3>tolerance))||
206 ((dot0>tolerance)&&(dot2>tolerance)&&(dot3>tolerance))||
207 ((dot1>tolerance)&&(dot2>tolerance)&&(dot3>tolerance)))
208 {
209 allDotMinusOnePositive = true;
210 }
211
212 keepCell->SetValue(i,0);
213
214 if (allDotPositive)
215 {
216 keepCell->SetValue(i,1);
217 }
218 else if (boundaryTetra)
219 {
220 if (allDotMinusOnePositive)
221 {
222 keepCell->SetValue(i,1);
223 }
224 }
225 }
226
228 {
229 double pt0[3], pt1[3], pt2[3];
230 this->Surface->BuildLinks();
231
232 vtkIdList* cellNeighbors = vtkIdList::New();
233 for (i=0; i<input->GetNumberOfCells(); i++)
234 {
235 if (keepCell->GetValue(i) == 0)
236 {
237 continue;
238 }
239
240 tetra = vtkTetra::SafeDownCast(input->GetCell(i));
241 if (!tetra)
242 {
243 continue;
244 }
245 bool onNewBoundary = false;
246 for (j=0; j<tetra->GetNumberOfFaces(); j++)
247 {
248 cellNeighbors->Initialize();
249 input->GetCellNeighbors(i,tetra->GetFace(j)->GetPointIds(),cellNeighbors);
250 if (cellNeighbors->GetNumberOfIds() == 0 || keepCell->GetValue(cellNeighbors->GetId(0)) == 0)
251 {
252 onNewBoundary = true;
253 }
254 }
255 if (!onNewBoundary)
256 {
257 continue;
258 }
259
260 tetra->GetPoints()->GetPoint(0,p0);
261 tetra->GetPoints()->GetPoint(1,p1);
262 tetra->GetPoints()->GetPoint(2,p2);
263 tetra->GetPoints()->GetPoint(3,p3);
264 double circumradius = vtkTetra::Circumsphere(p0,p1,p2,p3,circumcenter);
265
266 for (j=0; j<tetra->GetNumberOfPoints(); j++)
267 {
268 vtkIdType ncells;
269 vtkIdType* cells;
270 this->Surface->GetPointCells(j,ncells,cells);
271 double minEdgeLength = VTK_VMTK_LARGE_DOUBLE;
272 int k;
273 for (k=0; k<ncells; k++)
274 {
275 vtkTriangle* triangle = vtkTriangle::SafeDownCast(this->Surface->GetCell(cells[k]));
276 if (!triangle)
277 {
278 continue;
279 }
280 triangle->GetPoints()->GetPoint(0,pt0);
281 triangle->GetPoints()->GetPoint(1,pt1);
282 triangle->GetPoints()->GetPoint(2,pt2);
283 double triangleArea = triangle->TriangleArea(pt0,pt1,pt2);
284 double edgeLength = sqrt(2.0 * triangleArea);
285 if (edgeLength < minEdgeLength)
286 {
287 minEdgeLength = edgeLength;
288 }
289 }
290 // TODO: set factor as a member variable.
291 if (circumradius < this->SubresolutionFactor * minEdgeLength)
292 {
293 keepCell->SetValue(i,0);
294 }
295 }
296 }
297 cellNeighbors->Delete();
298 }
299
300 for (i=0; i<input->GetNumberOfCells(); i++)
301 {
302 if (keepCell->GetValue(i))
303 {
304 newCellTypes->InsertNextId(VTK_TETRA);
305 newTetras->InsertNextCell(input->GetCell(i));
306 }
307 }
308
309 int* newCellTypesInt = new int[newCellTypes->GetNumberOfIds()];
310 for (i=0; i<newCellTypes->GetNumberOfIds(); i++)
311 {
312 newCellTypesInt[i] = newCellTypes->GetId(i);
313 }
314
315 output->SetPoints(input->GetPoints());
316 output->GetPointData()->PassData(input->GetPointData());
317 output->SetCells(newCellTypesInt,newTetras);
318
319 // Destroy
320 newTetras->Delete();
321 newCellTypes->Delete();
322 keepCell->Delete();
323
324 delete[] newCellTypesInt;
325
326 return 1;
327}
#define VTK_VMTK_LARGE_DOUBLE

Member Data Documentation

◆ UseCaps

int vtkvmtkInternalTetrahedraExtractor::UseCaps
protected

Definition at line 113 of file vtkvmtkInternalTetrahedraExtractor.h.

◆ CapCenterIds

vtkIdList* vtkvmtkInternalTetrahedraExtractor::CapCenterIds
protected

Definition at line 114 of file vtkvmtkInternalTetrahedraExtractor.h.

◆ OutwardNormalsArrayName

char* vtkvmtkInternalTetrahedraExtractor::OutwardNormalsArrayName
protected

Definition at line 115 of file vtkvmtkInternalTetrahedraExtractor.h.

◆ Tolerance

double vtkvmtkInternalTetrahedraExtractor::Tolerance
protected

Definition at line 117 of file vtkvmtkInternalTetrahedraExtractor.h.

◆ RemoveSubresolutionTetrahedra

int vtkvmtkInternalTetrahedraExtractor::RemoveSubresolutionTetrahedra
protected

Definition at line 119 of file vtkvmtkInternalTetrahedraExtractor.h.

◆ Surface

vtkPolyData* vtkvmtkInternalTetrahedraExtractor::Surface
protected

Definition at line 120 of file vtkvmtkInternalTetrahedraExtractor.h.

◆ SubresolutionFactor

double vtkvmtkInternalTetrahedraExtractor::SubresolutionFactor
protected

Definition at line 121 of file vtkvmtkInternalTetrahedraExtractor.h.


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