------------------------------------------------------------------------------
| 729 | |
| 730 | //------------------------------------------------------------------------------ |
| 731 | void vtkGPUVolumeRayCastMapper::TransformInput(int port) |
| 732 | { |
| 733 | vtkDataSet* dataset = this->TransformedInputs[port]; |
| 734 | if (vtkImageData* clone = vtkImageData::SafeDownCast(dataset)) |
| 735 | { |
| 736 | if (!dataset) |
| 737 | { |
| 738 | clone->SetExtent(0, -1, 0, -1, 0, -1); |
| 739 | return; |
| 740 | } |
| 741 | |
| 742 | clone->ShallowCopy(this->GetInput(port)); |
| 743 | |
| 744 | // Get the current extents. |
| 745 | int extents[6]; |
| 746 | clone->GetExtent(extents); |
| 747 | |
| 748 | // Get the current origin and spacing. |
| 749 | double origin[3], spacing[3]; |
| 750 | clone->GetOrigin(origin); |
| 751 | clone->GetSpacing(spacing); |
| 752 | double* direction = clone->GetDirectionMatrix()->GetData(); |
| 753 | |
| 754 | // find the location of the min extent |
| 755 | double blockOrigin[3]; |
| 756 | vtkImageData::TransformContinuousIndexToPhysicalPoint( |
| 757 | extents[0], extents[2], extents[4], origin, spacing, direction, blockOrigin); |
| 758 | |
| 759 | // make it so that the clone starts with extent 0,0,0 |
| 760 | for (int cc = 0; cc < 3; cc++) |
| 761 | { |
| 762 | // Transform the origin and the extents. |
| 763 | origin[cc] = blockOrigin[cc]; |
| 764 | extents[2 * cc + 1] -= extents[2 * cc]; |
| 765 | extents[2 * cc] = 0; |
| 766 | } |
| 767 | |
| 768 | clone->SetOrigin(origin); |
| 769 | clone->SetExtent(extents); |
| 770 | } |
| 771 | else if (vtkRectilinearGrid* cloneRGrid = vtkRectilinearGrid::SafeDownCast(dataset)) |
| 772 | { |
| 773 | if (!dataset) |
| 774 | { |
| 775 | cloneRGrid->SetExtent(0, -1, 0, -1, 0, -1); |
| 776 | return; |
| 777 | } |
| 778 | |
| 779 | cloneRGrid->ShallowCopy(this->GetInput(port)); |
| 780 | |
| 781 | // Get the current extents. |
| 782 | int extents[6]; |
| 783 | cloneRGrid->GetExtent(extents); |
| 784 | |
| 785 | // Transform the current extent so that it starts at 0, 0, 0 |
| 786 | for (int cc = 0; cc < 3; cc++) |
| 787 | { |
| 788 | extents[2 * cc + 1] -= extents[2 * cc]; |
no test coverage detected