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

Compute the Voronoi diagram from a Delaunay tessellation or an internal Delaunay tessellation. More...

#include <vtkvmtkVoronoiDiagram3D.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkVoronoiDiagram3D * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetRadiusArrayName (const char *)
virtual char * GetRadiusArrayName ()
virtual vtkIdList * GetPoleIds ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkVoronoiDiagram3D ()
 ~vtkvmtkVoronoiDiagram3D ()
int FillInputPortInformation (int, vtkInformation *info) override
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void ExtractUniqueEdges (vtkUnstructuredGrid *input, vtkCellArray *edgeArray)
void BuildVoronoiPolys (vtkUnstructuredGrid *input, vtkCellArray *voronoiPolys)
void BuildVoronoiLines ()

Protected Attributes

int BuildLines
vtkIdList * PoleIds
char * RadiusArrayName

Detailed Description

Compute the Voronoi diagram from a Delaunay tessellation or an internal Delaunay tessellation.

This class computes the Voronoi diagram of a set of points given their Delaunay tessellation. Basically, the output points are Delaunay tetrahedra circumcenters, and the cells are convex polygons constructed by connecting circumcenters of tetrahedra sharing a face. The radius of the circumsphere associated with each circumcenter is stored in a point data array with name specified by RadiusArrayName. The id list of poles is also provided. Poles are the farthest inner and outer Voronoi points associated with a Delaunay point. Since this class is meant to deal with Delaunay tessellations which are internal to a given surface, only the internal pole is considered for each input point.

Definition at line 36 of file vtkvmtkVoronoiDiagram3D.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkVoronoiDiagram3D::Superclass

Definition at line 39 of file vtkvmtkVoronoiDiagram3D.h.

Constructor & Destructor Documentation

◆ vtkvmtkVoronoiDiagram3D()

vtkvmtkVoronoiDiagram3D::vtkvmtkVoronoiDiagram3D ( )
protected

Definition at line 37 of file vtkvmtkVoronoiDiagram3D.cxx.

38{
39 this->BuildLines = 0;
40 this->PoleIds = vtkIdList::New();
41 this->RadiusArrayName = NULL;
42}

◆ ~vtkvmtkVoronoiDiagram3D()

vtkvmtkVoronoiDiagram3D::~vtkvmtkVoronoiDiagram3D ( )
protected

Definition at line 44 of file vtkvmtkVoronoiDiagram3D.cxx.

45{
46 this->PoleIds->Delete();
47
48 if (this->RadiusArrayName)
49 {
50 delete[] this->RadiusArrayName;
51 this->RadiusArrayName = NULL;
52 }
53}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkVoronoiDiagram3D::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkVoronoiDiagram3D * vtkvmtkVoronoiDiagram3D::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 313 of file vtkvmtkVoronoiDiagram3D.cxx.

314{
315 this->Superclass::PrintSelf(os,indent);
316}

◆ New()

vtkvmtkVoronoiDiagram3D * vtkvmtkVoronoiDiagram3D::New ( )
static

◆ SetRadiusArrayName()

virtual void vtkvmtkVoronoiDiagram3D::SetRadiusArrayName ( const char * )
virtual

Set/Get the name of the point data array where circumsphere radius values are stored. Commonly named "MaximumInscribedSphereRadius".

◆ GetRadiusArrayName()

virtual char * vtkvmtkVoronoiDiagram3D::GetRadiusArrayName ( )
virtual

Set/Get the name of the point data array where circumsphere radius values are stored. Commonly named "MaximumInscribedSphereRadius".

◆ GetPoleIds()

virtual vtkIdList * vtkvmtkVoronoiDiagram3D::GetPoleIds ( )
virtual

Get the id list of poles. The id list has the same size as input points. For every input point, one Voronoi point id is stored in the list.

◆ FillInputPortInformation()

int vtkvmtkVoronoiDiagram3D::FillInputPortInformation ( int ,
vtkInformation * info )
overrideprotected

Definition at line 55 of file vtkvmtkVoronoiDiagram3D.cxx.

56{
57 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid");
58 return 1;
59}

◆ RequestData()

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

Definition at line 192 of file vtkvmtkVoronoiDiagram3D.cxx.

