------------------------------------------------------------------------------
| 220 | |
| 221 | //------------------------------------------------------------------------------ |
| 222 | void 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 | //------------------------------------------------------------------------------ |
| 277 | void vtkDijkstraGraphGeodesicPath::Relax(const int& u, const int& v, const double& w) |
no test coverage detected