71 #ifndef vtkm_worklet_contourtree_chaingraph_h
72 #define vtkm_worklet_contourtree_chaingraph_h
100 namespace contourtree
103 #define DEBUG_STRING_TRANSFER_GOVERNING_SADDLES "Extrema should now be assigned"
104 #define DEBUG_STRING_TRANSFER_SADDLE_STARTS "Transfer Saddle Starts "
105 #define DEBUG_STRING_TRANSFERRED_SADDLE_STARTS "Saddle Starts Transferred"
106 #define DEBUG_STRING_TRANSFER_TO_MERGE_TREE "Transfer to Merge Tree"
107 #define DEBUG_STRING_OUTDEGREE "Outdegree"
108 #define DEBUG_STRING_CHAINEXT "Chain Ext"
109 #define DEBUG_STRING_ACTIVE_OUTDEGREE "Active Outdegree"
110 #define DEBUG_STRING_ACTIVE_CHAINEXT "Active Chain Ext"
111 #define DEBUG_STRING_FAR_ID "Far"
112 #define DEBUG_STRING_FAR_INDEX "Far Index"
113 #define DEBUG_STRING_FAR_VALUE "Far Value"
114 #define DEBUG_STRING_NEAR_ID "Near"
115 #define DEBUG_STRING_NEAR_INDEX "Near Index"
116 #define DEBUG_STRING_NEAR_VALUE "Near Value"
117 #define DEBUG_STRING_EDGE_FAR_ID "Edge Far"
118 #define DEBUG_STRING_EDGE_NEAR_ID "Edge Near"
119 #define DEBUG_STRING_EDGE_NEAR_INDEX "Edge Near Index"
120 #define DEBUG_STRING_EDGE_NEAR_VALUE "Edge Near Value"
121 #define DEBUG_STRING_SORTED_NEAR_ID "Sorted Near"
122 #define DEBUG_STRING_SORTED_NEAR_INDEX "Sorted Near Index"
123 #define DEBUG_STRING_SORTED_NEAR_VALUE "Sorted Near Value"
124 #define DEBUG_STRING_SORTED_FAR_ID "Sorted Far"
126 template <
typename T,
typename StorageType>
218 template <
typename T,
typename StorageType>
221 valueIndex.Allocate(Size);
222 prunesTo.Allocate(Size);
223 firstEdge.Allocate(Size);
224 outdegree.Allocate(Size);
225 chainExtremum.Allocate(Size);
226 activeVertices.Allocate(Size);
230 template <
typename T,
typename StorageType>
233 edgeFar.Allocate(Size);
234 edgeNear.Allocate(Size);
235 activeEdges.Allocate(Size);
239 template <
typename T,
typename StorageType>
242 #ifdef DEBUG_FUNCTION_ENTRY
243 std::cout << std::endl;
244 std::cout <<
"===================" << std::endl;
245 std::cout <<
"Compute Chain Graph" << std::endl;
246 std::cout <<
"===================" << std::endl;
247 std::cout << std::endl;
251 DebugPrint(
"Chain Graph Computation Starting");
256 while (edgeSorter.GetNumberOfValues() > 0)
259 FindGoverningSaddles();
262 TransferRegularPoints();
265 CompactActiveVertices();
266 CompactActiveEdges();
272 TransferSaddleStarts();
282 firstEdge.ReleaseResources();
283 outdegree.ReleaseResources();
284 edgeNear.ReleaseResources();
285 edgeFar.ReleaseResources();
286 activeEdges.ReleaseResources();
287 activeVertices.ReleaseResources();
288 edgeSorter.ReleaseResources();
291 TransferToMergeTree(saddles);
294 chainExtremum.ReleaseResources();
295 prunesTo.ReleaseResources();
298 DebugPrint(
"Chain Graph Computed");
303 template <
typename T,
typename StorageType>
306 #ifdef DEBUG_FUNCTION_ENTRY
307 std::cout << std::endl;
308 std::cout <<
"======================" << std::endl;
309 std::cout <<
"Find Governing Saddles" << std::endl;
310 std::cout <<
"======================" << std::endl;
311 std::cout << std::endl;
317 values, valueIndex, edgeFar, edgeNear, arcArray, isJoinGraph));
320 DebugPrint(
"After Sorting");
326 governingSaddleFinder);
327 vtkm::Id nEdges = edgeSorter.GetNumberOfValues();
330 governingSaddleFinderDispatcher.Invoke(edgeIndexArray,
342 template <
typename T,
typename StorageType>
345 #ifdef DEBUG_FUNCTION_ENTRY
346 std::cout << std::endl;
347 std::cout <<
"=======================" << std::endl;
348 std::cout <<
"Transfer Regular Points" << std::endl;
349 std::cout <<
"=======================" << std::endl;
350 std::cout << std::endl;
354 regularPointTransferrer);
356 regularPointTransferrerDispatcher.Invoke(activeVertices,
363 DebugPrint(
"Regular Points Should Now Be Labelled");
368 template <
typename T,
typename StorageType>
371 #ifdef DEBUG_FUNCTION_ENTRY
372 std::cout << std::endl;
373 std::cout <<
"=======================" << std::endl;
374 std::cout <<
"Compact Active Vertices" << std::endl;
375 std::cout <<
"=======================" << std::endl;
376 std::cout << std::endl;
391 activeVertices.ReleaseResources();
395 DebugPrint(
"Active Vertex List Compacted");
400 template <
typename T,
typename StorageType>
403 #ifdef DEBUG_FUNCTION_ENTRY
404 std::cout << std::endl;
405 std::cout <<
"====================" << std::endl;
406 std::cout <<
"Compact Active Edges" << std::endl;
407 std::cout <<
"====================" << std::endl;
408 std::cout << std::endl;
411 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
416 newOutdegree.
Allocate(nActiveVertices);
423 vertexDegreeUpdater);
425 vertexDegreeUpdaterDispatcher.Invoke(activeVertices,
463 DebugPrint(
"Active Edges Now Compacted");
468 template <
typename T,
typename StorageType>
471 #ifdef DEBUG_FUNCTION_ENTRY
472 std::cout << std::endl;
473 std::cout <<
"============" << std::endl;
474 std::cout <<
"Build Chains" << std::endl;
475 std::cout <<
"============" << std::endl;
476 std::cout << std::endl;
480 tempChainExtremum.
Allocate(edgeNear.GetNumberOfValues());
483 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
485 for (
vtkm::Id shifter = nActiveVertices; shifter != 0; shifter >>= 1)
494 for (
vtkm::Id logStep = 0; logStep < nLogSteps; logStep++)
496 chainDoublerDispatcher.Invoke(activeVertices,
501 DebugPrint(
"Chains Built");
506 template <
typename T,
typename StorageType>
509 #ifdef DEBUG_FUNCTION_ENTRY
510 std::cout << std::endl;
511 std::cout <<
"=======================" << std::endl;
513 std::cout <<
"=======================" << std::endl;
514 std::cout << std::endl;
518 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
526 newFirstEdge.
Allocate(nActiveVertices);
527 newOutdegree.
Allocate(nActiveVertices);
532 saddleAscentFunctor);
534 saddleAscentFunctorDispatcher.Invoke(activeVertices,
547 edgeSorter.ReleaseResources();
548 edgeSorter.Allocate(nEdgesToSort);
552 saddleAscentTransferrer);
554 saddleAscentTransferrerDispatcher.Invoke(activeVertices,
567 template <
typename T,
typename StorageType>
570 #ifdef DEBUG_FUNCTION_ENTRY
571 std::cout << std::endl;
572 std::cout <<
"===========" << std::endl;
573 std::cout <<
"Build Trunk" << std::endl;
574 std::cout <<
"============" << std::endl;
575 std::cout << std::endl;
581 trunkBuilderDispatcher.Invoke(activeVertices,
585 DebugPrint(
"Trunk Built");
590 template <
typename T,
typename StorageType>
593 #ifdef DEBUG_FUNCTION_ENTRY
594 std::cout << std::endl;
595 std::cout <<
"=====================" << std::endl;
597 std::cout <<
"=====================" << std::endl;
598 std::cout << std::endl;
609 joinTreeTransferrer);
612 joinTreeTransferrerDispatcher.Invoke(valueIndexArray,
621 template <
typename T,
typename StorageType>
624 std::cout <<
"---------------------------" << std::endl;
625 std::cout << std::string(message) << std::endl;
626 std::cout <<
"---------------------------" << std::endl;
627 std::cout << std::endl;
638 std::cout <<
"Full Vertex Arrays - Size: " << nValues << std::endl;
647 std::cout << std::endl;
650 vtkm::Id nActiveVertices = activeVertices.GetNumberOfValues();
651 std::cout <<
"Active Vertex Arrays - Size: " << nActiveVertices << std::endl;
652 if (nActiveVertices > 0)
671 std::cout << std::endl;
675 vtkm::Id nEdges = edgeNear.GetNumberOfValues();
676 std::cout <<
"Full Edge Arrays - Size: " << nEdges << std::endl;
699 vtkm::Id nActiveEdges = activeEdges.GetNumberOfValues();
700 std::cout <<
"Active Edge Arrays - Size: " << nActiveEdges << std::endl;
701 if (nActiveEdges > 0)
719 std::cout << std::endl;
723 vtkm::Id nEdgeSorter = edgeSorter.GetNumberOfValues();
724 std::cout <<
"Edge Sorter - Size: " << nEdgeSorter << std::endl;
740 std::cout << std::endl;
743 std::cout <<
"---------------------------" << std::endl;
744 std::cout << std::endl;