Go to the documentation of this file.
120 #ifndef vtkm_worklet_contourtree_contourtree_h
121 #define vtkm_worklet_contourtree_contourtree_h
159 namespace contourtree
162 template <
typename T,
typename StorageType>
247 template <
typename InPortalFieldType>
268 template <
typename T,
typename StorageType>
276 , splitTree(SplitTree)
277 , joinGraph(JoinGraph)
278 , splitGraph(SplitGraph)
296 std::cout <<
"========================================" << std::endl;
297 std::cout <<
" " << std::endl;
300 std::cout <<
" " << std::endl;
301 std::cout <<
"========================================" << std::endl;
326 template <
typename T,
typename StorageType>
333 joinGraph.valueIndex.GetNumberOfValues() + splitGraph.valueIndex.GetNumberOfValues();
338 joinGraph.valueIndex, splitGraph.valueIndex);
347 vtkm::Id nValues = values.GetNumberOfValues();
356 regularToCriticalUp);
358 regularToCriticalUpDispatcher.Invoke(candidateIndexArray,
365 joinTree.ComputeAugmentedSuperarcs();
366 joinTree.ComputeAugmentedArcs(candidates);
367 splitTree.ComputeAugmentedSuperarcs();
368 splitTree.ComputeAugmentedArcs(candidates);
395 regularToCandidateDispatcher.Invoke(candidates,
414 subrangeOffsetDispatcher.Invoke(subsetIndexArray,
425 degreeDeltaDispatcher.Invoke(subsetIndexArray,
436 regularToCriticalDown);
438 regularToCriticalDownDispatcher.Invoke(candidates,
456 subrangeOffsetDispatcher.Invoke(subsetIndexArray,
467 degreeDeltaDispatcher.Invoke(subsetIndexArray,
482 fillSupernodesDispatcher.Invoke(upCandidate,
497 supernodes.ReleaseResources();
498 updegree.ReleaseResources();
499 downdegree.ReleaseResources();
501 supernodes.Allocate(nSupernodes);
502 updegree.Allocate(nSupernodes);
503 downdegree.Allocate(nSupernodes);
511 copySupernodesDispatcher.Invoke(isSupernode,
523 joinTree.ComputeAugmentedArcs(supernodes);
524 splitTree.ComputeAugmentedArcs(supernodes);
527 nSupernodes = supernodes.GetNumberOfValues();
529 joinArcs.ReleaseResources();
530 splitArcs.ReleaseResources();
531 joinArcs.Allocate(nSupernodes);
532 splitArcs.Allocate(nSupernodes);
537 setJoinAndSplitArcs);
539 setJoinAndSplitArcsDispatcher.Invoke(supernodes,
547 superarcs.ReleaseResources();
551 activeSupernodes.ReleaseResources();
552 activeSupernodes.Allocate(nSupernodes);
557 DebugPrint(
"Supernodes Found");
562 template <
typename T,
typename StorageType>
568 findLeavesDispatcher.Invoke(activeSupernodes,
575 DebugPrint(
"Leaves Transferred");
580 template <
typename T,
typename StorageType>
584 vtkm::Id nSupernodes = supernodes.GetNumberOfValues();
611 copyJoinSplitDispatcher.Invoke(activeSupernodes,
619 vtkm::Id nActiveSupernodes = activeSupernodes.GetNumberOfValues();
620 for (
vtkm::Id shifter = nActiveSupernodes; shifter != 0; shifter >>= 1)
625 for (
vtkm::Id iteration = 0; iteration < nLogSteps; iteration++)
630 updateOutboundDispatcher.Invoke(activeSupernodes,
644 setSupernodeInwardDispatcher.Invoke(activeSupernodes,
653 DebugPrint(isJoin ?
"Upper Regular Nodes Collapsed" :
"Lower Regular Nodes Collapsed");
658 template <
typename T,
typename StorageType>
662 vtkm::Id nActiveSupernodes = activeSupernodes.GetNumberOfValues();
664 for (
vtkm::Id shifter = nActiveSupernodes; shifter != 0; shifter >>= 1)
668 for (
vtkm::Id logStep = 0; logStep < nLogSteps; logStep++)
673 skipVertexDispatcher.Invoke(activeSupernodes,
680 DebugPrint(
"Trees Compressed");
685 template <
typename T,
typename StorageType>
690 noSuperarcArray.
Allocate(activeSupernodes.GetNumberOfValues());
695 vertexAssignedDispatcher.Invoke(activeSupernodes, superarcs, noSuperarcArray);
700 activeSupernodes.ReleaseResources();
704 DebugPrint(
"Active Supernodes Compressed");
709 template <
typename T,
typename StorageType>
712 if (activeSupernodes.GetNumberOfValues() == 0)
715 vtkm::Id nActiveSupernodes = activeSupernodes.GetNumberOfValues();
719 resetDegreesDispatcher.Invoke(activeSupernodes,
725 sortVector.
Allocate(nActiveSupernodes);
729 if (nActiveSupernodes > 0)
734 copyNeighborsDispatcher.Invoke(activeSupernodeIndexArray,
748 if (nActiveSupernodes > 1)
752 degreeSubrangeOffset);
754 degreeSubrangeOffsetDispatcher.Invoke(subsetIndexArray,
760 if (nActiveSupernodes > 1)
765 degreeDeltaDispatcher.Invoke(subsetIndexArray,
772 if (nActiveSupernodes > 0)
777 copyNeighborsDispatcher.Invoke(activeSupernodeIndexArray,
790 if (nActiveSupernodes > 1)
794 degreeSubrangeOffset);
796 degreeSubrangeOffsetDispatcher.Invoke(subsetIndexArray,
802 if (nActiveSupernodes > 1)
807 degreeDeltaDispatcher.Invoke(subsetIndexArray,
812 DebugPrint(
"Degrees Recomputed");
862 template <
typename T,
typename StorageType>
867 std::vector<vtkm::Pair<vtkm::Id, vtkm::Id>> superarcVector;
868 const auto supernodePortal = supernodes.ReadPortal();
869 const auto superarcPortal = superarcs.ReadPortal();
870 for (
vtkm::Id supernode = 0; supernode < supernodes.GetNumberOfValues(); supernode++)
873 const vtkm::Id regularID = supernodePortal.Get(supernode);
876 const vtkm::Id superTo = superarcPortal.Get(supernode);
886 const vtkm::Id regularTo = supernodePortal.Get(superTo);
889 if (regularID < regularTo)
892 if (superarcPortal.Get(superTo) != supernode)
913 for (
vtkm::Id superarc = 0; superarc < arcVecSize; superarc++)
915 std::cout << std::setw(
PRINT_WIDTH) << saddlePeak.WritePortal().Get(superarc).first <<
" ";
916 std::cout << std::setw(
PRINT_WIDTH) << saddlePeak.WritePortal().Get(superarc).second
923 template <
typename T,
typename StorageType>
926 std::cout <<
"---------------------------" << std::endl;
927 std::cout << std::string(message) << std::endl;
928 std::cout <<
"---------------------------" << std::endl;
929 std::cout << std::endl;
932 vtkm::Id nSupernodes = supernodes.GetNumberOfValues();
946 std::cout << std::endl;
949 vtkm::Id nActiveSupernodes = activeSupernodes.GetNumberOfValues();
973 std::cout << std::endl;
void PrintHeader(vtkm::Id howMany)
Definition: PrintVectors.h:155
VTKM_EXEC vtkm::Id operator()(const vtkm::Id supernode, const InPortalFieldType &superarcs) const
Definition: ContourTree.h:248
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:217
Definition: ChainGraph.h:127
Definition: ContourTree.h:844
VTKM_EXEC_CONT vtkm::Pair< typename std::decay< T1 >::type, typename std::decay< T2 >::type > make_Pair(T1 &&v1, T2 &&v2)
Definition: Pair.h:164
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
void CompressTrees()
Definition: ContourTree.h:659
ChainGraph< T, StorageType > & splitGraph
Definition: ContourTree.h:187
VTKM_EXEC_CONT bool operator()(const vtkm::Pair< vtkm::Id, vtkm::Id > &a, const vtkm::Pair< vtkm::Id, vtkm::Id > &b) const
Definition: ContourTree.h:846
_3(_1, _2) ExecutionSignature
Definition: ContourTree.h:236
Definition: ArrayHandleConcatenate.h:241
Definition: CopyJoinSplit.h:71
bool vertexIsAssigned
Definition: ContourTree.h:239
Definition: CopySupernodes.h:70
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
Definition: ResetDegrees.h:70
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
A control signature tag for output fields.
Definition: WorkletMapField.h:60
Definition: MergeTree.h:126
Definition: UpdateOutbound.h:71
#define PRINT_WIDTH
Definition: PrintVectors.h:77
Definition: RegularToCandidate.h:71
vtkm::Id low
Definition: ContourTree.h:820
vtkm::cont::ArrayHandle< vtkm::Id > superarcs
Definition: ContourTree.h:175
static VTKM_CONT void Sort(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:965
bool operator<(const EdgePair LHS, const EdgePair RHS)
Definition: ContourTree.h:831
void CompressActiveSupernodes()
Definition: ContourTree.h:686
VTKM_CONT T ArrayGetValue(vtkm::Id id, const vtkm::cont::ArrayHandle< T, S > &data)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:264
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
void CollapseRegular(bool isJoin)
Definition: ContourTree.h:581
Definition: SetSupernodeInward.h:71
Definition: DegreeDelta.h:70
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::ArrayHandle< vtkm::Id > updegree
Definition: ContourTree.h:190
void PrintValues(std::string label, vtkm::cont::ArrayHandle< T, StorageType > &dVec, vtkm::Id nValues=-1)
Definition: PrintVectors.h:174
vtkm::cont::ArrayHandle< vtkm::Id > supernodes
Definition: ContourTree.h:178
static VTKM_CONT void Unique(vtkm::cont::DeviceAdapterId devId, vtkm::cont::ArrayHandle< T, Storage > &values)
Definition: Algorithm.h:1063
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
_1 InputDomain
Definition: ContourTree.h:237
Definition: ContourTree.h:232
A control signature tag for input fields.
Definition: WorkletMapField.h:49
static VTKM_CONT T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:816
Implicitly permutes the values in an array.
Definition: ArrayHandlePermutation.h:227
FirstType first
The pair's first object.
Definition: Pair.h:50
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
static VTKM_CONT void CopyIf(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< U, CStencil > &stencil, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:435
EdgePair(vtkm::Id Low=-1, vtkm::Id High=-1)
Definition: ContourTree.h:823
vtkm::cont::ArrayHandle< vtkm::Id > downdegree
Definition: ContourTree.h:190
ChainGraph< T, StorageType > & joinGraph
Definition: ContourTree.h:187
void(FieldIn supernode, WholeArrayIn superarcs, FieldOut hasSuperArc) ControlSignature
Definition: ContourTree.h:235
#define NO_VERTEX_ASSIGNED
Definition: filter/scalar_topology/worklet/contourtree/Types.h:77
MergeTree< T, StorageType > & splitTree
Definition: ContourTree.h:184
An array handle with a constant value.
Definition: ArrayHandleConstant.h:63
Definition: RegularToCriticalDown.h:71
Definition: SkipVertex.h:71
void DebugPrint(const char *message)
Definition: ContourTree.h:924
vtkm::Id high
Definition: ContourTree.h:820
const vtkm::cont::ArrayHandle< T, StorageType > values
Definition: ContourTree.h:172
void FindSupernodes()
Definition: ContourTree.h:327
ContourTree(const vtkm::cont::ArrayHandle< T, StorageType > &Values, MergeTree< T, StorageType > &JoinTree, MergeTree< T, StorageType > &SplitTree, ChainGraph< T, StorageType > &JoinGraph, ChainGraph< T, StorageType > &SplitGraph)
Definition: ContourTree.h:269
Definition: ContourTree.h:817
Definition: ContourTree.h:163
Definition: FillSupernodes.h:70
Definition: SetJoinAndSplitArcs.h:71
Definition: RegularToCriticalUp.h:70
void CollectSaddlePeak(vtkm::cont::ArrayHandle< vtkm::Pair< vtkm::Id, vtkm::Id >> &saddlePeak)
Definition: ContourTree.h:863
void TransferLeaves()
Definition: ContourTree.h:563
void PrintIndices(std::string label, vtkm::cont::ArrayHandle< vtkm::Id > &iVec, vtkm::Id nIndices=-1)
Definition: PrintVectors.h:202
VTKM_EXEC_CONT VertexAssigned(bool VertexIsAssigned)
Definition: ContourTree.h:242
Definition: SubrangeOffset.h:70
vtkm::cont::ArrayHandle< vtkm::Id > splitArcs
Definition: ContourTree.h:193
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
Definition: DegreeSubrangeOffset.h:71
vtkm::Id nIterations
Definition: ContourTree.h:196
MergeTree< T, StorageType > & joinTree
Definition: ContourTree.h:184
SecondType second
The pair's second object.
Definition: Pair.h:55
vtkm::cont::ArrayHandle< vtkm::Id > activeSupernodes
Definition: ContourTree.h:181
Definition: FindLeaves.h:71
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
void FindDegrees()
Definition: ContourTree.h:710
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::cont::ArrayHandle< vtkm::Id > joinArcs
Definition: ContourTree.h:193
Definition: CopyNeighbors.h:71