shrinking the length of functions used by CastAndCallForTypes in BranchDecompositionTreeMaker.h

This commit is contained in:
Mingzhe Li 2024-07-08 21:51:39 -07:00
parent 67b200c1d5
commit 477c8b488f

@ -341,7 +341,10 @@ inline void BranchDecompositionTreeMaker::ComputeTopVolumeBranchHierarchy(
// 1. parent branch info id: tData.TopVolumeBranchParent
// 2. saddle-end value: tData.TopVolumeBranchSaddleIsovalue
// 3. branch root global regular id (anything that can break tie)
auto resolveBranchParent = [&](const auto& inArray)
IdArrayType topVolSortForOuterSaddleIdx;
vtkm::cont::Algorithm::Copy(topVolBranchesIndex, topVolSortForOuterSaddleIdx);
auto resolveBranchParentSorter = [&](const auto& inArray)
{
using InArrayHandleType = std::decay_t<decltype(inArray)>;
using ValueType = typename InArrayHandleType::ValueType;
@ -350,9 +353,11 @@ inline void BranchDecompositionTreeMaker::ComputeTopVolumeBranchHierarchy(
parentComparator(tData.TopVolumeBranchParent, inArray, tData.TopVolumeBranchRootGRId);
// sort index for all top volume branches
IdArrayType topVolSortForOuterSaddleIdx;
vtkm::cont::Algorithm::Copy(topVolBranchesIndex, topVolSortForOuterSaddleIdx);
vtkm::cont::Algorithm::Sort(topVolSortForOuterSaddleIdx, parentComparator);
};
tData.TopVolumeBranchSaddleIsoValue
.CastAndCallForTypes<vtkm::TypeListScalarAll, vtkm::cont::StorageListBasic>(
resolveBranchParentSorter);
IdArrayType parentPermutation;
vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex<vtkm::Id, IdArrayType>(
@ -424,13 +429,13 @@ inline void BranchDecompositionTreeMaker::ComputeTopVolumeBranchHierarchy(
vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex<vtkm::Id, IdArrayType>(
tData.BranchRootGRId, extraMaximaParentBranch, extraMaximaParentBranchRootGRId);
InArrayHandleType extraMaximaBranchIsoValue;
vtkm::cont::Algorithm::CopyIf(
tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle<InArrayHandleType>(),
IsOuterSaddle,
extraMaximaBranchIsoValue,
vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMaxima());
tData.ExtraMaximaBranchIsoValue = extraMaximaBranchIsoValue;
//InArrayHandleType extraMaximaBranchIsoValue;
//vtkm::cont::Algorithm::CopyIf(
// tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle<InArrayHandleType>(),
// IsOuterSaddle,
// extraMaximaBranchIsoValue,
// vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMaxima());
//tData.ExtraMaximaBranchIsoValue = extraMaximaBranchIsoValue;
// a worklet to binary search a number in a sorted array and return the index
vtkm::worklet::scalar_topology::select_top_volume_contours::IdxIfWithinBlockWorklet
@ -458,13 +463,13 @@ inline void BranchDecompositionTreeMaker::ComputeTopVolumeBranchHierarchy(
vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex<vtkm::Id, IdArrayType>(
tData.BranchRootGRId, extraMinimaParentBranch, extraMinimaParentBranchRootGRId);
InArrayHandleType extraMinimaBranchIsoValue;
vtkm::cont::Algorithm::CopyIf(
tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle<InArrayHandleType>(),
IsOuterSaddle,
extraMinimaBranchIsoValue,
vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMinima());
tData.ExtraMinimaBranchIsoValue = extraMinimaBranchIsoValue;
//InArrayHandleType extraMinimaBranchIsoValue;
//vtkm::cont::Algorithm::CopyIf(
// tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle<InArrayHandleType>(),
// IsOuterSaddle,
// extraMinimaBranchIsoValue,
// vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMinima());
//tData.ExtraMinimaBranchIsoValue = extraMinimaBranchIsoValue;
vtkm::worklet::scalar_topology::select_top_volume_contours::IdxIfWithinBlockWorklet
getParentBranchOrder;
@ -481,10 +486,37 @@ inline void BranchDecompositionTreeMaker::ComputeTopVolumeBranchHierarchy(
vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex<vtkm::Id, IdArrayType>(
branchGRIdByVolumeIdx, permutedExtraMinimaBranchOrder, tData.ExtraMinimaBranchOrder);
}
};
tData.TopVolumeBranchSaddleIsoValue
.CastAndCallForTypes<vtkm::TypeListScalarAll, vtkm::cont::StorageListBasic>(
resolveBranchParent);
auto resolveExtraContourSaddleValue = [&](const auto& inArray)
{
using InArrayHandleType = std::decay_t<decltype(inArray)>;
using ValueType = typename InArrayHandleType::ValueType;
if (extraMaximaParentBranch.GetNumberOfValues())
{
InArrayHandleType extraMaximaBranchIsoValue;
vtkm::cont::Algorithm::CopyIf(
inArray,
IsOuterSaddle,
extraMaximaBranchIsoValue,
vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMaxima());
tData.ExtraMaximaBranchIsoValue = extraMaximaBranchIsoValue;
}
if (extraMinimaParentBranch.GetNumberOfValues())
{
InArrayHandleType extraMinimaBranchIsoValue;
vtkm::cont::Algorithm::CopyIf(
inArray,
IsOuterSaddle,
extraMinimaBranchIsoValue,
vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMinima());
tData.ExtraMinimaBranchIsoValue = extraMinimaBranchIsoValue;
}
};
tData.TopVolumeBranchSaddleIsoValue
.CastAndCallForTypes<vtkm::TypeListScalarAll, vtkm::cont::StorageListBasic>(
resolveExtraContourSaddleValue);
}