------------------------------------------------------------------------------ This is probably a horribly inefficient way to do it.
| 171 | //------------------------------------------------------------------------------ |
| 172 | // This is probably a horribly inefficient way to do it. |
| 173 | void vtkDijkstraGraphGeodesicPath::BuildAdjacency(vtkDataSet* inData) |
| 174 | { |
| 175 | vtkPolyData* pd = vtkPolyData::SafeDownCast(inData); |
| 176 | vtkIdType ncells = pd->GetNumberOfCells(); |
| 177 | |
| 178 | for (vtkIdType i = 0; i < ncells; i++) |
| 179 | { |
| 180 | // Possible types |
| 181 | // VTK_VERTEX, VTK_POLY_VERTEX, VTK_LINE, |
| 182 | // VTK_POLY_LINE,VTK_TRIANGLE, VTK_QUAD, |
| 183 | // VTK_POLYGON, or VTK_TRIANGLE_STRIP. |
| 184 | |
| 185 | vtkIdType ctype = pd->GetCellType(i); |
| 186 | |
| 187 | // Until now only handle polys and triangles |
| 188 | // TODO: All types |
| 189 | if (ctype == VTK_POLYGON || ctype == VTK_TRIANGLE || ctype == VTK_LINE) |
| 190 | { |
| 191 | const vtkIdType* pts; |
| 192 | vtkIdType npts; |
| 193 | pd->GetCellPoints(i, npts, pts); |
| 194 | double cost; |
| 195 | |
| 196 | for (int j = 0; j < npts; ++j) |
| 197 | { |
| 198 | vtkIdType u = pts[j]; |
| 199 | vtkIdType v = pts[((j + 1) % npts)]; |
| 200 | |
| 201 | std::map<int, double>& mu = this->Internals->Adjacency[u]; |
| 202 | if (mu.find(v) == mu.end()) |
| 203 | { |
| 204 | cost = this->CalculateStaticEdgeCost(inData, u, v); |
| 205 | mu.insert(std::pair<int, double>(v, cost)); |
| 206 | } |
| 207 | |
| 208 | std::map<int, double>& mv = this->Internals->Adjacency[v]; |
| 209 | if (mv.find(u) == mv.end()) |
| 210 | { |
| 211 | cost = this->CalculateStaticEdgeCost(inData, v, u); |
| 212 | mv.insert(std::pair<int, double>(u, cost)); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | this->AdjacencyBuildTime.Modified(); |
| 219 | } |
| 220 | |
| 221 | //------------------------------------------------------------------------------ |
| 222 | void vtkDijkstraGraphGeodesicPath::TraceShortestPath( |
no test coverage detected