196{
197 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
198 vtkInformation *outInfo = outputVector->GetInformationObject(0);
199
200 vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast(
201 inInfo->Get(vtkDataObject::DATA_OBJECT()));
202 vtkPolyData *output = vtkPolyData::SafeDownCast(
203 outInfo->Get(vtkDataObject::DATA_OBJECT()));
204
205 // Declare
206 double p0[3], p1[3], p2[3], p3[3];
207 double tetraCenter[3], tetraRadius;
208 double currentRadius;
209 vtkIdType i, j, id, poleId;
210 vtkPoints* newPoints;
211 vtkCellArray* newPolys;
212 vtkCellArray* newLines;
213 vtkDoubleArray* newScalars;
214 vtkDoubleArray* thicknessScalars;
215 vtkIdList* cellIds;
216 vtkTetra* tetra;
217
218 poleId = -1;
219
220 // Allocate
221 newPoints = vtkPoints::New();
222 newPoints->SetNumberOfPoints(input->GetNumberOfCells());
223 newScalars = vtkDoubleArray::New();
224 newScalars->SetNumberOfTuples(input->GetNumberOfCells());
225 newPolys = vtkCellArray::New();
226 newLines = vtkCellArray::New();
227 thicknessScalars = vtkDoubleArray::New();
228 thicknessScalars->SetNumberOfTuples(input->GetNumberOfPoints());
229 thicknessScalars->FillComponent(0,0.0);
230
231 cellIds = vtkIdList::New();
232
233 this->PoleIds->SetNumberOfIds(input->GetNumberOfPoints());
234
235 // Execute
236
237 for (i=0; i<input->GetNumberOfPoints(); i++)
238 {
239 this->PoleIds->SetId(i,-1);
240 }
241
242 for (i=0; i<input->GetNumberOfCells(); i++)
243 {
244 tetra = (vtkTetra*) input->GetCell(i);
245 tetra->GetPoints()->GetPoint(0,p0);
246 tetra->GetPoints()->GetPoint(1,p1);
247 tetra->GetPoints()->GetPoint(2,p2);
248 tetra->GetPoints()->GetPoint(3,p3);
249 tetraRadius = sqrt(vtkTetra::Circumsphere(p0,p1,p2,p3,tetraCenter));
250
251 newPoints->SetPoint(i,tetraCenter);
252 newScalars->SetValue(i,(double)tetraRadius);
253 }
254
255 // compute poles
256 input->BuildLinks();
257 for (i=0; i<input->GetNumberOfPoints(); i++)
258 {
259 cellIds->Initialize();
260 input->GetPointCells(i,cellIds);
261 currentRadius = thicknessScalars->GetValue(i);
262 for (j=0; j<cellIds->GetNumberOfIds(); j++)
263 {
264 id = cellIds->GetId(j);
265 tetraRadius = newScalars->GetValue(id);
266 if (tetraRadius - currentRadius > VTK_VMTK_DOUBLE_TOL)
267 {
268 poleId = id;
269 currentRadius = tetraRadius;
270 }
271 }
272 this->PoleIds->SetId(i,poleId);
273 thicknessScalars->SetValue(i,currentRadius);
274 }
275
276 this->BuildVoronoiPolys(input,newPolys);
277
278 if (this->BuildLines)
279 {
280 this->BuildVoronoiLines();
281 }
282
283 if (this->RadiusArrayName)
284 {
285 newScalars->SetName(this->RadiusArrayName);
286 }
287 else
288 {
289 newScalars->SetName("VoronoiRadius");
290 }
291
292 output->SetPoints(newPoints);
293 output->GetPointData()->AddArray(newScalars);
294 output->GetPointData()->SetActiveScalars(newScalars->GetName());
295 output->SetPolys(newPolys);
296
297 if (this->BuildLines)
298 {
299 output->SetLines(newLines);
300 }
301
302 // Destroy
303 newPoints->Delete();
304 newPolys->Delete();
305 newLines->Delete();
306 newScalars->Delete();
307 thicknessScalars->Delete();
308 cellIds->Delete();
309
310 return 1;
311}
void BuildVoronoiPolys(vtkUnstructuredGrid *input, vtkCellArray *voronoiPolys)
#define VTK_VMTK_DOUBLE_TOL

◆ ExtractUniqueEdges()

void vtkvmtkVoronoiDiagram3D::ExtractUniqueEdges ( vtkUnstructuredGrid * input,
vtkCellArray * edgeArray )
protected

Definition at line 61 of file vtkvmtkVoronoiDiagram3D.cxx.

62{
63 int isVisited;
64 vtkIdType i, j, k;
65 vtkIdType edgePts[2];
66 vtkIdType npts;
67 const vtkIdType *pts;
68 vtkIntArray* visited;
69 vtkIdList* pointCells;
70 vtkIdList* insertedLoopPoints;
71
72 visited = vtkIntArray::New();
73 visited->SetNumberOfTuples(input->GetNumberOfPoints());
74 visited->FillComponent(0,0);
75
76 pointCells = vtkIdList::New();
77 insertedLoopPoints = vtkIdList::New();
78
79 for (i=0; i<input->GetNumberOfPoints(); i++)
80 {
81 visited->SetValue(i,1);
82 edgePts[0] = i;
83 pointCells->Initialize();
84 insertedLoopPoints->Initialize();
85 input->GetPointCells(i,pointCells);
86 for (j=0; j<pointCells->GetNumberOfIds(); j++)
87 {
88 input->GetCellPoints(pointCells->GetId(j),npts,pts);
89 for (k=0; k<npts; k++)
90 {
91 isVisited = visited->GetValue(pts[k]);
92 if (!isVisited)
93 if (insertedLoopPoints->IsId(pts[k])==-1)
94 {
95 edgePts[1] = pts[k];
96 insertedLoopPoints->InsertNextId(pts[k]);
97 edgeArray->InsertNextCell(2,edgePts);
98 }
99 }
100 }
101 }
102
103 visited->Delete();
104 pointCells->Delete();
105 insertedLoopPoints->Delete();
106
107}

