MeVisLab Toolbox Reference
mlVesselNode.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_VESSEL_NODE_H
14 #define ML_VESSEL_NODE_H
15 
16 
18 
19 #include "mlVesselGraphSystem.h"
20 #include "VesselGraphTypes.h"
21 #include "mlBaseGraphItem.h"
22 #include "mlVesselEdge.h"
23 #include "mlPropertiesMacros.h"
24 
26 
29 {
30 friend class Graph;
31 friend class VesselEdge;
32 friend class LoadTreeData;
33 
34 public:
36 #if ML_DEPRECATED_SINCE(3,5,0)
37  ML_DEPRECATED VesselNode(const VesselNode& other);
38 #endif
40  ~VesselNode() override { assert(_edges.empty()); }
41 
43 #if ML_DEPRECATED_SINCE(3,5,0)
45 #endif
46 
48  void copyProperties(const VesselNode* other);
49 
50  bool operator==(const VesselNode& other) const;
51  bool operator!=(const VesselNode& other) const { return !(*this==other); }
52 
56  bool isRoot() const;
57  bool isEnd() const;
58  bool isBranch() const;
59  int nodeType() const;
60 
62  size_t getEdgeNum() const { return _edges.size(); }
64  VesselEdge* getDepEdge(size_t i) { return _edges[i]; }
66  const VesselEdge* getDepEdge(size_t i) const { return _edges[i]; }
68  std::vector<VesselEdge*>* edges() { return &_edges; }
69 
71  VesselNode* getDepNode(size_t i);
73  const VesselNode* getDepNode(size_t i)const;
75  bool isPred(size_t i) const { return _edges[i]->succNode()==this; }
77  bool isSucc(size_t i) const { return _edges[i]->predNode()==this; }
79  bool isCycle(size_t i)const { return _edges[i]->isCycle(); }
80 
82  bool closeCycle();
86  const VesselNode* getPredNode() const;
90  const VesselEdge* getPredEdge() const;
92 
96 
98  void setVectorPos(const ImageVector& position) { setPos(Vector3(static_cast<MLdouble>(position.x), static_cast<MLdouble>(position.y), static_cast<MLdouble>(position.z))); }
100  ImageVector getVectorPos() const { return ImageVector(static_cast<int>(getPos()[0]), static_cast<int>(getPos()[1]), static_cast<int>(getPos()[2]), 0, 0, 0); }
101 
104  double distance(const Vector3& position) const { return (position - getPos()).length(); }
105 
107  void transform(const Matrix4& m);
108 
111 
115 
119  STATIC_GRAPH_PROPERTY(MLdouble, minDistance, MinDistance);
120  STATIC_GRAPH_PROPERTY(MLdouble, maxPathLength, MaxPathLength);
121 
124  STATIC_GRAPH_PROPERTY(MLdouble, weight, Weight);
125 
127  typedef MLdouble (VesselNode::*NodeGetFkt) () const;
128  typedef void (VesselNode::*NodeSetFkt) (const MLdouble&);
129 
131 
132 private:
134  VesselNode(Graph& graph, MLint id, const Vector3& pos);
135 
139  void addEdge (VesselEdge *edge);
140  void removeEdge(VesselEdge *edge);
142 
144  std::vector<VesselEdge*> _edges;
145 
146  STATIC_GRAPH_PROPERTY(MLdouble, drainVolume, DrainVolume);
148  STATIC_GRAPH_PROPERTY(MLint16, shortLabel, ShortLabel);
149 
151  STATIC_GRAPH_PROPERTY(MLuint32, enumLabel, EnumLabel);
152 
153 public:
157  void addStateToTree(TreeNode* parent) const override;
158 
161 
163  void readStateFromTree(TreeNode* parent) override;
165 
166 private:
168  void readOldGraphNodeStateFromTree(TreeNode* parent);
170  void readOldVesselNodeStateFromTree(TreeNode* parent);
171 
173 };
174 
175 #if ML_DEPRECATED_SINCE(3,5,0)
180 ML_DEPRECATED typedef VesselNode GraphNode;
182 #endif // ML_DEPRECATED
183 
185 
186 #endif // __mlVesselNode_H
#define ML_DEPRECATED
Definition: CSOGroup.h:371
class BaseGraphItem
BaseGraphItem & operator=(const BaseGraphItem &item)
Assignment operator, deprecated. Use copyProperties() instead.
Defines the basic Graph class which holds sets of nodes, edges and roots to model tubular structures ...
Definition: mlGraph.h:64
Class VesselEdge.
Definition: mlVesselEdge.h:35
VesselNode is derived from GraphNode, hence it can be stored as node item in a class Graph object.
Definition: mlVesselNode.h:29
bool isPred(size_t i) const
Is the dependent edge with index i preceding?
Definition: mlVesselNode.h:75
void convertToWorld(Matrix4 *mat)
Convert nodes' coordinates.
~VesselNode() override
Copy constructor (creates an unconnected object, only copies properties), deprecated.
Definition: mlVesselNode.h:40
const VesselEdge * getDepEdge(size_t i) const
Get the pointer of edge with index i.
Definition: mlVesselNode.h:66
VesselNode * getPredNode()
Get the one and only predecessor node (return NULL for rootnode)
void copyProperties(const VesselNode *other)
Assignment operator, deprecated. Use copyProperties() instead.
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
STATIC_GRAPH_PROPERTY(MLdouble, minDistance, MinDistance)
int nodeType() const
STATIC_GRAPH_PROPERTY(Vector3, pos, Pos)
bool isEnd() const
bool isSucc(size_t i) const
Is the dependent edge with index i succeeding?
Definition: mlVesselNode.h:77
std::vector< VesselEdge * > * edges()
Get pointer to edge array.
Definition: mlVesselNode.h:68
size_t getEdgeNum() const
Get number of edges dependent on the node.
Definition: mlVesselNode.h:62
void setVectorPos(const ImageVector &position)
Position in world.
Definition: mlVesselNode.h:98
bool closeCycle()
TODO: Unclear what this does.
const VesselNode * getPredNode() const
Get the one and only predecessor node (return NULL for rootnode)
void transform(const Matrix4 &m)
Apply a 4x4 homogeneous transformation matrix to the node position.
bool operator==(const VesselNode &other) const
STATIC_GRAPH_PROPERTY(MLint, label, Label)
ImageVector getVectorPos() const
Position in world.
Definition: mlVesselNode.h:100
ML_SET_ADDSTATE_VERSION(2)
Set current addStateToTree() version number:
VesselEdge * getDepEdge(size_t i)
Get the pointer of edge with index i.
Definition: mlVesselNode.h:64
STATIC_GRAPH_PROPERTY(MLdouble, maxPathLength, MaxPathLength)
const VesselEdge * getPredEdge() const
Get the one and only predecessor edge (return NULL for rootnode)
VesselEdge * getPredEdge()
Get the one and only predecessor edge (return NULL for rootnode)
VesselNode * getDepNode(size_t i)
Get dependent node via edge with index i.
bool isRoot() const
bool isCycle(size_t i) const
Is the dependent edge with index i a cycle?
Definition: mlVesselNode.h:79
double distance(const Vector3 &position) const
Get the euclidean distance between _worldPos and pos.
Definition: mlVesselNode.h:104
void convertToVoxel(Matrix4 *mat)
Convert nodes' coordinates.
void addStateToTree(TreeNode *parent) const override
bool isBranch() const
const VesselNode * getDepNode(size_t i) const
Get dependent node via edge with index i.
STATIC_GRAPH_PROPERTY(MLdouble, weight, Weight)
Weight of the node.
bool operator!=(const VesselNode &other) const
Definition: mlVesselNode.h:51
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
#define STATIC_GRAPH_PROPERTY(Type, lowerCaseName, upperCaseName)
unsigned int MLuint32
Definition: mlTypeDefs.h:191
double MLdouble
Definition: mlTypeDefs.h:223
signed short MLint16
Definition: mlTypeDefs.h:131
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
#define VESSELGRAPH_END_NAMESPACE
#define VESSELGRAPH_EXPORT
Definiert systemspezifische Macros, die f"ur diese DLL gelten sollen.
#define VESSELGRAPH_BEGIN_NAMESPACE
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition: mlMatrix4.h:726
Tvec3< MLdouble > Vector3
A vector with 3 components of type double.
Definition: mlVector3.h:300
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.