TTK
Loading...
Searching...
No Matches
FTMStructures.h
Go to the documentation of this file.
1
2//
8
9#pragma once
10
11#include <forward_list>
12#include <iterator>
13#include <memory>
14#include <vector>
15
16#include <boost/heap/fibonacci_heap.hpp>
17
18#include "FTMAtomicVector.h"
19#include "FTMDataTypes.h"
20
21// todo remove
22#include <iostream>
23
24namespace ttk {
25 namespace ftm {
26 // Compute parameters (global)
27 struct Params {
29 bool segm = true;
30 bool normalize = true;
31 bool advStats = true;
32 int samplingLvl = 0;
33 };
34
35#ifdef TTK_ENABLE_FTM_TREE_STATS_TIME
36 struct ActiveTask {
37 float begin = -1;
38 float end = -1;
39 SimplexId origin = nullVertex;
40 };
41#endif
42
43 // Scalar related containers (global)
44 struct Scalars {
46 void *values{};
48
49 // [0] -> vertex id of the global miminum
50 // [size-1] -> vertex id of the global maximum
51 std::vector<SimplexId> sortedVertices{};
52
53 inline bool isLower(const SimplexId a, const SimplexId b) const {
54 return this->offsets[a] < this->offsets[b];
55 }
56 inline bool isEqLower(const SimplexId a, const SimplexId b) const {
57 return this->offsets[a] <= this->offsets[b];
58 }
59 inline bool isHigher(const SimplexId a, const SimplexId b) const {
60 return this->offsets[a] > this->offsets[b];
61 }
62 inline bool isEqHigher(const SimplexId a, const SimplexId b) const {
63 return this->offsets[a] >= this->offsets[b];
64 }
65 };
66
67 struct CurrentState {
69 boost::heap::fibonacci_heap<SimplexId, boost::heap::compare<VertCompFN>>
71
72 CurrentState(SimplexId startVert, VertCompFN &vertComp)
73 : vertex(startVert), propagation(vertComp) {
74 }
75
77 : vertex(nullVertex), propagation(vertComp) {
78 // will need to use setStartVert before use
79 }
80
81 void setStartVert(const SimplexId v) {
82 vertex = v;
83 }
84
86 vertex = propagation.top();
87 propagation.pop();
88 return vertex;
89 }
90
91 void addNewVertex(const SimplexId v) {
92 propagation.emplace(v);
93 }
94
95 void merge(CurrentState &other) {
96 propagation.merge(other.propagation);
97 vertex = propagation.top();
98 }
99
100 bool empty() {
101 return propagation.empty();
102 }
103
104 // DEBUG ONLY
105 bool find(SimplexId v) {
106 return std::find(propagation.begin(), propagation.end(), v)
107 != propagation.end();
108 }
109 };
110
111 struct SharedData {
115
117 : extrema(e), states(50), openedArcs(50) {
118 }
119
120 void addState(CurrentState *curState) {
121 const idThread &thisTask = states.getNext();
122 states[thisTask] = curState;
123 }
124
125 void addArc(const idSuperArc arc) {
126 idSuperArc const thisArc = openedArcs.getNext();
127 openedArcs[thisArc] = arc;
128 }
129
130 void merge(SharedData &other) {
131 for(auto *state : other.states) {
132 addState(state);
133 }
134
135 for(auto &arc : other.openedArcs) {
136 addArc(arc);
137 }
138 }
139
140 void reserve(const size_t &s) {
141 states.reserve(s);
143 }
144 };
145
149
150 using segm_it = std::vector<SimplexId>::iterator;
151 using segm_rev_it = std::vector<SimplexId>::reverse_iterator;
152 using segm_const_it = std::vector<SimplexId>::const_iterator;
153 using segm_const_rev_it = std::vector<SimplexId>::const_reverse_iterator;
154
155 // Segmentation data
156 struct Region {
157 // inverted in case of split tree
160 };
161
162 } // namespace ftm
163} // namespace ttk
TTK processing package that manage a parallel vecrion of vector.
void reserve(const std::size_t &newSize)
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
std::vector< SimplexId >::iterator segm_it
std::function< bool(SimplexId, SimplexId)> VertCompFN
std::vector< SimplexId >::reverse_iterator segm_rev_it
ThreadId idThread
manage number of threads
std::vector< SimplexId >::const_iterator segm_const_it
std::vector< SimplexId >::const_reverse_iterator segm_const_rev_it
The Topology ToolKit.
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22
T end(std::pair< T, T > &p)
Definition ripserpy.cpp:483
T begin(std::pair< T, T > &p)
Definition ripserpy.cpp:479
void merge(CurrentState &other)
CurrentState(SimplexId startVert, VertCompFN &vertComp)
void setStartVert(const SimplexId v)
bool find(SimplexId v)
boost::heap::fibonacci_heap< SimplexId, boost::heap::compare< VertCompFN > > propagation
CurrentState(VertCompFN &vertComp)
SimplexId getNextMinVertex()
void addNewVertex(const SimplexId v)
bool isEqLower(const SimplexId a, const SimplexId b) const
bool isLower(const SimplexId a, const SimplexId b) const
std::vector< SimplexId > sortedVertices
const SimplexId * offsets
bool isHigher(const SimplexId a, const SimplexId b) const
bool isEqHigher(const SimplexId a, const SimplexId b) const
FTMAtomicVector< CurrentState * > states
void addState(CurrentState *curState)
FTMAtomicVector< idSuperArc > openedArcs
void addArc(const idSuperArc arc)
SharedData(SimplexId e)
void merge(SharedData &other)
void reserve(const size_t &s)