MeVisLab Toolbox Reference
mlVesselEdge.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_EDGE_H
14 #define ML_VESSEL_EDGE_H
15 
16 
20 
21 #include "mlVesselGraphSystem.h"
22 #include "VesselGraphTypes.h"
23 #include "mlGraph.h"
24 #include "mlBaseGraphItem.h"
25 #include "mlSkeleton.h"
26 #include "mlPropertiesMacros.h"
27 
29 
30 class VesselNode;
31 class Graph;
32 
35 {
36 friend class EdgeAnalyser;
37 friend class Graph;
38 friend class LoadTreeData;
39 
40 public:
42  VesselEdge(const VesselEdge &other);
44  ~VesselEdge() override;
45 
47  void copyProperties(const VesselEdge* other);
48 
49  bool operator==(const VesselEdge& other) const;
50  bool operator!=(const VesselEdge& other) const { return !(*this==other); }
51 
55  VesselNode* predNode() { return _predNode; }
56  const VesselNode* predNode() const { return _predNode; }
57 
59  VesselNode* succNode() { return _succNode; }
60  const VesselNode* succNode() const { return _succNode; }
61 
63  void setPred(VesselNode* node);
64 
66  void setSucc(VesselNode* node);
67 
69  bool isPred(const VesselNode* node) const { return _predNode==node; }
71  bool isSucc(const VesselNode* node) const { return _succNode==node; }
72 
75 
77  void setCycle() { _cycle = true; }
78  void unsetCycle() { _cycle = false; }
79  bool isCycle() const { return _cycle; }
81 
86  double distance(Vector3 vp) const { return getDistanceAndNearestSkeletonIndex(vp).first; };
87 
88  std::pair<MLdouble, size_t> getDistanceAndNearestSkeletonIndex(const Vector3& pos) const;
89 
91  Vector3 extent() const;
92 
94  SubImageBoxd getBoundingBox() const;
95 
97  void transform(const Matrix4& m);
98 
103 
106  STATIC_GRAPH_PROPERTY(MLdouble, averageMinDistance, AverageMinDistance);
107  STATIC_GRAPH_PROPERTY(MLdouble, length, Length);
108  STATIC_GRAPH_PROPERTY(MLdouble, STLength, STLength);
109  STATIC_GRAPH_PROPERTY(MLdouble, volume, Volume);
110  STATIC_GRAPH_PROPERTY(MLdouble, STVolume, STVolume);
111  STATIC_GRAPH_PROPERTY(Vector3, STBarycenter, STBarycenter);
112  STATIC_GRAPH_PROPERTY(MLint, hierarchy, Hierarchy);
114  STATIC_GRAPH_PROPERTY(MLdouble, weight, Weight);
115 
117  typedef double (VesselEdge::*EdgeGetFkt) (void) const;
118  typedef void (VesselEdge::*EdgeSetFkt) (double);
119 
121  void setSTLabel(int nLabel);
123 
124 
127  Skeleton* createSkeleton(const Vector3& pos=Vector3(0), double minDistance = 0.0,
128  double maxDistance = 0.0);
129  Skeleton* createSkeleton(const ImageVector& pos, double minDistance = 0.0,
130  double maxDistance = 0.0)
131  {
132  return createSkeleton(Vector3(static_cast<MLdouble>(pos.x),
133  static_cast<MLdouble>(pos.y),
134  static_cast<MLdouble>(pos.z)),
135  minDistance, maxDistance);
136  }
137  Skeleton* createSkeleton(const Skeleton* skeletonTemplate);
138 
139  void removeLeadingSkeletons(size_t count);
140  void removeTrailingSkeletons(size_t count);
141  void removeSkeleton(size_t index);
142 
143  size_t numSkeletons(void) const { return _skeletons.size(); }
144  Skeleton* skeleton(size_t index) { return _skeletons.at(index); }
145  const Skeleton* skeleton(size_t index) const { return _skeletons.at(index); }
146 
148  void skeletonsAscending(std::vector<Skeleton*> &skeletons);
149 
151  void skeletonsAscending(std::vector<const Skeleton*> &skeletons) const;
152 
154  void skeletonsDescending(std::vector<Skeleton*> &skeletons);
155 
157  void skeletonsDescending(std::vector<const Skeleton*> &skeletons) const;
158 
160 
162  void skeletonsAscending(std::vector<Skeleton>& skeletons) const;
163 
165  void skeletonsDescending(std::vector<Skeleton>& skeletons) const;
166 
168  bool skeletonsAreAscending() const;
169 
172  Skeleton* frontSkeleton() {return _skeletons.front();}
173  Skeleton* backSkeleton() {return _skeletons.back();}
174  const Skeleton* frontSkeleton() const {return _skeletons.front();}
175  const Skeleton* backSkeleton() const {return _skeletons.back();}
176 
180  Skeleton *skeleton(Vector3 pos,int itemType) { return const_cast<Skeleton*>(const_cast<const VesselEdge*>(this)->skeleton(pos, itemType)); }
181 
185  const Skeleton *skeleton(Vector3 pos,int itemType) const;
186 
188  size_t getVoxelNum() const;
189 
192  void smooth(unsigned int numSmoothingPasses, double positionSmoothingFactor, double radiusSmoothingFactor, double smoothingLimit = 0.0f );
194 
195 private:
197  VesselEdge(Graph& graph, MLint id);
198 
200  VesselNode* _predNode;
202  VesselNode* _succNode;
203 
206  bool _cycle;
207 
209  std::vector <Skeleton*> _skeletons;
210 
211 public:
212 #if ML_DEPRECATED_SINCE(3,5,0)
216 #endif
217 
221  void addStateToTree(TreeNode* parent) const override;
222 
225 
227  void readStateFromTree(TreeNode* parent) override;
229 
231  void setSTLabel(Graph *pGraph);
232 
236  bool markST( int a_label, float r, float g, float b, float a, Vector3 pos, int snap );
237  bool markEdge( int a_label, float r, float g, float b, float a, Vector3 pos, int snap );
238 
239 private:
241  void readOldGraphEdgeStateFromTree(TreeNode* parent);
243  void readOldVesselEdgeStateFromTree(TreeNode* parent);
244 
246 };
247 
248 #if ML_DEPRECATED_SINCE(3,5,0)
253 ML_DEPRECATED typedef VesselEdge GraphEdge;
255 #endif // ML_DEPRECATED
256 
258 
259 #endif // __mlVesselEdge_H
#define ML_DEPRECATED
Definition: CSOGroup.h:371
class BaseGraphItem
BaseGraphItem & operator=(const BaseGraphItem &item)
Assignment operator, deprecated. Use copyProperties() instead.
— Class EdgeAnalyser
Defines the basic Graph class which holds sets of nodes, edges and roots to model tubular structures ...
Definition: mlGraph.h:64
Skeleton objects represent centerline voxels stored in a VesselEdge object.
Definition: mlSkeleton.h:35
Class VesselEdge.
Definition: mlVesselEdge.h:35
Skeleton * frontSkeleton()
Definition: mlVesselEdge.h:172
Skeleton * createSkeleton(const ImageVector &pos, double minDistance=0.0, double maxDistance=0.0)
Definition: mlVesselEdge.h:129
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
void removeSkeleton(size_t index)
STATIC_GRAPH_PROPERTY(MLint, label, Label)
size_t getVoxelNum() const
Get number of edge voxels.
bool isCycle() const
Definition: mlVesselEdge.h:79
STATIC_GRAPH_PROPERTY(MLdouble, STLength, STLength)
STATIC_GRAPH_PROPERTY(MLdouble, STVolume, STVolume)
void removeTrailingSkeletons(size_t count)
void transform(const Matrix4 &m)
Apply a 4x4 homogeneous transformation matrix to all skeleton positions.
const Skeleton * skeleton(size_t index) const
Definition: mlVesselEdge.h:145
void convertToVoxel(Matrix4 *mat)
Convert all skeleton coordinates.
bool markEdge(int a_label, float r, float g, float b, float a, Vector3 pos, int snap)
void skeletonsAscending(std::vector< Skeleton * > &skeletons)
Return copy of skeletons' addresses in ascending order (graph hierarchy)
void switchDirection()
Change direction of the edge by exchanging pred. and succ. node.
Vector3 extent() const
Get the edge's extent.
void skeletonsDescending(std::vector< Skeleton * > &skeletons)
Return copy of skeletons' addresses in descending order (graph hierarchy)
void setSucc(VesselNode *node)
Connect edge-tail to node node.
Skeleton * skeleton(size_t index)
Definition: mlVesselEdge.h:144
void setSTLabel(int nLabel)
Set label of edge and the attached subtree defined by edge directions.
SubImageBoxd getBoundingBox() const
Bounding box of the edge.
const VesselNode * succNode() const
Definition: mlVesselEdge.h:60
void removeLeadingSkeletons(size_t count)
VesselNode * predNode()
Definition: mlVesselEdge.h:55
STATIC_GRAPH_PROPERTY(MLdouble, weight, Weight)
void setCycle()
Separate circles in the graph or connections between trees.
Definition: mlVesselEdge.h:77
STATIC_GRAPH_PROPERTY(Vector3, STBarycenter, STBarycenter)
std::pair< MLdouble, size_t > getDistanceAndNearestSkeletonIndex(const Vector3 &pos) const
void skeletonsAscending(std::vector< Skeleton > &skeletons) const
Return copy of skeletons in ascending order (graph hierarchy from pred -> succ)
void smooth(unsigned int numSmoothingPasses, double positionSmoothingFactor, double radiusSmoothingFactor, double smoothingLimit=0.0f)
Smooths the skeletons' positions and radii.
bool markST(int a_label, float r, float g, float b, float a, Vector3 pos, int snap)
Set label and rgb color of edge and the attached subtree defined by edge directions.
Skeleton * createSkeleton(const Skeleton *skeletonTemplate)
VesselNode * succNode()
Get the successor node of this edge.
Definition: mlVesselEdge.h:59
void addStateToTree(TreeNode *parent) const override
double distance(Vector3 vp) const
Definition: mlVesselEdge.h:86
void orderSkeletonsAscending()
const Skeleton * skeleton(Vector3 pos, int itemType) const
Get the skeleton with minimal distance to pos.
void skeletonsDescending(std::vector< Skeleton > &skeletons) const
Return copy of skeletons in descending order (graph hierarchy from succ -> pred)
VesselEdge(const VesselEdge &other)
Copy constructor (creates an unconnected object, only copies properties), deprecated.
Skeleton * backSkeleton()
Definition: mlVesselEdge.h:173
void setPred(VesselNode *node)
Connect edge-head to node node.
void skeletonsDescending(std::vector< const Skeleton * > &skeletons) const
Return copy of skeletons' addresses in descending order (graph hierarchy)
bool operator==(const VesselEdge &other) const
STATIC_GRAPH_PROPERTY(MLdouble, averageMinDistance, AverageMinDistance)
void clearSkeletons()
Encapsulate std::vector access.
size_t numSkeletons(void) const
Definition: mlVesselEdge.h:143
const Skeleton * frontSkeleton() const
Definition: mlVesselEdge.h:174
Skeleton * createSkeleton(const Vector3 &pos=Vector3(0), double minDistance=0.0, double maxDistance=0.0)
STATIC_GRAPH_PROPERTY(MLdouble, volume, Volume)
Skeleton * skeleton(Vector3 pos, int itemType)
Get the skeleton with minimal distance to pos.
Definition: mlVesselEdge.h:180
STATIC_GRAPH_PROPERTY(MLdouble, length, Length)
ML_SET_ADDSTATE_VERSION(3)
Set current addStateToTree() version number:
bool operator!=(const VesselEdge &other) const
Definition: mlVesselEdge.h:50
bool isSucc(const VesselNode *node) const
Is the graphNode the succeeding node of the edge?
Definition: mlVesselEdge.h:71
void copyProperties(const VesselEdge *other)
Copy all properties (topology information is left unchanged)
~VesselEdge() override
Destructor.
void unsetCycle()
Definition: mlVesselEdge.h:78
void skeletonsAscending(std::vector< const Skeleton * > &skeletons) const
Return copy of skeletons' addresses in ascending order (graph hierarchy)
bool skeletonsAreAscending() const
Returns if the skeletons are ordered ascending.
const Skeleton * backSkeleton() const
Definition: mlVesselEdge.h:175
void setSTLabel(Graph *pGraph)
Set label of edge and the attached subtree defined by edge directions according to labels of pGraph.
void convertToWorld(Matrix4 *mat)
const VesselNode * predNode() const
Definition: mlVesselEdge.h:56
STATIC_GRAPH_PROPERTY(MLint, hierarchy, Hierarchy)
bool isPred(const VesselNode *node) const
Is the graphNode the preceding node of the edge?
Definition: mlVesselEdge.h:69
VesselNode is derived from GraphNode, hence it can be stored as node item in a class Graph object.
Definition: mlVesselNode.h:29
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
double MLdouble
Definition: mlTypeDefs.h:223
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.