MCPcopy Create free account
hub / github.com/Kitware/VTK / ProcessHTG

Method ProcessHTG

Filters/General/vtkAxisAlignedTransformFilter.cxx:864–1099  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

862
863//----------------------------------------------------------------------------
864bool 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 };

Callers 1

DispatchMethod · 0.95

Calls 15

ApplyCellScaleMethod · 0.95
FindNormalAxisMethod · 0.95
ComputeCellScaleMethod · 0.95
GetRotatedIdMethod · 0.95
ApplyScaleFunction · 0.85
ApplyTranslationFunction · 0.85
ReverseAxesFunction · 0.85
SwapXYZCoordinatesFunction · 0.85
ApplyMaskFunction · 0.85
CopyRotatedDataHTGFunction · 0.85
GetMaxNumberOfTreesMethod · 0.80

Tested by

no test coverage detected