◆ BuildVoronoiPolys()

void vtkvmtkVoronoiDiagram3D::BuildVoronoiPolys ( vtkUnstructuredGrid * input,
vtkCellArray * voronoiPolys )
protected

Definition at line 109 of file vtkvmtkVoronoiDiagram3D.cxx.

110{
111 bool boundaryTetra;
112 vtkIdType npts;
113 const vtkIdType *pts;
114 pts = NULL;
115 vtkIdType neighborTetraId;
116 vtkIdType i, k, h;
117 vtkCellArray* edgeArray;
118 vtkIdList* polyIds;
119 vtkIdList* neighborCells;
120 vtkIdList* neighborTrianglePointIds;
121 vtkIdList* neighborNeighborCells;
122 vtkIdList* linePointIds;
123 vtkTetra* neighborTetra;
124
125 edgeArray = vtkCellArray::New();
126 polyIds = vtkIdList::New();
127 neighborCells = vtkIdList::New();
128 neighborTrianglePointIds = vtkIdList::New();
129 neighborNeighborCells = vtkIdList::New();
130 linePointIds = vtkIdList::New();
131
132 this->ExtractUniqueEdges(input,edgeArray);
133
134 edgeArray->InitTraversal();
135 for (i=0; i<edgeArray->GetNumberOfCells(); i++)
136 {
137 edgeArray->GetNextCell(npts,pts);
138 linePointIds->Initialize();
139 linePointIds->InsertNextId(pts[0]);
140 linePointIds->InsertNextId(pts[1]);
141
142 boundaryTetra = false;
143 neighborCells->Initialize();
144 neighborTrianglePointIds->Initialize();
145 polyIds->Initialize();
146 input->GetCellNeighbors(-1,linePointIds,neighborCells);
147
148 neighborTrianglePointIds->InsertNextId(linePointIds->GetId(0));
149 neighborTrianglePointIds->InsertNextId(linePointIds->GetId(1));
150
151 neighborTetraId = neighborCells->GetId(0);
152 neighborTetra = vtkTetra::SafeDownCast(input->GetCell(neighborTetraId));
153 polyIds->InsertNextId(neighborTetraId);
154 for (k=0; k<neighborCells->GetNumberOfIds(); k++)
155 {
156 neighborNeighborCells->Initialize();
157 for (h=0; h<neighborTetra->GetNumberOfPoints(); h++)
158 {
159 if (neighborTrianglePointIds->IsId(neighborTetra->GetPointId(h))==-1)
160 {
161 neighborTrianglePointIds->InsertId(2,neighborTetra->GetPointId(h));
162 input->GetCellNeighbors(neighborTetraId,neighborTrianglePointIds,neighborNeighborCells);
163 if (neighborNeighborCells->GetNumberOfIds()==0)
164 {
165 boundaryTetra = true;
166 break;
167 }
168 else if (neighborNeighborCells->GetNumberOfIds()==1)
169 {
170 neighborTetraId = neighborNeighborCells->GetId(0);
171 neighborTetra = vtkTetra::SafeDownCast(input->GetCell(neighborTetraId));
172 polyIds->InsertUniqueId(neighborTetraId);
173 break;
174 }
175 }
176 }
177 if (boundaryTetra)
178 break;
179 }
180 if (!boundaryTetra)
181 voronoiPolys->InsertNextCell(polyIds);
182 }
183
184 edgeArray->Delete();
185 polyIds->Delete();
186 neighborCells->Delete();
187 neighborTrianglePointIds->Delete();
188 neighborNeighborCells->Delete();
189 linePointIds->Delete();
190}
void ExtractUniqueEdges(vtkUnstructuredGrid *input, vtkCellArray *edgeArray)

◆ BuildVoronoiLines()

void vtkvmtkVoronoiDiagram3D::BuildVoronoiLines ( )
inlineprotected

Definition at line 75 of file vtkvmtkVoronoiDiagram3D.h.

75{}; // not yet implemented

Member Data Documentation

◆ BuildLines

int vtkvmtkVoronoiDiagram3D::BuildLines
protected

Definition at line 77 of file vtkvmtkVoronoiDiagram3D.h.

◆ PoleIds

vtkIdList* vtkvmtkVoronoiDiagram3D::PoleIds
protected

Definition at line 78 of file vtkvmtkVoronoiDiagram3D.h.

◆ RadiusArrayName

char* vtkvmtkVoronoiDiagram3D::RadiusArrayName
protected

Definition at line 79 of file vtkvmtkVoronoiDiagram3D.h.


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