MCPcopy Create free account
hub / github.com/Kitware/VTK / TraceShortestPath

Method TraceShortestPath

Filters/Modeling/vtkDijkstraGraphGeodesicPath.cxx:222–274  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

220
221//------------------------------------------------------------------------------
222void vtkDijkstraGraphGeodesicPath::TraceShortestPath(
223 vtkDataSet* inData, vtkPolyData* outPoly, vtkIdType startv, vtkIdType endv)
224{
225 vtkPoints* points = vtkPoints::New();
226 vtkCellArray* lines = vtkCellArray::New();
227
228 // n is far to many. Adjusted later
229 lines->InsertNextCell(this->NumberOfVertices);
230
231 // trace backward
232 vtkIdType v = endv;
233 double pt[3];
234 vtkIdType id;
235 while (v != startv)
236 {
237 if (this->CheckAbort())
238 {
239 break;
240 }
241 if (v < 0)
242 {
243 // Invalid vertex. Path does not exist.
244 break;
245 }
246
247 this->IdList->InsertNextId(v);
248
249 inData->GetPoint(v, pt);
250 id = points->InsertNextPoint(pt);
251 lines->InsertCellPoint(id);
252
253 v = this->Internals->Predecessors[v];
254 }
255
256 if (v >= 0)
257 {
258 this->IdList->InsertNextId(v);
259 inData->GetPoint(v, pt);
260 id = points->InsertNextPoint(pt);
261 lines->InsertCellPoint(id);
262 lines->UpdateCellCount(points->GetNumberOfPoints());
263 }
264 else
265 {
266 points->Reset();
267 lines->Reset();
268 }
269
270 outPoly->SetPoints(points);
271 points->Delete();
272 outPoly->SetLines(lines);
273 lines->Delete();
274}
275
276//------------------------------------------------------------------------------
277void vtkDijkstraGraphGeodesicPath::Relax(const int& u, const int& v, const double& w)

Callers 2

RequestDataMethod · 0.95
RequestDataMethod · 0.80

Calls 13

CheckAbortMethod · 0.80
InsertNextIdMethod · 0.80
InsertCellPointMethod · 0.80
UpdateCellCountMethod · 0.80
SetLinesMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
InsertNextCellMethod · 0.45
GetPointMethod · 0.45
InsertNextPointMethod · 0.45
GetNumberOfPointsMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected