HalfEdge.hpp
Go to the documentation of this file.
1 
28 /*
29  * HalfEdge.hpp
30  *
31  * @date 02.06.2017
32  * @author Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
33  */
34 
35 #ifndef LVR2_GEOMETRY_HALFEDGE_H_
36 #define LVR2_GEOMETRY_HALFEDGE_H_
37 
38 #include <utility>
39 
40 #include "BaseMesh.hpp"
41 #include "Handles.hpp"
42 
43 namespace lvr2
44 {
45 
46 // We need a specific handle for half edges. The `BaseMesh` interface talks
47 // about simple (full) edges. To avoid confusion, this HalfEdgeHandle is used
48 // internally in the HEM. The edge handles given out by the HEM implementation
49 // are handles to the half edge with the lower index.
50 
52 class HalfEdgeHandle : public BaseHandle<Index>
53 {
54 public:
56 
58  {
59  // The index of an edge handle is always the index of the handle of
60  // one of its half edges
61  return HalfEdgeHandle(eH.idx());
62  }
63 };
64 
66 class OptionalHalfEdgeHandle : public BaseOptionalHandle<Index, HalfEdgeHandle>
67 {
68 public:
72 };
73 
74 struct HalfEdge
75 {
79 
82 
87 
90 
91 private:
95  HalfEdge() : target(0), next(0), twin(0) {}
96 
98  template <typename BaseVecT>
99  friend class HalfEdgeMesh;
100 };
101 
102 
103 inline std::ostream& operator<<(std::ostream& os, const HalfEdgeHandle& h)
104 {
105  os << "HE" << h.idx();
106  return os;
107 }
108 
109 inline std::ostream& operator<<(std::ostream& os, const OptionalHalfEdgeHandle& h)
110 {
111  if (h)
112  {
113  os << "HE" << h.unwrap().idx();
114  }
115  else
116  {
117  os << "HE⊥";
118  }
119  return os;
120 }
121 
122 } // namespace lvr2
123 
124 namespace std
125 {
126 
127 template<>
128 struct hash<lvr2::HalfEdgeHandle> {
129  size_t operator()(const lvr2::HalfEdgeHandle& h) const
130  {
131  return std::hash<lvr2::Index>()(h.idx());
132  }
133 };
134 
135 } // namespace std
136 
137 #endif /* LVR2_GEOMETRY_HALFEDGE_H_ */
NonOptionalT unwrap() const
Extracts the handle. If this doesn&#39;t hold a handle (is "None"), this method panics.
std::ostream & operator<<(std::ostream &os, const BaseVector< T > &v)
Definition: BaseVector.hpp:227
OptionalFaceHandle face
Definition: HalfEdge.hpp:78
Interface for all kinds of handles. Handles are basically a key to refer to something.
Definition: BaseHandle.hpp:54
Handle to access vertices of the mesh.
Definition: Handles.hpp:146
Handle to access edges of the mesh.
Definition: Handles.hpp:134
HalfEdgeHandle twin
The twin edge.
Definition: HalfEdge.hpp:89
static HalfEdgeHandle oneHalfOf(EdgeHandle eH)
Definition: HalfEdge.hpp:57
OptionalHalfEdgeHandle(EdgeHandle eH)
Definition: HalfEdge.hpp:71
Half-edge data structure implementing the BaseMesh interface.
size_t operator()(const lvr2::HalfEdgeHandle &h) const
Definition: HalfEdge.hpp:129
Semantically equivalent to boost::optional<FaceHandle>
Definition: Handles.hpp:170
Semantically equivalent to boost::optional<HalfEdgeHandle>
Definition: HalfEdge.hpp:66
Handle to access half edges of the HEM.
Definition: HalfEdge.hpp:52
IdxT idx() const
Base class for optional handles (handles that can be "null" or "None").
Definition: BaseHandle.hpp:79
HalfEdge()
Initializes all fields with dummy values (unsafe, thus private).
Definition: HalfEdge.hpp:95
HalfEdgeHandle next
Definition: HalfEdge.hpp:86
VertexHandle target
The vertex this edge points to.
Definition: HalfEdge.hpp:81


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06