72 vtkInformation *vtkNotUsed(request),
73 vtkInformationVector **inputVector,
74 vtkInformationVector *outputVector)
76 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
77 vtkInformation *outInfo = outputVector->GetInformationObject(0);
79 vtkPolyData *input = vtkPolyData::SafeDownCast(
80 inInfo->Get(vtkDataObject::DATA_OBJECT()));
81 vtkPolyData *output = vtkPolyData::SafeDownCast(
82 outInfo->Get(vtkDataObject::DATA_OBJECT()));
86 vtkErrorMacro(<<
"DijkstraDistanceToPointsArrayName not set.");
92 vtkErrorMacro(<<
"SeedIds not set");
96 int numberOfInputPoints = input->GetNumberOfPoints();
98 output->DeepCopy(input);
103 bool createArray = !distanceToPointsArray;
107 distanceToPointsArray = vtkDoubleArray::New();
109 distanceToPointsArray->SetNumberOfComponents(1);
110 distanceToPointsArray->SetNumberOfTuples(numberOfInputPoints);
113 output->GetPointData()->AddArray(distanceToPointsArray);
116 int numberOfSeeds = this->
SeedIds->GetNumberOfIds();
118 vtkDijkstraGraphGeodesicPath *dijkstraAlgo = vtkDijkstraGraphGeodesicPath::New();
119 dijkstraAlgo->SetInputData(input);
120 dijkstraAlgo->StopWhenEndReachedOff();
121 dijkstraAlgo->UseScalarWeightsOff();
125 for (
int i=0; i<numberOfSeeds; i++)
127 dijkstraAlgo->SetStartVertex(
SeedIds->GetId(i));
128 dijkstraAlgo->Update();
129 vtkDoubleArray *seedDistances = vtkDoubleArray::New();
130 dijkstraAlgo->GetCumulativeWeights(seedDistances);
131 for (
int i=0;i<numberOfInputPoints;i++)
134 if (newDist<this->
MinDistance) newDist = this->MinDistance;
135 if (newDist>maxd) newDist = maxd;
136 if (newDist<distanceToPointsArray->GetComponent(i,0)) distanceToPointsArray->SetComponent(i,0,newDist);
138 seedDistances->Delete();
142 if (createArray) distanceToPointsArray->Delete();