----------------------------------------------------------------------------
| 862 | |
| 863 | //---------------------------------------------------------------------------- |
| 864 | bool vtkAxisAlignedTransformFilter::ProcessHTG( |
| 865 | vtkHyperTreeGrid* inputHTG, vtkHyperTreeGrid* outputHTG, int rotationMatrix[3][3]) |
| 866 | { |
| 867 | outputHTG->DeepCopy(inputHTG); |
| 868 | |
| 869 | // If HTG is empty, nothing to do |
| 870 | if (inputHTG->GetMaxNumberOfTrees() == 0) |
| 871 | { |
| 872 | return true; |
| 873 | } |
| 874 | |
| 875 | ::ApplyScale(outputHTG, Scale); |
| 876 | |
| 877 | // Lambda to apply cell level scaling |
| 878 | auto applyCellScale = [this](vtkHyperTreeGrid* htg, double scales[3]) |
| 879 | { |
| 880 | vtkHyperTreeGrid::vtkHyperTreeGridIterator iterator; |
| 881 | iterator.Initialize(htg); |
| 882 | while (vtkHyperTree* tree = iterator.GetNextTree()) |
| 883 | { |
| 884 | vtkNew<vtkHyperTreeGridNonOrientedCursor> cursor; |
| 885 | cursor->Initialize(htg, tree->GetTreeIndex(), false); |
| 886 | if (!cursor->IsMasked()) |
| 887 | { |
| 888 | this->ApplyCellScale(cursor, scales); |
| 889 | } |
| 890 | } |
| 891 | }; |
| 892 | |
| 893 | // Lambda to correctly handle interfaces intercepts and normals |
| 894 | auto interfaceUpdate = [inputHTG, outputHTG]( |
| 895 | double translation[3], double scale[3], int rotMatrix[3][3]) |
| 896 | { |
| 897 | if (inputHTG->GetHasInterface()) |
| 898 | { |
| 899 | vtkDataArray* interceptArray = |
| 900 | outputHTG->GetCellData()->GetArray(outputHTG->GetInterfaceInterceptsName()); |
| 901 | vtkDataArray* normalsArray = |
| 902 | outputHTG->GetCellData()->GetArray(outputHTG->GetInterfaceNormalsName()); |
| 903 | for (vtkIdType i = 0; i < interceptArray->GetNumberOfTuples(); ++i) |
| 904 | { |
| 905 | double distance = interceptArray->GetComponent(i, 0); |
| 906 | double distance2 = interceptArray->GetComponent(i, 1); |
| 907 | double* normal = normalsArray->GetTuple(i); |
| 908 | vtkVector3d t(translation); |
| 909 | vtkVector3d n(rotMatrix[0][0] * normal[0] / scale[0] + |
| 910 | rotMatrix[0][1] * normal[1] / scale[1] + rotMatrix[0][2] * normal[2] / scale[2], |
| 911 | rotMatrix[1][0] * normal[0] / scale[0] + rotMatrix[1][1] * normal[1] / scale[1] + |
| 912 | rotMatrix[1][2] * normal[2] / scale[2], |
| 913 | rotMatrix[2][0] * normal[0] / scale[0] + rotMatrix[2][1] * normal[1] / scale[1] + |
| 914 | rotMatrix[2][2] * normal[2] / scale[2]); |
| 915 | |
| 916 | interceptArray->SetComponent(i, 0, (distance - n.Dot(t))); |
| 917 | interceptArray->SetComponent(i, 1, (distance2 - n.Dot(t))); |
| 918 | normalsArray->SetTuple(i, n.GetData()); |
| 919 | } |
| 920 | } |
| 921 | }; |
no test coverage detected