53 #ifndef vtk_m_worklet_contourtree_augmented_contourtreemaker_h
54 #define vtk_m_worklet_contourtree_augmented_contourtreemaker_h
113 namespace contourtree_augmented
148 template <
class Mesh,
class MeshBoundaryExecObj>
151 const MeshBoundaryExecObj& meshBoundary);
171 void DebugPrint(
const char* message,
const char* fileName,
long lineNum);
181 : ContourTreeResult(contourTree)
183 , SplitTree(splitTree)
186 , AugmentedJoinSuperarcs()
187 , AugmentedSplitSuperarcs()
231 "defines a contour forest rather than a simple tree.");
248 DebugPrint(
"Contour Tree Constructed. Now Swizzling", __FILE__, __LINE__);
265 this->ContourTreeResult.Hyperparents,
266 this->ContourTreeResult.Supernodes,
267 this->ContourTreeResult.WhenTransferred));
271 PermuteArray<vtkm::Id>(
274 PermuteArray<vtkm::Id>(
277 PermuteArray<vtkm::Id>(
294 permutedSuperSortIndex);
303 this->
Invoke(permuteSuperarcsWorklet,
310 PermuteArray<vtkm::Id>(
319 this->ContourTreeResult.Hypernodes,
320 permutedWhenTransferred);
332 oneIfHypernodeFunctor(
334 this->ContourTreeResult.WhenTransferred));
337 newHypernodes.
Allocate(nHypernodes);
342 setNewHypernodesAndArcsWorklet;
343 this->
Invoke(setNewHypernodesAndArcsWorklet,
345 this->ContourTreeResult.WhenTransferred,
346 this->ContourTreeResult.Hypernodes,
347 this->ContourTreeResult.Hyperarcs,
348 newHypernodePosition,
375 hypernodesSetFirstSuperchildWorklet;
376 this->
Invoke(hypernodesSetFirstSuperchildWorklet,
379 this->ContourTreeResult.Hypernodes);
386 resetHyperparentsIdWorklet;
395 this->ContourTreeResult.FirstSupernodePerIteration);
398 setFirstSupernodePerIterationWorklet;
399 auto tempSupernodesIndex =
401 this->
Invoke(setFirstSupernodePerIterationWorklet,
404 this->ContourTreeResult.FirstSupernodePerIteration
411 auto firstSupernodePerIterationPortal =
415 if (firstSupernodePerIterationPortal.Get(iteration) == 0)
417 firstSupernodePerIterationPortal.Set(iteration,
418 firstSupernodePerIterationPortal.Get(iteration + 1));
423 this->ContourTreeResult.Supernodes.GetNumberOfValues() - 1);
425 this->ContourTreeResult.Supernodes.GetNumberOfValues());
438 this->ContourTreeResult.FirstHypernodePerIteration
444 this->ContourTreeResult.Hypernodes.GetNumberOfValues() - 1);
447 this->ContourTreeResult.Hypernodes.GetNumberOfValues());
449 DebugPrint(
"Contour Tree Super Structure Constructed", __FILE__, __LINE__);
458 auto supernodesIndex =
463 this->ContourTreeResult.Superparents);
472 this->ContourTreeResult.Supernodes.GetNumberOfValues());
473 this->
Invoke(locateSuperarcsWorklet,
475 this->ContourTreeResult.WhenTransferred,
476 this->ContourTreeResult.Hyperparents,
477 this->ContourTreeResult.Hyperarcs,
478 this->ContourTreeResult.Hypernodes,
479 this->ContourTreeResult.Supernodes,
486 this->ContourTreeResult.Nodes);
491 this->ContourTreeResult.Superarcs));
496 this->
Invoke(setArcsWorklet,
498 this->ContourTreeResult.Superparents,
499 this->ContourTreeResult.Superarcs,
500 this->ContourTreeResult.Supernodes,
501 this->ContourTreeResult.Arcs);
503 DebugPrint(
"Regular Structure Computed", __FILE__, __LINE__);
509 template <
typename T>
524 template <
class Mesh,
class MeshBoundaryExecObj>
528 const MeshBoundaryExecObj& meshBoundaryExecObj)
531 auto supernodesIndex =
536 auto permutedSuperparents =
546 this->ContourTreeResult.Supernodes.GetNumberOfValues());
547 this->
Invoke(locateSuperarcsOnBoundaryWorklet,
550 this->ContourTreeResult.Hyperparents,
551 this->ContourTreeResult.Hyperarcs,
552 this->ContourTreeResult.Hypernodes,
553 this->ContourTreeResult.Supernodes,
557 meshBoundaryExecObj);
563 this->ContourTreeResult.Augmentnodes);
574 auto permutedToCompressed =
578 permutedToCompressed);
590 augmentnodes_sorted);
601 this->
Invoke(setAugmentArcsWorklet,
605 this->ContourTreeResult.Supernodes,
607 this->ContourTreeResult.Augmentarcs);
609 DebugPrint(
"Regular Boundary Structure Computed", __FILE__, __LINE__);
666 vtkm::Id nSupernodes = nJoinSupernodes + nSplitSupernodes;
672 this->
JoinTree.
Supernodes, 0, nJoinSupernodes, this->ContourTreeResult.Supernodes, 0);
676 this->ContourTreeResult.Supernodes,
689 newJoinID.
Allocate(nJoinSupernodes);
691 newSplitID.
Allocate(nSplitSupernodes);
697 joinSuperparents.
Allocate(nSupernodes);
699 splitSuperparents.
Allocate(nSupernodes);
702 initNewJoinSplitIDAndSuperparentsWorklet;
703 this->
Invoke(initNewJoinSplitIDAndSuperparentsWorklet,
705 this->JoinTree.Superparents,
706 this->SplitTree.Superparents,
707 this->JoinTree.Supernodes,
708 this->SplitTree.Supernodes,
728 this->
Invoke(setAugmentedJoinArcsWorklet,
733 this->AugmentedJoinSuperarcs);
745 this->
Invoke(setAugmentedSplitArcsWorklet,
750 this->AugmentedSplitSuperarcs);
769 DebugPrint(
"Supernodes Found", __FILE__, __LINE__);
797 template <
typename DeviceAdapter,
typename... Args>
798 inline bool operator()(DeviceAdapter device, Args&&... args)
const
812 dispatcher.SetDevice(device);
813 dispatcher.Invoke(std::forward<Args>(args)...);
853 this->
Invoke(initInAndOutboundWorklet,
861 DebugPrint(
"Init in and outbound -- Step 1", __FILE__, __LINE__);
873 for (
vtkm::Id iteration = 0; iteration < numLogSteps; iteration++)
877 this->
Invoke(collapsePastRegularWorklet,
884 DebugPrint(
"Init in and outbound -- Step 2", __FILE__, __LINE__);
917 this->ContourTreeResult.Hyperarcs,
918 this->ContourTreeResult.Superarcs,
919 this->ContourTreeResult.WhenTransferred);
921 DebugPrint(isJoin ?
"Upper Regular Chains Transferred" :
"Lower Regular Chains Transferred",
940 for (
vtkm::Id logStep = 0; logStep < numLogSteps; logStep++)
943 this->
Invoke(compressTreesStepWorklet,
946 this->AugmentedJoinSuperarcs,
947 this->AugmentedSplitSuperarcs
952 DebugPrint(
"Trees Compressed", __FILE__, __LINE__);
964 auto wasNotTransferred =
968 auto notTransferredActiveSupernodes =
972 this->
ActiveSupernodes, notTransferredActiveSupernodes, compressedActiveSupernodes);
976 compressedActiveSupernodes;
978 DebugPrint(
"Active Supernodes Compressed", __FILE__, __LINE__);
995 DebugPrint(
"Degrees Set to 0", __FILE__, __LINE__);
1018 this->
Invoke(joinSubractLHEWorklet, inNeighbour, this->
Updegree);
1037 DebugPrint(
"Degrees Computed", __FILE__, __LINE__);
1045 std::string childString = std::string(message);
1047 <<
"==========================================================================================="
1048 "==============================================="
1049 <<
"=============================================="
1051 "=============================================================================================="
1052 "============================================"
1055 <<
"==========================================================================================="
1056 "==============================================="
1057 <<
"=============================================="
1059 "=============================================================================================="
1060 "============================================"
1063 <<
"==========================================================================================="
1064 "==============================================="
1065 <<
"=============================================="
1067 "=============================================================================================="
1068 "============================================"
1070 std::cout << std::setw(30) << std::left << fileName <<
":" << std::right << std::setw(4)
1071 << lineNum << std::endl;
1072 std::cout << std::left << std::string(message) << std::endl;
1077 (childString + std::string(
": Contour Tree")).c_str(), fileName, lineNum);
1079 <<
"==========================================================================================="
1080 "==============================================="
1081 <<
"=============================================="
1083 "=============================================================================================="
1084 "============================================"
1088 std::cout << std::setw(30) << std::left << fileName <<
":" << std::right << std::setw(4)
1089 << lineNum << std::endl;
1090 std::cout << std::left << std::string(message) << std::endl;
1091 std::cout <<
"Contour Tree Maker Contains: " << std::endl;
1092 std::cout <<
"------------------------------------------------------" << std::endl;