EBGeometry  1.0
EBGeometry_DCEL_Vertex.hpp
Go to the documentation of this file.
1 /* EBGeometry
2  * Copyright © 2022 Robert Marskar
3  * Please refer to Copyright.txt and LICENSE in the EBGeometry root directory.
4  */
5 
13 #ifndef EBGeometry_DCEL_Vertex
14 #define EBGeometry_DCEL_Vertex
15 
16 // Std includes
17 #include <vector>
18 #include <memory>
19 
20 // Our includes
21 #include "EBGeometry_Vec.hpp"
22 #include "EBGeometry_DCEL.hpp"
23 #include "EBGeometry_DCEL_Face.hpp"
25 
26 namespace DCEL {
27 
38  template <class T, class Meta>
39  class VertexT
40  {
41  public:
45  using Vec3 = Vec3T<T>;
46 
51 
56 
61 
65  using VertexPtr = std::shared_ptr<Vertex>;
66 
70  using EdgePtr = std::shared_ptr<Edge>;
71 
75  using FacePtr = std::shared_ptr<Face>;
76 
81 
88 
95  VertexT(const Vec3& a_position);
96 
104  VertexT(const Vec3& a_position, const Vec3& a_normal);
105 
112  VertexT(const Vertex& a_otherVertex);
113 
117  virtual ~VertexT();
118 
126  inline void
127  define(const Vec3& a_position, const EdgePtr& a_edge, const Vec3& a_normal) noexcept;
128 
133  inline void
134  setPosition(const Vec3& a_position) noexcept;
135 
140  inline void
141  setNormal(const Vec3& a_normal) noexcept;
142 
147  inline void
148  setEdge(const EdgePtr& a_edge) noexcept;
149 
154  inline void
155  addFace(const FacePtr& a_face) noexcept;
156 
160  inline void
162 
167  inline void
169 
176  inline void
177  computeVertexNormalAverage(const std::vector<FacePtr>& a_faces) noexcept;
178 
187  inline void
189 
198  inline void
199  computeVertexNormalAngleWeighted(const std::vector<FacePtr>& a_faces) noexcept;
200 
204  inline void
205  flip() noexcept;
206 
210  inline Vec3T<T>&
211  getPosition() noexcept;
212 
216  inline const Vec3T<T>&
217  getPosition() const noexcept;
218 
222  inline Vec3T<T>&
223  getNormal() noexcept;
224 
228  inline const Vec3T<T>&
229  getNormal() const noexcept;
230 
234  inline EdgePtr&
235  getOutgoingEdge() noexcept;
236 
240  inline const EdgePtr&
241  getOutgoingEdge() const noexcept;
242 
246  inline std::vector<FacePtr>&
247  getFaces() noexcept;
248 
252  inline const std::vector<FacePtr>&
253  getFaces() const noexcept;
254 
261  inline T
262  signedDistance(const Vec3& a_x0) const noexcept;
263 
270  inline T
271  unsignedDistance2(const Vec3& a_x0) const noexcept;
272 
277  inline Meta&
278  getMetaData() noexcept;
279 
284  inline const Meta&
285  getMetaData() const noexcept;
286 
287  protected:
292 
297 
302 
306  std::vector<FacePtr> m_faces;
307 
312  };
313 } // namespace DCEL
314 
315 #include "EBGeometry_NamespaceFooter.hpp"
316 
317 #include "EBGeometry_DCEL_VertexImplem.hpp"
318 
319 #endif
Namespace documentation.
Declaration of a polygon face class for use in DCEL descriptions of polygon tesselations.
Declaration of 2D and 3D point/vector classes with templated precision. Used with DCEL tools.
Edge iterator class.
Definition: EBGeometry_DCEL_Iterator.hpp:28
Edge class.
Definition: EBGeometry_DCEL_Edge.hpp:47
Face class.
Definition: EBGeometry_DCEL_Face.hpp:49
Vertex class.
Definition: EBGeometry_DCEL_Vertex.hpp:40
std::shared_ptr< Face > FacePtr
Alias for face pointer type.
Definition: EBGeometry_DCEL_Vertex.hpp:75
void setPosition(const Vec3 &a_position) noexcept
Set the vertex position.
VertexT()
Default constructor.
void computeVertexNormalAverage() noexcept
Compute the vertex normal, using an average the normal vector in this vertex's face list (m_faces)
std::shared_ptr< Vertex > VertexPtr
Alias for vertex pointer type.
Definition: EBGeometry_DCEL_Vertex.hpp:65
VertexT(const Vec3 &a_position)
Partial constructor.
Vec3T< T > & getPosition() noexcept
Return modifiable vertex position.
Vec3T< T > & getNormal() noexcept
Return modifiable vertex normal vector.
void setEdge(const EdgePtr &a_edge) noexcept
Set the reference to the outgoing edge.
T unsignedDistance2(const Vec3 &a_x0) const noexcept
Get the squared unsigned distance to this vertex.
std::vector< FacePtr > m_faces
List of faces connected to this vertex (these must be "manually" added)
Definition: EBGeometry_DCEL_Vertex.hpp:306
std::shared_ptr< Edge > EdgePtr
Alias for edge pointer type.
Definition: EBGeometry_DCEL_Vertex.hpp:70
void setNormal(const Vec3 &a_normal) noexcept
Set the vertex normal vector.
EdgePtr & getOutgoingEdge() noexcept
Return modifiable pointer to outgoing edge.
void addFace(const FacePtr &a_face) noexcept
Add a face to the polygon face list.
T signedDistance(const Vec3 &a_x0) const noexcept
Get the signed distance to this vertex.
std::vector< FacePtr > & getFaces() noexcept
Get modifiable polygon face list for this vertex.
void flip() noexcept
Flip the normal vector.
Vec3 m_normal
Vertex normal vector.
Definition: EBGeometry_DCEL_Vertex.hpp:301
virtual ~VertexT()
Destructor (does nothing)
VertexT(const Vec3 &a_position, const Vec3 &a_normal)
Constructor.
VertexT(const Vertex &a_otherVertex)
Full copy constructor.
Meta m_metaData
Meta-data for this vertex.
Definition: EBGeometry_DCEL_Vertex.hpp:311
EdgePtr m_outgoingEdge
Pointer to an outgoing edge from this vertex.
Definition: EBGeometry_DCEL_Vertex.hpp:291
void computeVertexNormalAngleWeighted() noexcept
Compute the vertex normal, using the pseudonormal algorithm which weights the normal with the subtend...
void define(const Vec3 &a_position, const EdgePtr &a_edge, const Vec3 &a_normal) noexcept
Define function.
Meta & getMetaData() noexcept
Get meta-data.
Vec3 m_position
Vertex position.
Definition: EBGeometry_DCEL_Vertex.hpp:296
void normalizeNormalVector() noexcept
Normalize the normal vector, ensuring its length is 1.
Three-dimensional vector class with arithmetic operators.
Definition: EBGeometry_Vec.hpp:218
Namespace containing various double-connected edge list (DCEL) functionality.