-
Notifications
You must be signed in to change notification settings - Fork 10
/
Skeleton.h
83 lines (64 loc) · 1.73 KB
/
Skeleton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef IMAGEPROCESSING_TUBES_SKELETON_H__
#define IMAGEPROCESSING_TUBES_SKELETON_H__
#include <memory>
#include <stack>
#include <vector>
#include <lemon/list_graph.h>
#include "GraphVolume.h"
/**
* Represents a skeleton as a graph of terminal nodes and branch points.
*/
class Skeleton : public GraphVolume {
public:
/**
* Skeleton graph datastructures: Nodes are terminal and branch points,
* edges indicate skeleton segments between nodes.
*/
typedef lemon::ListGraph Graph;
typedef Graph::Node Node;
typedef Graph::Edge Edge;
typedef Graph::NodeMap<float> Diameters;
/**
* Create an empty skeleton.
*/
Skeleton();
/**
* Move constructor.
*/
Skeleton(Skeleton&& other) = default;
/**
* Copy constructor.
*/
Skeleton(const Skeleton& other);
/**
* Assignment operator.
*/
Skeleton& operator=(const Skeleton& other);
/**
* Start a new segment (a chain of nodes) in the skeleton at the given
* position.
*/
Node openSegment(Position pos, float diameter);
/**
* Extend the currently open segment by one position.
*/
Node extendSegment(Position pos, float diameter);
/**
* Close the currently open segment, backtrack to the end of the previous
* segment in the tree.
*/
void closeSegment();
/**
* Get a node property map with the diameters of each skeleton node.
*/
Diameters& diameters() { return *_diameters; }
const Diameters& diameters() const { return *_diameters; }
private:
void copy(const Skeleton& other);
// list of previous segment end nodes
std::stack<Node> _currentSegmentPath;
// previously added node
Node _prevNode = lemon::INVALID;
std::unique_ptr<Diameters> _diameters{new Diameters(graph())};
};
#endif // IMAGEPROCESSING_TUBES_SKELETON_H__