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

Method ShortestPath

Filters/Modeling/vtkDijkstraGraphGeodesicPath.cxx:290–372  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

288
289//------------------------------------------------------------------------------
290void vtkDijkstraGraphGeodesicPath::ShortestPath(vtkDataSet* inData, int startv, int endv)
291{
292 int u, v;
293
294 if (this->RepelPathFromVertices && this->RepelVertices)
295 {
296 // loop over the pts and if they are in the image
297 // get the associated index for that point and mark it as blocked
298 for (int i = 0; i < this->RepelVertices->GetNumberOfPoints(); ++i)
299 {
300 double* pt = this->RepelVertices->GetPoint(i);
301 u = inData->FindPoint(pt);
302 if (u < 0 || u == startv || u == endv)
303 {
304 continue;
305 }
306 this->Internals->BlockedVertices[u] = true;
307 }
308 }
309
310 this->Internals->CumulativeWeights[startv] = 0;
311
312 this->Internals->HeapInsert(startv);
313 this->Internals->OpenVertices[startv] = true;
314
315 bool stop = false;
316 while ((u = this->Internals->HeapExtractMin()) >= 0 && !stop)
317 {
318 if (this->CheckAbort())
319 {
320 break;
321 }
322 // u is now in ClosedVertices since the shortest path to u is determined
323 this->Internals->ClosedVertices[u] = true;
324 // remove u from OpenVertices
325 this->Internals->OpenVertices[u] = false;
326
327 if (u == endv && this->StopWhenEndReached)
328 {
329 stop = true;
330 }
331
332 std::map<int, double>::iterator it = this->Internals->Adjacency[u].begin();
333
334 // Update all vertices v adjacent to u
335 for (; it != this->Internals->Adjacency[u].end(); ++it)
336 {
337 v = (*it).first;
338
339 // ClosedVertices is the set of vertices with determined shortest path...
340 // do not use them again
341 if (!this->Internals->ClosedVertices[v])
342 {
343 // Only relax edges where the end is not in ClosedVertices
344 // and edge is in OpenVertices
345 double w;
346 if (this->Internals->BlockedVertices[v])
347 {

Callers 2

RequestDataMethod · 0.95
RequestDataMethod · 0.80

Calls 8

RelaxMethod · 0.95
CheckAbortMethod · 0.80
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
FindPointMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected