119 #ifndef vtk_m_filter_scalar_topology_worklet_HierarchicalVolumetricBranchDecomposer_h
120 #define vtk_m_filter_scalar_topology_worklet_HierarchicalVolumetricBranchDecomposer_h
142 #define DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
149 namespace scalar_topology
204 template <
typename IdArrayHandleType,
typename DataValueArrayHandleType>
205 static std::string
PrintBranches(
const IdArrayHandleType& hierarchicalTreeSuperarcsAH,
206 const IdArrayHandleType& hierarchicalTreeSupernodesAH,
207 const IdArrayHandleType& hierarchicalTreeRegularNodeGlobalIdsAH,
208 const DataValueArrayHandleType& hierarchicalTreeDataValuesAH,
209 const IdArrayHandleType& branchRootAH);
213 std::string
DebugPrint(std::string message,
const char* fileName,
long lineNum);
229 auto hierarchicalTreeSupernodes = hierarchicalTreeDataSet.
GetField(
"Supernodes")
232 auto hierarchicalTreeSuperarcs = hierarchicalTreeDataSet.
GetField(
"Superarcs")
235 auto hierarchicalTreeRegularNodeGlobalIds =
236 hierarchicalTreeDataSet.
GetField(
"RegularNodeGlobalIds")
250 LocalBestUpDownByVolumeInitSuperarcListWorklet{},
251 hierarchicalTreeSuperarcs,
255 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
257 std::stringstream resultStream;
261 "Superarc List", superarcList, -1, resultStream);
262 resultStream << std::endl;
272 hierarchicalTreeSuperarcs,
281 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
283 std::stringstream resultStream;
286 "Actual Superarcs", actualSuperarcs, -1, resultStream);
287 resultStream << std::endl;
304 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
314 vtkm::worklet::scalar_topology::hierarchical_volumetric_branch_decomposer::
315 LocalBestUpDownByVolumeBestUpDownEdgeWorklet bestUpDownEdgeWorklet(totalVolume);
318 auto permutedHierarchicalTreeSuperarcs =
320 auto permutedDependetValues =
322 auto permutedIntrinsicValues =
324 auto permutedUpVolume =
326 auto permitedDownVolume =
329 this->
Invoke(bestUpDownEdgeWorklet,
330 permutedHierarchicalTreeSuperarcs,
331 permutedDependetValues,
332 permutedIntrinsicValues,
338 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
341 std::stringstream resultStream;
345 "Superarc List", superarcList, -1, resultStream);
346 resultStream << std::endl;
355 vtkm::worklet::scalar_topology::hierarchical_volumetric_branch_decomposer::
356 SuperArcVolumetricComparatorIndirectGlobalIdComparator
357 SuperArcVolumetricComparatorIndirectGlobalIdComparator(
358 this->
UpVolume, superarcList, hierarchicalTreeRegularNodeGlobalIds,
false);
360 SuperArcVolumetricComparatorIndirectGlobalIdComparator);
363 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
365 std::stringstream resultStream;
367 <<
"Actual Superarc List After Sorting By High End (Full Array, including ignored elements)"
371 "Actual Superarcs", actualSuperarcs, -1, resultStream);
372 resultStream << std::endl;
378 auto permutedUpVolume =
381 LocalBestUpDownByVolumeWorklet<true>{ nActualSuperarcs },
385 hierarchicalTreeRegularNodeGlobalIds,
386 hierarchicalTreeSupernodes,
391 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
393 DebugPrint(
"BestDownSupernode Written", __FILE__, __LINE__));
398 vtkm::worklet::scalar_topology::hierarchical_volumetric_branch_decomposer::
399 SuperArcVolumetricComparatorIndirectGlobalIdComparator
400 SuperArcVolumetricComparatorIndirectGlobalIdComparator(
401 this->
DownVolume, superarcList, hierarchicalTreeRegularNodeGlobalIds,
true);
403 SuperArcVolumetricComparatorIndirectGlobalIdComparator);
406 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
408 std::stringstream resultStream;
410 <<
"Actual Superarc List After Sorting By Low End (Full Array, including ignored elements)"
414 "Actual Superarcs", actualSuperarcs, -1, resultStream);
415 resultStream << std::endl;
422 auto permutedDownVolume =
425 LocalBestUpDownByVolumeWorklet<false>{ nActualSuperarcs },
429 hierarchicalTreeRegularNodeGlobalIds,
430 hierarchicalTreeSupernodes,
436 #ifdef DEBUG_HIERARCHICAL_VOLUMETRIC_BRANCH_DECOMPOSER
438 DebugPrint(
"Local Best Up/Down Computed", __FILE__, __LINE__));
448 auto hierarchicalTreeSupernodes = hierarchicalTreeDataSet.
GetField(
"Supernodes")
451 auto hierarchicalTreeSuperarcs = hierarchicalTreeDataSet.
GetField(
"Superarcs")
454 auto hierarchicalTreeRegularNodeGlobalIds =
455 hierarchicalTreeDataSet.
GetField(
"RegularNodeGlobalIds")
458 auto hierarchicalTreeRegularNodeSortOrder =
459 hierarchicalTreeDataSet.
GetField(
"RegularNodeSortOrder")
462 auto hierarchicalTreeRegular2Supernode = hierarchicalTreeDataSet.
GetField(
"Regular2Supernode")
465 auto hierarchicalTreeWhichRound = hierarchicalTreeDataSet.
GetField(
"WhichRound")
475 hierarchicalTreeRegularNodeSortOrder, hierarchicalTreeRegularNodeGlobalIds
478 hierarchicalTreeSuperarcs
481 using vtkm::worklet::scalar_topology::hierarchical_volumetric_branch_decomposer::
482 CollapseBranchesWorklet;
483 this->
Invoke(CollapseBranchesWorklet{},
487 findSuperArcBetweenNodes,
488 hierarchicalTreeRegular2Supernode,
489 hierarchicalTreeWhichRound,
502 for (
vtkm::Id iteration = 0; iteration < nLogSteps; iteration++)
505 using vtkm::filter::scalar_topology::hierarchical_volumetric_branch_decomposer::
506 CollapseBranchesPointerDoublingWorklet;
507 this->
Invoke(CollapseBranchesPointerDoublingWorklet{}, branchRoot);
524 template <
typename IdArrayHandleType,
typename DataValueArrayHandleType>
526 const IdArrayHandleType& hierarchicalTreeSuperarcsAH,
527 const IdArrayHandleType& hierarchicalTreeSupernodesAH,
528 const IdArrayHandleType& hierarchicalTreeRegularNodeGlobalIdsAH,
529 const DataValueArrayHandleType& hierarchicalTreeDataValuesAH,
530 const IdArrayHandleType& branchRootAH)
532 auto hierarchicalTreeSuperarcsPortal = hierarchicalTreeSuperarcsAH.ReadPortal();
533 vtkm::Id nSuperarcs = hierarchicalTreeSuperarcsAH.GetNumberOfValues();
534 auto hierarchicalTreeSupernodesPortal = hierarchicalTreeSupernodesAH.ReadPortal();
535 auto hierarchicalTreeRegularNodeGlobalIdsPortal =
536 hierarchicalTreeRegularNodeGlobalIdsAH.ReadPortal();
537 auto hierarchicalTreeDataValuesPortal = hierarchicalTreeDataValuesAH.ReadPortal();
538 auto branchRootPortal = branchRootAH.ReadPortal();
540 std::stringstream resultStream;
543 for (
vtkm::Id superarc = 0; superarc < nSuperarcs; superarc++)
547 hierarchicalTreeSuperarcsPortal.Get(superarc)))
553 vtkm::Id branchRootSuperId = branchRootPortal.Get(superarc);
554 vtkm::Id branchRootRegularId = hierarchicalTreeSupernodesPortal.Get(branchRootSuperId);
556 hierarchicalTreeRegularNodeGlobalIdsPortal.Get(branchRootRegularId);
559 vtkm::Id superFromRegularId = hierarchicalTreeSupernodesPortal.Get(superarc);
560 vtkm::Id superFromGlobalId = hierarchicalTreeRegularNodeGlobalIdsPortal.Get(superFromRegularId);
561 typename DataValueArrayHandleType::ValueType superFromValue =
562 hierarchicalTreeDataValuesPortal.Get(superFromRegularId);
563 resultStream << branchRootGlobalId <<
"\t" << superFromValue <<
"\t" << superFromGlobalId
568 hierarchicalTreeSuperarcsPortal.Get(superarc));
569 vtkm::Id superToGlobalId = hierarchicalTreeRegularNodeGlobalIdsPortal.Get(superToRegularId);
570 typename DataValueArrayHandleType::ValueType superToValue =
571 hierarchicalTreeDataValuesPortal.Get(superToRegularId);
572 resultStream << branchRootGlobalId <<
"\t" << superToValue <<
"\t" << superToGlobalId
576 return resultStream.str();
582 auto hierarchicalTreeSuperarcsAH =
584 auto hierarchicalTreeSupernodesAH =
587 auto hierarchicalTreeRegularNodeGlobalIdsAH =
592 auto hierarchicalTreeDataValuesData = ds.
GetField(
"DataValues").
GetData();
599 hierarchicalTreeDataValuesData.CastAndCallForTypes<
TypeListScalarAll, VTKM_DEFAULT_STORAGE_LIST>(
600 [&](
const auto& hierarchicalTreeDataValuesAH) {
602 hierarchicalTreeSupernodesAH,
603 hierarchicalTreeRegularNodeGlobalIdsAH,
604 hierarchicalTreeDataValuesAH,
614 const char* fileName,
617 std::stringstream resultStream;
618 resultStream <<
"----------------------------------------" << std::endl;
619 resultStream << std::setw(30) << std::left << fileName <<
":" << std::right << std::setw(4)
620 << lineNum << std::endl;
621 resultStream << std::left << message << std::endl;
622 resultStream <<
"Hypersweep Value Array Contains: " << std::endl;
623 resultStream <<
"----------------------------------------" << std::endl;
624 resultStream << std::endl;
629 "Up Volume by SA", this->
UpVolume, -1, resultStream);
631 "Down Volume by SA", this->
DownVolume, -1, resultStream);
635 "Best Down Volume by SN", this->
BestDownVolume, -1, resultStream);
639 "Best Up Volume by SN", this->
BestUpVolume, -1, resultStream);
640 std::cout << std::endl;
641 return resultStream.str();