1 #ifndef PATH_VERTEX_H
2 #define PATH_VERTEX_H
3 
4 #include <vector>
5 #include "NodeBundle.h"
6 
7 namespace psurface {
8 
9 /**  \brief This class represents a node that is to be created when an edge of the target surface can be inserted.*/
10 template <class ctype>
11 class PathVertex
12 {
13 public:
14     /** \brief Default Constructor. */
PathVertex()15     PathVertex()
16     {}
17 
18     /** \brief Construct Vertex from node bundle. */
PathVertex(const NodeBundle & bundle)19     PathVertex(const NodeBundle& bundle) :
20         bundle_(bundle), enteringEdge_(-1)
21     {}
22 
23     /** \brief Full constructor. */
24     PathVertex(int tri, int edge, ctype locEdge,
25                typename Node<ctype>::NodeType type,
26                const NodeBundle& bundle,
27                ctype lambda, int enteringEdge, int corner=-1) :
tri_(tri)28         tri_(tri), edge_(edge), locEdge_(locEdge),
29         corner_(corner), type_(type), bundle_(bundle),
30         lambda_(lambda), enteringEdge_(enteringEdge)
31     {}
32 
33     /** \brief Assignment operator */
34     PathVertex & operator=(const PathVertex& other) {
35         (*this).tri_ = other.tri_;
36         (*this).edge_ = other.edge_;
37         (*this).locEdge_ = other.locEdge_;
38         (*this).corner_ = other.corner_;
39         (*this).type_ = other.type_;
40         (*this).bundle_ = other.bundle_;
41         (*this).lambda_ = other.lambda_;
42         (*this).enteringEdge_ = other.enteringEdge_;
43         return *this;
44     }
45 
46     /** \brief Equality-operator. */
47     bool operator==(const PathVertex& other) const {
48         return (tri_==other.tri_) && (edge_ == other.edge_) && (std::fabs(locEdge_-other.locEdge_)<1e-8)
49                 && (corner_ == other.corner_) && (type_ == other.type_) && (bundle_==other.bundle_)
50                     && (std::fabs(lambda_-other.lambda_)<1e-8) && (enteringEdge_ == other.enteringEdge_);
51     }
52 
53     /** \brief Print the content for debugging */
print()54     void print() const {
55         std::cout<<"Triangle: "<<tri_<<", Edge: "<<edge_<<std::endl;
56         std::cout<<" Edge coordinate "<<locEdge_<<",  Corner "<<corner_<<std::endl;
57         std::cout<<"Type: "<<type_<<", lambda on ray: "<<lambda_<<std::endl;
58         std::cout<<" enteringEdge "<<enteringEdge_<<std::endl;
59     }
60 
61     //! The triangle the vertex lives on, for INTERSECTION nodes the first triangle is stored
62     int tri_;
63     //! The edge the vertex lives on or -1
64     int edge_;
65     //! Barycentric coordinate on the edge
66     ctype locEdge_;
67     //! If the vertex is a corner, store the corner idx
68     int corner_;
69     //! The vertex type
70     typename Node<ctype>::NodeType type_;
71     //! The node bundle of the vertex
72     NodeBundle bundle_;
73     //! Position on the path of the target surface edge 0<=lambda<=1
74     ctype lambda_;
75     //! The edge from which the target edge entered the domain triangle tri_
76     int enteringEdge_;
77 };
78 
79 } // namespace psurface
80 
81 #endif
82