------------------------------------------------------------------------------
| 438 | |
| 439 | //------------------------------------------------------------------------------ |
| 440 | bool vtkOverlappingAMRMetaData::GenerateRefinementRatio() |
| 441 | { |
| 442 | if (!this->HasSpacing()) |
| 443 | { |
| 444 | return false; |
| 445 | } |
| 446 | |
| 447 | this->Refinement->SetNumberOfTuples(this->GetNumberOfLevels()); |
| 448 | |
| 449 | // sanity check |
| 450 | int numLevels = this->GetNumberOfLevels(); |
| 451 | |
| 452 | if (numLevels < 1) |
| 453 | { |
| 454 | // AMR is empty! |
| 455 | return true; |
| 456 | } |
| 457 | |
| 458 | if (numLevels == 1) |
| 459 | { |
| 460 | // No refinement, data-set has only a single level. |
| 461 | // The refinement ratio is set to 2 to satisfy the |
| 462 | // vtkOverlappingAMR requirement. |
| 463 | this->Refinement->SetValue(0, 2); |
| 464 | return true; |
| 465 | } |
| 466 | |
| 467 | for (int level = 0; level < numLevels - 1; ++level) |
| 468 | { |
| 469 | int childLevel = level + 1; |
| 470 | |
| 471 | if (this->GetNumberOfBlocks(childLevel) < 1 || this->GetNumberOfBlocks(level) < 1) |
| 472 | { |
| 473 | continue; |
| 474 | } |
| 475 | |
| 476 | for (unsigned int id = 0; id < this->GetNumberOfBlocks(level); id++) |
| 477 | { |
| 478 | if (!this->GetAMRBox(level, id).IsInvalid()) |
| 479 | { |
| 480 | break; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | double childSpacing[3]; |
| 485 | this->GetSpacing(childLevel, childSpacing); |
| 486 | |
| 487 | double currentSpacing[3]; |
| 488 | this->GetSpacing(level, currentSpacing); |
| 489 | |
| 490 | // Note current implementation assumes uniform spacing. The |
| 491 | // refinement ratio is the same in each dimension i,j,k. |
| 492 | int nonEmptyDimension = 0; |
| 493 | switch (this->GetGridDescription()) |
| 494 | { |
| 495 | case vtkStructuredData::VTK_STRUCTURED_XY_PLANE: |
| 496 | nonEmptyDimension = 0; |
| 497 | break; |
no test coverage detected