/* * airwaysEdge.h * * Created on: May 12, 2014 * Author: caceres */ #ifndef AIRWAYSEDGE_H_ #define AIRWAYSEDGE_H_ #include #include #include #include #include #include "airwaysNode.h" #include "Quaternion.h" #include /** * @brief Airways project namespace */ namespace airways { /* * Pair of which means the position of the skeleton point * between two nodes (including branch-points) and it radius (obtained from * the Danielsson's distance map algorithm) */ typedef std::pair pair_posVox_rad; /* * A vector stocking all the points between two nodes */ typedef std::vector vec_pair_posVox_rad; class Node; /* * This class represents an edge in a tree. Particularly, this edge represents the relation from child to father. * This means that the edge source corresponds to the father and the target to the child. This implies that the root * node has a NULL edge. */ class AirwaysLib_EXPORT Edge { public: /*! * Default constructor */ Edge(); /*! * Alternative constructor (copy) * @param edge */ Edge(Edge* edge); /*! * Destructor */ virtual ~Edge(); //Getters /*! * This method returns the angle between two vectors using its parent as * reference * @return */ int GetAngle() const; /*! * This method returns the Average radius between two branch-points * @return */ double GetARadius() const; /*! * This method returns the euclidean distance between two branch-points * @return */ double GetEDistance() const; /*! * This method returns the geodesic distance between two branch-points * @return */ double GetLength() const; /*! * This method returns the maximum radius between two branch-points * @return */ double GetMaxRadius() const; /*! * This method returns the minimum radius between two branch-points * @return */ double GetMinRadius() const; /*! * This method returns the source node of an edge * @return */ Node* GetSource() const; /*! * This method returns the target node of an edge * @return */ Node* GetTarget() const; /*! * This method returns the SKPairInfoVector of an edge * @return */ const vec_pair_posVox_rad& GetEdgeInfo() const; /*! * This method returns true if an edge is marked * @return */ bool IsMarked() const; /** * Method that returns if a voxel is influenced by this edge, i.e. if the distance * to the closest voxel of the edge is smaller than the radius on the closest voxel. * @param x,y,z are the voxel positions in coordinates x, y, and z respectively. * @return true is the voxel is influenced, false otherwise */ bool IsPointInfluencedByEdge(float point_x, float point_y, float point_z) const; //Setters and Modifiers /*! * This method sets the angle between two vectors using its parent * as reference * @param angle */ void SetAngle(const double& angle); /*! * This method sets the average radius between two nodes * @param aRadius */ void SetARadius(const double& aRadius); /*! * This method sets the Euclidean distance between two nodes * @param eDistance */ void SetEDistance(const double& eDistance); /*! * This method sets the geodesical length between two nodes * @param length */ void SetLength(const double& length); /*! * This method sets the maximum radius between two nodes * @param maxRadius */ void SetMaxRadius(const unsigned int& maxRadius); /*! * This method sets the minimum radius between two nodes * @param minRadius */ void SetMinRadius(const unsigned int& minRadius); /*! * This method sets the source node of an edge * @param source */ void SetSource(Node* source); /*! * This method sets the target node of an edge * @param target */ void SetTarget(Node* target); /*! * This method adds a pair into skPInfoVector * @param skPairInfo */ void AddSkeletonPairInfo(const pair_posVox_rad& skPairInfo); /*! * This method sets the skPInfoVector * @param skPInfoVector */ void SetSkeletonPairVector(const vec_pair_posVox_rad& skPInfoVector); /*! * This method updates all the attributes of an edge using the information * provided from m_skInfoPairVector attribute. */ void UpdateEdgeInfo(); /** * Method that compares two edges. * @pre The actual and the edge given by parameter both have a parent edge * @param edge is the edge to be compared with * @return the evalation value */ double CompareWith(Edge* edge); /** * Method that obtains the distance between two edges * @param edge is the edge to be compared with * @return the average distance from all points in the given edge * to this edge. The distance from each in point in the edge to this * edge is defined as the minimum distance to all the point in this * edge. */ float GetDistanceToEdge(Edge* edge); float GetDistanceToTranslatedEdge(Edge* edge, Vec3 vector_translation); /** * Method that returns the distance point to point to the edge given by parameter. * Additionally, the points that share the same closest point receive more weight in the distance. * @param edge is the edge to be compared with * @param vector_translation is the translation vector to translate the given edge * @return the weigthed distance to the given edge */ float GetDistanceWeigthedToTranslatedEdge(Edge* edge, Vec3 vector_translation); /** * Method that calculates the distance from edge to one point in the space * @point is the point in the space * @return the distance from edge to one point in the space */ float GetDistanceToPoint(Vec3 point); /** * Method that returns the smallest distance of the edge voxels to the given voxel (represented as a vector) * @param vector is the point to be compared * @return the smallest distance of the edge voxels to the given voxel */ float GetSmallestDistanceToPoint(Vec3 vector); /** * Method that returns the closest point in the edge to the given point (represented as a vector) and the distance between them (by parameter) * @param vector is the point to be compared * @param distance is the returned distance to the closes point * @return the closest vector and the minimum distance of the point to the points in the edge by parameter. */ Vec3 GetClosestPoint(Vec3 vector, float& distance); /** * Method that concatenates the actual edge to a superior one given by parameter * @param superior is the superio edge. The target of the superior edge must be the source of the actual edge * in terms of voxel position. * @return the composed edge to the superior edge */ Edge* ConcatenateToSuperior(Edge* superior); //Operator Overload Edge& operator=(Edge& edge); const Edge& operator=(const Edge& edge); bool operator==(const Edge& edge); bool operator!=(const Edge& edge); bool operator<(const Edge& edge); bool operator>(const Edge& edge); protected: unsigned int m_id; /** * Source node representing the father */ Node* m_source; /** * Target node representing the child */ Node* m_target; bool m_mark; //!Mark attribute double m_angle; //!Angle between two vectors having its parent as reference double m_length; //!Geodesic distance double m_eDistance; //!Euclidean distance double m_aRadius; //!Average radius between two nodes unsigned int m_minRadius; //!Minimum radius between two nodes unsigned int m_maxRadius; //!Maximum radius between two nodes /*! * The m_vec_pair_posVox_rad is a vector containing all centerline points, * in real coordinates of the image, and radius information of an edge. * i.e., for each point of the skeleton between two nodes there is a pair * */ vec_pair_posVox_rad m_vec_pair_posVox_rad; friend class AirwaysTree; //!Friend class AirwaysTree friend class Node; //!Friend class Node }; } /* namespace airways */ #endif /* AIRWAYSEDGE_H_ */