------------------------------------------------------------------------------
| 613 | |
| 614 | //------------------------------------------------------------------------------ |
| 615 | void vtkVolumeTexture::SplitVolume(vtkImageData* imageData, Size3 const& part) |
| 616 | { |
| 617 | Size6& fullExt = this->FullExtent; |
| 618 | double const numBlocks_x = part[0]; |
| 619 | double const numBlocks_y = part[1]; |
| 620 | double const numBlocks_z = part[2]; |
| 621 | double const deltaX = (fullExt[1] - fullExt[0]) / numBlocks_x; |
| 622 | double const deltaY = (fullExt[3] - fullExt[2]) / numBlocks_y; |
| 623 | double const deltaZ = (fullExt[5] - fullExt[4]) / numBlocks_z; |
| 624 | unsigned int const numBlocks = static_cast<unsigned int>(numBlocks_x * numBlocks_y * numBlocks_z); |
| 625 | |
| 626 | this->ImageDataBlocks = std::vector<vtkDataSet*>(); |
| 627 | this->ImageDataBlocks.reserve(numBlocks); |
| 628 | this->SortedVolumeBlocks.reserve(numBlocks); |
| 629 | |
| 630 | for (int k = 0; k < static_cast<int>(numBlocks_z); k++) |
| 631 | { |
| 632 | for (int j = 0; j < static_cast<int>(numBlocks_y); j++) |
| 633 | { |
| 634 | for (int i = 0; i < static_cast<int>(numBlocks_x); i++) |
| 635 | { |
| 636 | Size6 ext; |
| 637 | ext[0] = fullExt[0] + i * deltaX; |
| 638 | ext[1] = fullExt[0] + (i + 1) * deltaX; |
| 639 | ext[2] = fullExt[2] + j * deltaY; |
| 640 | ext[3] = fullExt[2] + (j + 1) * deltaY; |
| 641 | ext[4] = fullExt[4] + k * deltaZ; |
| 642 | ext[5] = fullExt[4] + (k + 1) * deltaZ; |
| 643 | |
| 644 | // Adjust extents depending on the data representation (cell or point) and |
| 645 | // compute texture size. |
| 646 | if (this->IsCellData == 1) |
| 647 | { |
| 648 | this->AdjustExtentForCell(ext); |
| 649 | } |
| 650 | |
| 651 | // Create a proxy vtkImageData object for each block |
| 652 | vtkImageData* block = vtkImageData::New(); |
| 653 | block->ShallowCopy(imageData); |
| 654 | block->SetExtent(ext[0], ext[1], ext[2], ext[3], ext[4], ext[5]); |
| 655 | this->ImageDataBlocks.push_back(block); |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | //------------------------------------------------------------------------------ |
| 662 | void vtkVolumeTexture::GetScaleAndBias( |
no test coverage detected