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

Method BuildAdjacency

Filters/Modeling/vtkDijkstraGraphGeodesicPath.cxx:173–219  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This is probably a horribly inefficient way to do it.

Source from the content-addressed store, hash-verified

171//------------------------------------------------------------------------------
172// This is probably a horribly inefficient way to do it.
173void 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//------------------------------------------------------------------------------
222void vtkDijkstraGraphGeodesicPath::TraceShortestPath(

Callers 1

InitializeMethod · 0.95

Calls 8

GetNumberOfCellsMethod · 0.45
GetCellTypeMethod · 0.45
GetCellPointsMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected