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

Method BuildAdjacency

Filters/Modeling/vtkDijkstraImageGeodesicPath.cxx:221–264  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

219//------------------------------------------------------------------------------
220// This is probably a horribly inefficient way to do it.
221void vtkDijkstraImageGeodesicPath::BuildAdjacency(vtkDataSet* inData)
222{
223 vtkImageData* image = vtkImageData::SafeDownCast(inData);
224
225 vtkIdType ncells = image->GetNumberOfCells();
226
227 // optimized for cell type VTK_PIXEL
228 //
229 vtkIdList* ptIds = vtkIdList::New();
230 vtkIdType uId[6] = { 0, 1, 2, 3, 0, 1 };
231 vtkIdType vId[6] = { 1, 2, 3, 0, 2, 3 };
232 double cost;
233
234 for (vtkIdType i = 0; i < ncells; ++i)
235 {
236 image->GetCellPoints(i, ptIds);
237
238 for (int j = 0; j < 6; ++j)
239 {
240 vtkIdType u = ptIds->GetId(vId[j]);
241 vtkIdType v = ptIds->GetId(uId[j]);
242
243 // before insert and calc, check if key map u has key v
244 std::map<int, double>& mu = this->Internals->Adjacency[u];
245 if (mu.find(v) == mu.end())
246 {
247 cost = this->CalculateStaticEdgeCost(image, u, v);
248 mu.insert(std::pair<int, double>(v, cost));
249 }
250
251 std::map<int, double>& mv = this->Internals->Adjacency[v];
252 if (mv.find(u) == mv.end())
253 {
254 cost = this->CalculateStaticEdgeCost(image, v, u);
255 mv.insert(std::pair<int, double>(u, cost));
256 }
257 }
258 }
259
260 ptIds->Delete();
261
262 this->RebuildStaticCosts = false;
263 this->AdjacencyBuildTime.Modified();
264}
265
266//------------------------------------------------------------------------------
267void vtkDijkstraImageGeodesicPath::UpdateStaticCosts(vtkImageData* image)

Callers

nothing calls this directly

Calls 10

DeleteMethod · 0.65
NewFunction · 0.50
GetNumberOfCellsMethod · 0.45
GetCellPointsMethod · 0.45
GetIdMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected