diff --git a/vtkm/filter/scalar_topology/worklet/select_top_volume_contours/BranchDecompositionTreeMaker.h b/vtkm/filter/scalar_topology/worklet/select_top_volume_contours/BranchDecompositionTreeMaker.h index 00ed8bf63..81fa512f3 100644 --- a/vtkm/filter/scalar_topology/worklet/select_top_volume_contours/BranchDecompositionTreeMaker.h +++ b/vtkm/filter/scalar_topology/worklet/select_top_volume_contours/BranchDecompositionTreeMaker.h @@ -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; 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( + resolveBranchParentSorter); IdArrayType parentPermutation; vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex( @@ -424,13 +429,13 @@ inline void BranchDecompositionTreeMaker::ComputeTopVolumeBranchHierarchy( vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex( tData.BranchRootGRId, extraMaximaParentBranch, extraMaximaParentBranchRootGRId); - InArrayHandleType extraMaximaBranchIsoValue; - vtkm::cont::Algorithm::CopyIf( - tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle(), - IsOuterSaddle, - extraMaximaBranchIsoValue, - vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMaxima()); - tData.ExtraMaximaBranchIsoValue = extraMaximaBranchIsoValue; + //InArrayHandleType extraMaximaBranchIsoValue; + //vtkm::cont::Algorithm::CopyIf( + // tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle(), + // 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( tData.BranchRootGRId, extraMinimaParentBranch, extraMinimaParentBranchRootGRId); - InArrayHandleType extraMinimaBranchIsoValue; - vtkm::cont::Algorithm::CopyIf( - tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle(), - IsOuterSaddle, - extraMinimaBranchIsoValue, - vtkm::worklet::scalar_topology::select_top_volume_contours::IsExtraMinima()); - tData.ExtraMinimaBranchIsoValue = extraMinimaBranchIsoValue; + //InArrayHandleType extraMinimaBranchIsoValue; + //vtkm::cont::Algorithm::CopyIf( + // tData.TopVolumeBranchSaddleIsoValue.AsArrayHandle(), + // 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( branchGRIdByVolumeIdx, permutedExtraMinimaBranchOrder, tData.ExtraMinimaBranchOrder); } - }; - tData.TopVolumeBranchSaddleIsoValue - .CastAndCallForTypes( - resolveBranchParent); + + auto resolveExtraContourSaddleValue = [&](const auto& inArray) + { + using InArrayHandleType = std::decay_t; + 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( + resolveExtraContourSaddleValue); }