----------------------------------------------------------------------------
| 765 | |
| 766 | //---------------------------------------------------------------------------- |
| 767 | bool vtkAxisAlignedTransformFilter::ProcessRectilinearGrid( |
| 768 | vtkRectilinearGrid* inputRG, vtkRectilinearGrid* outputRG, int rotationMatrix[3][3]) |
| 769 | { |
| 770 | outputRG->DeepCopy(inputRG); |
| 771 | ::ApplyScale(outputRG, Scale); |
| 772 | if (RotationAngle == ROT0) |
| 773 | { |
| 774 | ::ApplyTranslation(outputRG, Translation); |
| 775 | return true; |
| 776 | } |
| 777 | |
| 778 | int dims[3]; |
| 779 | outputRG->GetDimensions(dims); |
| 780 | |
| 781 | if (outputRG->GetDataDimension() == 1) |
| 782 | { |
| 783 | vtkErrorMacro("Rotations for 1D RectilinearGrid are not supported."); |
| 784 | return false; |
| 785 | } |
| 786 | |
| 787 | // Swap dimensions according to rotation |
| 788 | int newDims[3]; |
| 789 | std::memcpy(newDims, dims, 3 * sizeof(int)); |
| 790 | for (int i = 0; i < 3; ++i) |
| 791 | { |
| 792 | for (int j = 0; j < 3; ++j) |
| 793 | { |
| 794 | if (rotationMatrix[i][j] != 0) |
| 795 | { |
| 796 | newDims[i] = dims[j]; |
| 797 | break; |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | vtkDoubleArray* XCoordinate = vtkDoubleArray::SafeDownCast(outputRG->GetXCoordinates()); |
| 803 | vtkDoubleArray* YCoordinate = vtkDoubleArray::SafeDownCast(outputRG->GetYCoordinates()); |
| 804 | vtkDoubleArray* ZCoordinate = vtkDoubleArray::SafeDownCast(outputRG->GetZCoordinates()); |
| 805 | |
| 806 | // Compute a translation vector for inverted dimensions |
| 807 | // after the rotation to stay in the positive quadrant |
| 808 | int tvec[3] = { 0, 0, 0 }; |
| 809 | for (int i = 0; i < 3; i++) |
| 810 | { |
| 811 | for (int j = 0; j < 3; j++) |
| 812 | { |
| 813 | if (rotationMatrix[i][j] < 0) |
| 814 | { |
| 815 | tvec[j] += std::max(newDims[i] - 1, 1) - 1; |
| 816 | ::ReverseAxes(j, XCoordinate, YCoordinate, ZCoordinate); |
| 817 | } |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | outputRG->SetDimensions(newDims[0], newDims[1], newDims[2]); |
| 822 | XCoordinate->Register(nullptr); |
| 823 | YCoordinate->Register(nullptr); |
| 824 | ZCoordinate->Register(nullptr); |
no test coverage detected