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

Method ProbeGridPointInAMR

Filters/AMR/vtkAMRResampleFilter.cxx:390–550  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

388
389//------------------------------------------------------------------------------
390int vtkAMRResampleFilter::ProbeGridPointInAMR(double q[3], unsigned int& donorLevel,
391 unsigned int& donorGridId, vtkOverlappingAMR* amrds, unsigned int maxLevel, bool hadDonorGrid)
392{
393 assert("pre: AMR dataset is nullptr" && amrds != nullptr);
394
395 vtkUniformGrid* currentGrid = nullptr;
396 int currentCellIdx = -1;
397 int donorCellIdx = -1;
398 unsigned int currentLevel = 0;
399 unsigned int currentGridId = 0;
400 vtkUniformGrid* donorGrid = hadDonorGrid
401 ? vtkUniformGrid::SafeDownCast(amrds->GetDataSetAsCartesianGrid(donorLevel, donorGridId))
402 : nullptr;
403
404 // STEP 0: Check the previously cached donor-grid
405 if (hadDonorGrid)
406 {
407 this->NumberOfBlocksTested++;
408 bool res(true);
409 if (!amrds->GetOverlappingAMRMetaData()->FindCell(q, donorLevel, donorGridId, donorCellIdx))
410 {
411 // Lets see if the point is contained by a grid at the same donar level
412 res = this->SearchForDonorGridAtLevel(q, amrds, donorLevel, donorGridId, donorCellIdx);
413 donorGrid = res
414 ? vtkUniformGrid::SafeDownCast(amrds->GetDataSetAsCartesianGrid(donorLevel, donorGridId))
415 : nullptr;
416 this->NumberOfBlocksTested += this->NumberOfBlocksTestedForLevel;
417 }
418
419 // If donorGrid is still not nullptr then we found the grid and potential starting
420 // level
421 if (res)
422 {
423 assert("pre: donorCellIdx is invalid" && (donorCellIdx >= 0) &&
424 (donorCellIdx < donorGrid->GetNumberOfCells()));
425
426 this->NumberOfTimesFoundOnDonorLevel++;
427
428 // Initialize values for step 1 s.t. that the search will start from the
429 // current donorLevel
430 currentGrid = donorGrid;
431 currentGridId = donorGridId;
432 currentCellIdx = donorCellIdx;
433 currentLevel = donorLevel;
434 assert(!donorGrid ||
435 vtkUniformGrid::SafeDownCast(amrds->GetDataSetAsCartesianGrid(donorLevel, donorGridId)) ==
436 donorGrid);
437 }
438 else if (donorLevel == 0)
439 {
440 // if we are here then the point is not contained in any of the level 0
441 // blocks!
442 this->NumberOfFailedPoints++;
443 donorGrid = nullptr;
444 donorLevel = 0;
445 return -1;
446 }
447 else

Callers 1

TransferToGridNodesMethod · 0.95

Calls 7

assertFunction · 0.50
FindCellMethod · 0.45
GetNumberOfCellsMethod · 0.45
IsCellVisibleMethod · 0.45

Tested by

no test coverage detected