LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DCEL.h
Go to the documentation of this file.
1 
10 #ifndef DCEL2D_h
11 #define DCEL2D_h
12 
13 // std includes
14 #include <algorithm>
15 #include <list>
16 #include <vector>
17 
18 // Eigen
19 #ifdef __clang__
20 #else
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
23 #endif
24 #include <Eigen/Dense>
25 #ifdef __clang__
26 #else
27 #pragma GCC diagnostic pop
28 #endif
29 
30 //------------------------------------------------------------------------------------------------------------------------------------------
31 
32 namespace reco {
33  class ClusterHit3D;
34 }
35 
36 namespace dcel2d {
37  class HalfEdge; // Forward declaration
38 
42  using Point = std::tuple<double, double, const reco::ClusterHit3D*>;
43  using PointList = std::list<Point>;
44  using Coords = Eigen::Vector3f; //std::pair<double,double>;
45 
46  class Vertex {
52  public:
56  Vertex() : fCoords(0., 0., 0.), fHalfEdge(NULL) {}
57 
58  Vertex(const double* coords, HalfEdge* half) : fHalfEdge(half) { setCoords(coords); }
59 
60  Vertex(const Coords& coords, HalfEdge* half) : fCoords(coords), fHalfEdge(half) {}
61 
62  const Coords& getCoords() const { return fCoords; }
63  const HalfEdge* getHalfEdge() const { return fHalfEdge; }
64 
65  void setCoords(const double* coords)
66  {
67  fCoords[0] = coords[0];
68  fCoords[1] = coords[1];
69  fCoords[2] = coords[2];
70  }
71 
72  void setCoords(const Coords& coords) { fCoords = coords; }
73 
74  void setHalfEdge(HalfEdge* half) { fHalfEdge = half; }
75 
76  private:
77  Coords fCoords; // x,y coordinates of this vertex
78  HalfEdge* fHalfEdge; // pointer to one of the half edges
79  };
80 
81  class Face {
88  public:
92  // Face() : fHalfEdge(NULL), fPoint(0.,0.,NULL) {}
93 
94  Face(HalfEdge* half, const Coords& coords, const reco::ClusterHit3D* clusterHit3D)
95  : fHalfEdge(half)
96  , fConvexHull(false)
97  , fCoords(coords)
98  , fFaceArea(0.)
99  , fClusterHit3D(clusterHit3D)
100  {}
101 
102  const HalfEdge* getHalfEdge() const { return fHalfEdge; }
103  bool onConvexHull() const { return fConvexHull; }
104  const Coords& getCoords() const { return fCoords; }
105  double getFaceArea() const { return fFaceArea; }
106  const reco::ClusterHit3D* getClusterHit3D() const { return fClusterHit3D; }
107 
108  void setHalfEdge(HalfEdge* half) { fHalfEdge = half; }
109  void setOnConvexHull() { fConvexHull = true; }
110  void setFaceArea(double area) { fFaceArea = area; }
111 
112  private:
113  HalfEdge* fHalfEdge; // pointer to one of the half edges
114  mutable bool fConvexHull; // This face on convex hull
115  Coords fCoords; // projected coordinates of associated point
116  double fFaceArea; // The area of the face once constructed
117  const reco::ClusterHit3D* fClusterHit3D; // The physical 3D hit this corresponds to
118  };
119 
120  class HalfEdge {
128  public:
133  : m_targetVertex(NULL)
134  , m_face(NULL)
135  , m_twinHalfEdge(NULL)
136  , m_nextHalfEdge(NULL)
137  , m_lastHalfEdge(NULL)
138  {}
139 
140  HalfEdge(Vertex* vertex, Face* face, HalfEdge* twin, HalfEdge* next, HalfEdge* last)
141  : m_targetVertex(vertex)
142  , m_face(face)
143  , m_twinHalfEdge(twin)
144  , m_nextHalfEdge(next)
145  , m_lastHalfEdge(last)
146  {}
147 
148  Vertex* getTargetVertex() const { return m_targetVertex; }
149  Face* getFace() const { return m_face; }
150  HalfEdge* getTwinHalfEdge() const { return m_twinHalfEdge; }
151  HalfEdge* getNextHalfEdge() const { return m_nextHalfEdge; }
152  HalfEdge* getLastHalfEdge() const { return m_lastHalfEdge; }
153 
154  void setTargetVertex(Vertex* vertex) { m_targetVertex = vertex; }
155  void setFace(Face* face) { m_face = face; }
156  void setTwinHalfEdge(HalfEdge* twin) { m_twinHalfEdge = twin; }
157  void setNextHalfEdge(HalfEdge* next) { m_nextHalfEdge = next; }
158  void setLastHalfEdge(HalfEdge* last) { m_lastHalfEdge = last; }
159 
160  private:
161  Vertex* m_targetVertex; // Pointer to the vertex we point to
162  Face* m_face; // Pointer to the face we are associated with
163  HalfEdge* m_twinHalfEdge; // Pointer to the twin half edge (pointing opposite)
164  HalfEdge* m_nextHalfEdge; // Pointer ot the next half edge
165  HalfEdge* m_lastHalfEdge; // Pointer to the previous half edge
166  };
167 
168  // Define containers to hold the above objects
169  using VertexList = std::list<Vertex>;
170  using FaceList = std::list<Face>;
171  using HalfEdgeList = std::list<HalfEdge>;
172 
173 } // namespace lar_cluster3d
174 #endif
void setFaceArea(double area)
Definition: DCEL.h:110
const reco::ClusterHit3D * getClusterHit3D() const
Definition: DCEL.h:106
Vertex()
Vertex class definition for use in a doubly connected edge list a Vertex will contain the coordinates...
Definition: DCEL.h:56
HalfEdge * getLastHalfEdge() const
Definition: DCEL.h:152
void setCoords(const Coords &coords)
Definition: DCEL.h:72
HalfEdge * getNextHalfEdge() const
Definition: DCEL.h:151
std::list< HalfEdge > HalfEdgeList
Definition: DCEL.h:171
void setHalfEdge(HalfEdge *half)
Definition: DCEL.h:74
Face(HalfEdge *half, const Coords &coords, const reco::ClusterHit3D *clusterHit3D)
Face class definition for use in a doubly connected edge list A Face represents the area enclosed by ...
Definition: DCEL.h:94
HalfEdge * getTwinHalfEdge() const
Definition: DCEL.h:150
Face * getFace() const
Definition: DCEL.h:149
bool onConvexHull() const
Definition: DCEL.h:103
HalfEdge * fHalfEdge
Definition: DCEL.h:113
HalfEdge * m_lastHalfEdge
Definition: DCEL.h:165
HalfEdge * m_nextHalfEdge
Definition: DCEL.h:164
Vertex(const double *coords, HalfEdge *half)
Definition: DCEL.h:58
double fFaceArea
Definition: DCEL.h:116
Vertex(const Coords &coords, HalfEdge *half)
Definition: DCEL.h:60
Vertex * m_targetVertex
Definition: DCEL.h:161
Coords fCoords
Definition: DCEL.h:77
void setLastHalfEdge(HalfEdge *last)
Definition: DCEL.h:158
void setTwinHalfEdge(HalfEdge *twin)
Definition: DCEL.h:156
HalfEdge()
HalfEdge class definition for use in a doubly connected edge list The half edge class represents one ...
Definition: DCEL.h:132
std::list< Face > FaceList
Definition: DCEL.h:170
HalfEdge * fHalfEdge
Definition: DCEL.h:78
Coords fCoords
Definition: DCEL.h:115
const Coords & getCoords() const
Definition: DCEL.h:104
void setFace(Face *face)
Definition: DCEL.h:155
bool fConvexHull
Definition: DCEL.h:114
const HalfEdge * getHalfEdge() const
Definition: DCEL.h:102
void setNextHalfEdge(HalfEdge *next)
Definition: DCEL.h:157
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
void setCoords(const double *coords)
Definition: DCEL.h:65
HalfEdge(Vertex *vertex, Face *face, HalfEdge *twin, HalfEdge *next, HalfEdge *last)
Definition: DCEL.h:140
void setHalfEdge(HalfEdge *half)
Definition: DCEL.h:108
Face * m_face
Definition: DCEL.h:162
HalfEdge * m_twinHalfEdge
Definition: DCEL.h:163
std::list< Point > PointList
Definition: DCEL.h:43
Vertex * getTargetVertex() const
Definition: DCEL.h:148
Eigen::Vector3f Coords
Definition: DCEL.h:44
void setOnConvexHull()
Definition: DCEL.h:109
const HalfEdge * getHalfEdge() const
Definition: DCEL.h:63
const Coords & getCoords() const
Definition: DCEL.h:62
const reco::ClusterHit3D * fClusterHit3D
Definition: DCEL.h:117
std::list< Vertex > VertexList
Definition: DCEL.h:169
void setTargetVertex(Vertex *vertex)
Definition: DCEL.h:154
double getFaceArea() const
Definition: DCEL.h:105
vertex reconstruction