TTK
Loading...
Searching...
No Matches
CTA_contourtree.h
Go to the documentation of this file.
1#pragma once
2
3#include <fstream>
4#include <functional>
5#include <iostream>
6#include <memory>
7#include <queue>
8#include <stack>
9
10namespace ttk {
11
12 namespace cta {
13
14 //#####################################################################################################################
15 // enums and structs for tree data structure
16
17 //=====================================================================================================================
18 // node types of a contour tree
20
21 //=====================================================================================================================
22 // Tree Data Structure with arbitrary degree
23
48 struct Tree {
49 std::vector<std::shared_ptr<Tree>> children;
52 int id;
53 int size;
54 int height;
56 float volume;
57 };
58
59 //=====================================================================================================================
60 // Binary Tree Data Structure
61
94 struct BinaryTree {
95 std::shared_ptr<BinaryTree> child1;
96 std::shared_ptr<BinaryTree> child2;
99 int id;
100 int size;
103 float area;
104 float volume;
106 std::vector<int> region;
107
108 // for fuzzy trees
109 int freq;
110 std::vector<std::pair<int, int>> nodeRefs;
111 std::vector<std::pair<int, int>> arcRefs;
112 };
113
114 //=====================================================================================================================
115 // Structs for unrooted Contour Tree
116
117 struct CTEdge;
118
137 struct CTNode {
138
142
143 std::vector<int> edgeList;
144 };
145
166 struct CTEdge {
167
171 float area;
172 std::vector<int> region;
173 float volume;
174 int segId;
175 };
176
178 // class for an unrooted contour tree
179
197
198 public:
216 ContourTree(float *scalars,
217 int *regionSizes,
218 int *segmentationIds,
219 long long *topology,
220 size_t nVertices,
221 size_t nEdges,
222 std::vector<std::vector<int>> regions = {});
223
226
232 std::shared_ptr<BinaryTree> rootAtMax();
233
241 std::shared_ptr<BinaryTree>
242 rootAtNode(const std::shared_ptr<CTNode> &root);
243
247 bool isBinary();
248
251 void computeBranches();
252
257 std::pair<std::vector<std::shared_ptr<CTNode>>,
258 std::vector<std::shared_ptr<CTEdge>>>
259 getGraph();
260
261 private:
262 std::vector<std::shared_ptr<CTNode>> nodes;
263 std::vector<std::shared_ptr<CTEdge>> arcs;
264
265 bool binary;
266
267 std::shared_ptr<Tree>
268 computeRootedTree(const std::shared_ptr<CTNode> &node,
269 const std::shared_ptr<CTEdge> &parent,
270 int &id);
271 std::shared_ptr<BinaryTree>
272 computeRootedTree_binary(const std::shared_ptr<CTNode> &node,
273 const std::shared_ptr<CTEdge> &parent,
274 int &id);
275 std::pair<float, std::vector<int>> pathToMax(int root, int parent);
276 std::pair<float, std::vector<int>> pathToMin(int root, int parent);
277 };
278
279 }; // namespace cta
280}; // namespace ttk
Contour Tree Data Structure for an unrooted contour tree of unbounded degree for internal use from th...
~ContourTree()
Destructor of internal contour tree class.
std::pair< std::vector< std::shared_ptr< CTNode > >, std::vector< std::shared_ptr< CTEdge > > > getGraph()
std::shared_ptr< BinaryTree > rootAtMax()
std::shared_ptr< BinaryTree > rootAtNode(const std::shared_ptr< CTNode > &root)
The Topology ToolKit.
Basic tree data structure for a rooted contour tree of degree 2 and rooted contour tree alignments of...
std::vector< int > region
std::shared_ptr< BinaryTree > child1
std::vector< std::pair< int, int > > nodeRefs
std::vector< std::pair< int, int > > arcRefs
std::shared_ptr< BinaryTree > child2
Basic data structure for an edge of an unrooted contour tree.
std::vector< int > region
Basic data structure for a node of an unrooted contour tree.
std::vector< int > edgeList
Basic tree data structure for a rooted contour tree of unbounded degree.
std::vector< std::shared_ptr< Tree > > children