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
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
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
236
237 for (i=0; i<input->GetNumberOfPoints(); i++)
238 {
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
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);
267 {
268 poleId = id;
269 currentRadius = tetraRadius;
270 }
271 }
272 this->
PoleIds->SetId(i,poleId);
273 thicknessScalars->SetValue(i,currentRadius);
274 }
275
277
279 {
281 }
282
284 {
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
298 {
299 output->SetLines(newLines);
300 }
301
302
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