]> Creatis software - FrontAlgorithms.git/blob - appli/TempAirwaysAppli/AirwaysLib/airwaysEdge.h
On my way... it does not work yet, but I think I'm on the good track.
[FrontAlgorithms.git] / appli / TempAirwaysAppli / AirwaysLib / airwaysEdge.h
1 /*
2  * airwaysEdge.h
3  *
4  *  Created on: May 12, 2014
5  *      Author: caceres
6  */
7
8 #ifndef AIRWAYSEDGE_H_
9 #define AIRWAYSEDGE_H_
10
11 #include <cstddef>
12 #include <cstdlib>
13 #include <vector>
14 #include <utility>
15 #include <limits>
16
17 #include "airwaysNode.h"
18 #include "Quaternion.h"
19 #include <appli/TempAirwaysAppli/AirwaysLib/AirwaysLib_Export.h>
20
21 /**
22  * @brief Airways project namespace
23  */
24 namespace airways
25 {
26
27 /*
28  * Pair of <Vec3,double> which means the position of the skeleton point
29  * between two nodes (including branch-points) and it radius (obtained from
30  * the Danielsson's distance map algorithm)
31  */
32 typedef std::pair<Vec3, double> pair_posVox_rad;
33
34 /*
35  * A vector stocking all the points between two nodes
36  */
37 typedef std::vector<pair_posVox_rad> vec_pair_posVox_rad;
38
39 class Node;
40
41 /*
42  * This class represents an edge in a tree. Particularly, this edge represents the relation from child to father.
43  * This means that the edge source corresponds to the father and the target to the child. This implies that the root
44  * node has a NULL edge.
45  */
46 class AirwaysLib_EXPORT Edge
47 {
48 public:
49         /*!
50          * Default constructor
51          */
52         Edge();
53
54         /*!
55          * Alternative constructor (copy)
56          * @param edge
57          */
58         Edge(Edge* edge);
59
60         /*!
61          * Destructor
62          */
63         virtual ~Edge();
64
65
66         //Getters
67
68         /*!
69          * This method returns the angle between two vectors using its parent as
70          * reference
71          * @return
72          */
73         int GetAngle() const;
74
75         /*!
76          * This method returns the Average radius between two branch-points
77          * @return
78          */
79         double GetARadius() const;
80
81         /*!
82          * This method returns the euclidean distance between two branch-points
83          * @return
84          */
85         double GetEDistance() const;
86
87         /*!
88          * This method returns the geodesic distance between two branch-points
89          * @return
90          */
91         double GetLength() const;
92
93         /*!
94          * This method returns the maximum radius between two branch-points
95          * @return
96          */
97         double GetMaxRadius() const;
98
99         /*!
100          * This method returns the minimum radius between two branch-points
101          * @return
102          */
103         double GetMinRadius() const;
104
105         /*!
106          * This method returns the source node of an edge
107          * @return
108          */
109         Node*   GetSource() const;
110
111         /*!
112          * This method returns the target node of an edge
113          * @return
114          */
115         Node*   GetTarget() const;
116
117         /*!
118          * This method returns the SKPairInfoVector of an edge
119          * @return
120          */
121         const vec_pair_posVox_rad&      GetEdgeInfo() const;
122
123         /*!
124          * This method returns true if an edge is marked
125          * @return
126          */
127         bool IsMarked() const;
128
129         /**
130          * Method that returns if a voxel is influenced by this edge, i.e. if the distance
131          * to the closest voxel of the edge is smaller than the radius on the closest voxel.
132          * @param x,y,z are the voxel positions in coordinates x, y, and z respectively.
133          * @return true is the voxel is influenced, false otherwise
134          */
135         bool IsPointInfluencedByEdge(float point_x, float point_y, float point_z) const;
136
137         //Setters and Modifiers
138
139         /*!
140          * This method sets the angle between two vectors using its parent
141          * as reference
142          * @param angle
143          */
144         void SetAngle(const double& angle);
145
146         /*!
147          * This method sets the average radius between two nodes
148          * @param aRadius
149          */
150         void SetARadius(const double& aRadius);
151
152
153         /*!
154          * This method sets the Euclidean distance between two nodes
155          * @param eDistance
156          */
157         void SetEDistance(const double& eDistance);
158
159         /*!
160          * This method sets the geodesical length between two nodes
161          * @param length
162          */
163         void SetLength(const double& length);
164
165         /*!
166          * This method sets the maximum radius between two nodes
167          * @param maxRadius
168          */
169         void SetMaxRadius(const unsigned int& maxRadius);
170
171         /*!
172          * This method sets the minimum radius between two nodes
173          * @param minRadius
174          */
175         void SetMinRadius(const unsigned int& minRadius);
176
177         /*!
178          * This method sets the source node of an edge
179          * @param source
180          */
181         void SetSource(Node* source);
182
183         /*!
184          * This method sets the target node of an edge
185          * @param target
186          */
187         void SetTarget(Node* target);
188
189         /*!
190          * This method adds a pair <Coordinate, Radius> into skPInfoVector
191          * @param skPairInfo
192          */
193         void AddSkeletonPairInfo(const pair_posVox_rad& skPairInfo);
194
195         /*!
196          * This method sets the skPInfoVector
197          * @param skPInfoVector
198          */
199         void SetSkeletonPairVector(const vec_pair_posVox_rad& skPInfoVector);
200
201         /*!
202          * This method updates all the attributes of an edge using the information
203          * provided from m_skInfoPairVector attribute.
204          */
205         void UpdateEdgeInfo();
206
207         /**
208          * Method that compares two edges.
209          * @pre The actual and the edge given by parameter both have a parent edge
210          * @param edge is the edge to be compared with
211          * @return the evalation value
212          */
213         double CompareWith(Edge* edge);
214
215         /**
216          * Method that obtains the distance between two edges
217          * @param edge is the edge to be compared with
218          * @return the average distance from all points in the given edge
219          * to this edge. The distance from each in point in the edge to this
220          * edge is defined as the minimum distance to all the point in this
221          * edge.
222          */
223         float GetDistanceToEdge(Edge* edge);
224
225         float GetDistanceToTranslatedEdge(Edge* edge, Vec3 vector_translation);
226
227         /**
228          * Method that returns the distance point to point to the edge given by parameter.
229          * Additionally, the points that share the same closest point receive more weight in the distance.
230          * @param edge is the edge to be compared with
231          * @param vector_translation is the translation vector to translate the given edge
232          * @return the weigthed distance to the given edge
233          */
234         float GetDistanceWeigthedToTranslatedEdge(Edge* edge, Vec3 vector_translation);
235
236         /**
237          * Method that calculates the distance from edge to one point in the space
238          * @point is the point in the space
239          * @return the distance from edge to one point in the space
240          */
241         float GetDistanceToPoint(Vec3 point);
242
243         /**
244          * Method that returns the smallest distance of the edge voxels to the given voxel (represented as a vector)
245          * @param vector is the point to be compared
246          * @return the smallest distance of the edge voxels to the given voxel
247          */
248         float GetSmallestDistanceToPoint(Vec3 vector);
249
250         /**
251          * Method that returns the closest point in the edge to the given point (represented as a vector) and the distance between them (by parameter)
252          * @param vector is the point to be compared
253          * @param distance is the returned distance to the closes point
254          * @return the closest vector and the minimum distance of the point to the points in the edge by parameter.
255          */
256         Vec3 GetClosestPoint(Vec3 vector, float& distance);
257
258         /**
259          * Method that concatenates the actual edge to a superior one given by parameter
260          * @param superior is the superio edge. The target of the superior edge must be the source of the actual edge
261          *       in terms of voxel position.
262          * @return the composed edge to the superior edge
263          */
264         Edge* ConcatenateToSuperior(Edge* superior);
265
266         //Operator Overload
267
268         Edge& operator=(Edge& edge);
269
270         const Edge&     operator=(const Edge& edge);
271
272         bool operator==(const Edge& edge);
273
274         bool operator!=(const Edge& edge);
275
276         bool operator<(const Edge& edge);
277
278         bool operator>(const Edge& edge);
279
280 protected:
281
282         unsigned int m_id;
283
284         /**
285          * Source node representing the father
286          */
287         Node* m_source;
288
289         /**
290          * Target node representing the child
291          */
292         Node* m_target;
293
294         bool m_mark; //!Mark attribute
295
296         double m_angle; //!Angle between two vectors having its parent as reference
297
298         double m_length; //!Geodesic distance
299
300         double m_eDistance; //!Euclidean distance
301
302         double m_aRadius; //!Average radius between two nodes
303
304         unsigned int m_minRadius; //!Minimum radius between two nodes
305
306         unsigned int m_maxRadius; //!Maximum radius between two nodes
307
308         /*!
309          * The m_vec_pair_posVox_rad is a vector containing all centerline points,
310          * in real coordinates of the image, and radius information of an edge.
311          * i.e., for each point of the skeleton between two nodes there is a pair
312          * <position real coordinates, radius>
313          */
314         vec_pair_posVox_rad m_vec_pair_posVox_rad;
315
316         friend class AirwaysTree; //!Friend class AirwaysTree
317
318         friend class Node; //!Friend class Node
319 };
320
321 } /* namespace airways */
322
323 #endif /* AIRWAYSEDGE_H_ */