119 vtkInformation *vtkNotUsed(request),
120 vtkInformationVector **inputVector,
121 vtkInformationVector *outputVector)
123 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
124 vtkInformation *outInfo = outputVector->GetInformationObject(0);
126 vtkPolyData *input = vtkPolyData::SafeDownCast(
127 inInfo->Get(vtkDataObject::DATA_OBJECT()));
128 vtkPolyData *output = vtkPolyData::SafeDownCast(
129 outInfo->Get(vtkDataObject::DATA_OBJECT()));
132 double surfacePoint[3], polePoint[3], poleVector[3], voronoiPoleVector[3], centerlinePoint[3], centerlineVector[3];
133 double voronoiRadius, voronoiGeodesicDistance;
134 double geodesicDistance, normalizedTangencyDeviation;
135 double euclideanDistance;
136 vtkDataArray* voronoiGeodesicDistanceArray = NULL;
137 vtkDataArray* voronoiPoleVectorsArray = NULL;
138 vtkDataArray* voronoiCellIdsArray = NULL;
139 vtkDataArray* voronoiPCoordsArray = NULL;
140 vtkDoubleArray* poleVectorsArray = NULL;
141 vtkDoubleArray* geodesicDistanceArray = NULL;
142 vtkDoubleArray* normalizedTangencyDeviationArray = NULL;
143 vtkDoubleArray* euclideanDistanceArray = NULL;
144 vtkDoubleArray* centerlineVectorsArray = NULL;
145 vtkIntArray* cellIdsArray = NULL;
146 vtkDoubleArray* pcoordsArray = NULL;
150 vtkErrorMacro(<<
"No Voronoi diagram specified!");
156 vtkErrorMacro(<<
"No poleIds specified!");
164 vtkErrorMacro(<<
"No Voronoi geodesic distance array name specified!");
169 if (!voronoiGeodesicDistanceArray)
171 vtkErrorMacro(<<
"Voronoi geodesic distance array with name specified does not exist!");
180 vtkErrorMacro(<<
"No Voronoi pole vectors array name specified!");
185 if (!voronoiPoleVectorsArray)
187 vtkErrorMacro(<<
"Voronoi pole vectors array with name specified does not exist!");
197 vtkErrorMacro(<<
"No Voronoi cellIds array name specified!");
202 if (!voronoiCellIdsArray)
204 vtkErrorMacro(<<
"Voronoi cellIds array with name specified does not exist!");
213 vtkErrorMacro(<<
"No Voronoi pcoords array name specified!");
218 if (!voronoiPCoordsArray)
220 vtkErrorMacro(<<
"Voronoi pcoords array with name specified does not exist!");
230 vtkErrorMacro(<<
"No geodesic distance array name specified!");
239 vtkErrorMacro(<<
"No normalized tangency deviation array name specified!");
248 vtkErrorMacro(<<
"No Euclidean distance array name specified!");
257 vtkErrorMacro(<<
"No cellIds array name specified!");
266 vtkErrorMacro(<<
"No pcoords array name specified!");
275 vtkErrorMacro(<<
"No pole vectors array name specified!");
282 poleVectorsArray = vtkDoubleArray::New();
284 poleVectorsArray->SetNumberOfComponents(3);
285 poleVectorsArray->SetNumberOfTuples(input->GetNumberOfPoints());
286 poleVectorsArray->FillComponent(0,0.0);
287 poleVectorsArray->FillComponent(1,0.0);
288 poleVectorsArray->FillComponent(2,0.0);
293 geodesicDistanceArray = vtkDoubleArray::New();
295 geodesicDistanceArray->SetNumberOfTuples(input->GetNumberOfPoints());
296 geodesicDistanceArray->FillComponent(0,0.0);
301 normalizedTangencyDeviationArray = vtkDoubleArray::New();
303 normalizedTangencyDeviationArray->SetNumberOfTuples(input->GetNumberOfPoints());
304 normalizedTangencyDeviationArray->FillComponent(0,0.0);
309 euclideanDistanceArray = vtkDoubleArray::New();
311 euclideanDistanceArray->SetNumberOfTuples(input->GetNumberOfPoints());
312 euclideanDistanceArray->FillComponent(0,0.0);
317 centerlineVectorsArray = vtkDoubleArray::New();
318 centerlineVectorsArray->SetNumberOfComponents(3);
320 centerlineVectorsArray->SetNumberOfTuples(input->GetNumberOfPoints());
321 centerlineVectorsArray->FillComponent(0,0.0);
322 centerlineVectorsArray->FillComponent(1,0.0);
323 centerlineVectorsArray->FillComponent(2,0.0);
329 cellIdsArray = vtkIntArray::New();
330 cellIdsArray->SetNumberOfComponents(2);
332 cellIdsArray->SetNumberOfTuples(input->GetNumberOfPoints());
333 cellIdsArray->FillComponent(0,0.0);
334 cellIdsArray->FillComponent(1,0.0);
339 pcoordsArray = vtkDoubleArray::New();
341 pcoordsArray->SetNumberOfTuples(input->GetNumberOfPoints());
342 pcoordsArray->FillComponent(0,0.0);
345 for (i=0; i<input->GetNumberOfPoints(); i++)
347 poleId = this->
PoleIds->GetId(i);
351 vtkWarningMacro(<<
"Invalid PoleId found");
356 input->GetPoint(i,surfacePoint);
358 poleVector[0] = polePoint[0] - surfacePoint[0];
359 poleVector[1] = polePoint[1] - surfacePoint[1];
360 poleVector[2] = polePoint[2] - surfacePoint[2];
361 poleVectorsArray->SetTuple(i,poleVector);
366 input->GetPoint(i,surfacePoint);
369 voronoiRadius = sqrt(vtkMath::Distance2BetweenPoints(surfacePoint,polePoint));
370 voronoiGeodesicDistance = voronoiGeodesicDistanceArray->GetTuple1(poleId);
372 geodesicDistance = voronoiGeodesicDistance + voronoiRadius;
375 normalizedTangencyDeviation = voronoiGeodesicDistance / geodesicDistance;
379 normalizedTangencyDeviation = 1.0;
384 geodesicDistanceArray->SetComponent(i,0,geodesicDistance);
389 normalizedTangencyDeviationArray->SetComponent(i,0,normalizedTangencyDeviation);
395 input->GetPoint(i,surfacePoint);
397 voronoiPoleVectorsArray->GetTuple(poleId,voronoiPoleVector);
398 centerlinePoint[0] = polePoint[0] + voronoiPoleVector[0];
399 centerlinePoint[1] = polePoint[1] + voronoiPoleVector[1];
400 centerlinePoint[2] = polePoint[2] + voronoiPoleVector[2];
401 centerlineVector[0] = centerlinePoint[0] - surfacePoint[0];
402 centerlineVector[1] = centerlinePoint[1] - surfacePoint[1];
403 centerlineVector[2] = centerlinePoint[2] - surfacePoint[2];
406 euclideanDistance = sqrt(vtkMath::Distance2BetweenPoints(surfacePoint,centerlinePoint));
407 euclideanDistanceArray->SetComponent(i,0,euclideanDistance);
411 centerlineVectorsArray->SetTuple(i,centerlineVector);
417 cellIdsArray->SetTuple(i,voronoiCellIdsArray->GetTuple(poleId));
422 pcoordsArray->SetTuple(i,voronoiPCoordsArray->GetTuple(poleId));
426 output->CopyStructure(input);
427 output->GetPointData()->PassData(input->GetPointData());
428 output->GetCellData()->PassData(input->GetCellData());
432 output->GetPointData()->AddArray(poleVectorsArray);
433 poleVectorsArray->Delete();
438 output->GetPointData()->AddArray(geodesicDistanceArray);
439 geodesicDistanceArray->Delete();
444 output->GetPointData()->AddArray(normalizedTangencyDeviationArray);
445 normalizedTangencyDeviationArray->Delete();
450 output->GetPointData()->AddArray(euclideanDistanceArray);
451 euclideanDistanceArray->Delete();
456 output->GetPointData()->AddArray(centerlineVectorsArray);
457 centerlineVectorsArray->Delete();
462 output->GetPointData()->AddArray(cellIdsArray);
463 cellIdsArray->Delete();
468 output->GetPointData()->AddArray(pcoordsArray);
469 pcoordsArray->Delete();
482 vtkDataArray* poleVectorsArray = NULL;
483 vtkDataArray* geodesicDistanceArray = NULL;
484 vtkDataArray* euclideanDistanceArray = NULL;
485 vtkDataArray* centerlineVectorsArray = NULL;
487 vtkTriangleFilter* triangleFilter = vtkTriangleFilter::New();
488 triangleFilter->SetInputData(output);
489 triangleFilter->Update();
492 boundaryExtractor->SetInputConnection(triangleFilter->GetOutputPort());
493 boundaryExtractor->Update();
495 vtkPolyData* boundaries = boundaryExtractor->GetOutput();
497 double point[3], barycenter[3];
498 int numberOfBoundaryPoints;
520 double radialVector[3], radialVectorModulus;
521 vtkIdType boundaryPointId;
524 for (i=0; i<boundaries->GetNumberOfCells(); i++)
526 vtkCell* boundary = boundaries->GetCell(i);
527 numberOfBoundaryPoints = boundary->GetPoints()->GetNumberOfPoints();
528 barycenter[0] = barycenter[1] = barycenter[2] = 0.0;
529 for (j=0; j<numberOfBoundaryPoints; j++)
531 boundary->GetPoints()->GetPoint(j,point);
532 barycenter[0] += point[0];
533 barycenter[1] += point[1];
534 barycenter[2] += point[2];
536 barycenter[0] /= numberOfBoundaryPoints;
537 barycenter[1] /= numberOfBoundaryPoints;
538 barycenter[2] /= numberOfBoundaryPoints;
540 for (j=0; j<numberOfBoundaryPoints; j++)
542 boundaryPointId =
static_cast<vtkIdType
>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundary->GetPointId(j)));
543 output->GetPoint(boundaryPointId,point);
544 radialVector[0] = barycenter[0] - point[0];
545 radialVector[1] = barycenter[1] - point[1];
546 radialVector[2] = barycenter[2] - point[2];
547 radialVectorModulus = vtkMath::Norm(radialVector);
551 poleVectorsArray->SetTuple(boundaryPointId,radialVector);
556 geodesicDistanceArray->SetTuple1(boundaryPointId,radialVectorModulus);
561 euclideanDistanceArray->SetTuple1(boundaryPointId,radialVectorModulus);
566 centerlineVectorsArray->SetTuple(boundaryPointId,radialVector);
571 triangleFilter->Delete();
572 boundaryExtractor->Delete();