EBGeometry  1.0
EBGeometry_DCEL_Face.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_Face
14 #define EBGeometry_DCEL_Face
15 
16 // Std includes
17 #include <memory>
18 #include <vector>
19 
20 // Our includes
21 #include "EBGeometry_Vec.hpp"
23 #include "EBGeometry_DCEL_Edge.hpp"
24 #include "EBGeometry_Polygon2D.hpp"
26 
27 namespace DCEL {
28 
47  template <class T, class Meta>
48  class FaceT
49  {
50  public:
54  using Vec3 = Vec3T<T>;
55 
60 
65 
70 
74  using VertexPtr = std::shared_ptr<Vertex>;
75 
79  using EdgePtr = std::shared_ptr<Edge>;
80 
84  using FacePtr = std::shared_ptr<Face>;
85 
90 
95  FaceT();
96 
102  FaceT(const EdgePtr& a_edge);
103 
109  FaceT(const Face& a_otherFace);
110 
114  virtual ~FaceT();
115 
121  inline void
122  define(const Vec3& a_normal, const EdgePtr& a_edge) noexcept;
123 
130  inline void
131  reconcile() noexcept;
132 
136  inline void
137  flip() noexcept;
138 
143  inline void
144  setHalfEdge(const EdgePtr& a_halfEdge) noexcept;
145 
153  inline void
154  setInsideOutsideAlgorithm(typename Polygon2D<T>::InsideOutsideAlgorithm& a_algorithm) noexcept;
155 
159  inline EdgePtr&
160  getHalfEdge() noexcept;
161 
165  inline const EdgePtr&
166  getHalfEdge() const noexcept;
167 
171  inline Vec3T<T>&
172  getCentroid() noexcept;
173 
177  inline const Vec3T<T>&
178  getCentroid() const noexcept;
179 
184  inline T&
185  getCentroid(const size_t a_dir) noexcept;
186 
191  inline const T&
192  getCentroid(const size_t a_dir) const noexcept;
193 
197  inline Vec3T<T>&
198  getNormal() noexcept;
199 
203  inline const Vec3T<T>&
204  getNormal() const noexcept;
205 
210  inline Meta&
211  getMetaData() noexcept;
212 
217  inline const Meta&
218  getMetaData() const noexcept;
219 
223  inline T
224  computeArea() noexcept;
225 
234  inline T
235  signedDistance(const Vec3& a_x0) const noexcept;
236 
245  inline T
246  unsignedDistance2(const Vec3& a_x0) const noexcept;
247 
252  inline std::vector<Vec3T<T>>
253  getAllVertexCoordinates() const noexcept;
254 
259  inline std::vector<VertexPtr>
260  gatherVertices() const noexcept;
261 
265  inline Vec3T<T>
266  getSmallestCoordinate() const noexcept;
267 
271  inline Vec3T<T>
272  getHighestCoordinate() const noexcept;
273 
274  protected:
279 
284 
289 
294 
299  std::shared_ptr<Polygon2D<T>> m_poly2;
300 
304  typename Polygon2D<T>::InsideOutsideAlgorithm m_poly2Algorithm;
305 
309  inline void
310  computeCentroid() noexcept;
311 
315  inline void
316  computeNormal() noexcept;
317 
321  inline void
322  computePolygon2D() noexcept;
323 
327  inline void
329 
333  inline T
334  getArea() noexcept;
335 
339  inline T
340  getArea() const noexcept;
341 
345  inline void
347 
352  inline Vec3T<T>
353  projectPointIntoFacePlane(const Vec3& a_p) const noexcept;
354 
361  inline bool
362  isPointInsideFace(const Vec3& a_p) const noexcept;
363  };
364 } // namespace DCEL
365 
366 #include "EBGeometry_NamespaceFooter.hpp"
367 
368 #include "EBGeometry_DCEL_FaceImplem.hpp"
369 
370 #endif
Declaration of a half-edge class for use in DCEL descriptions of polygon tesselations.
Declaration of a vertex class for use in DCEL descriptions of polygon tesselations.
Declaration of a two-dimensional polygon class for embedding 3D polygon faces.
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
void normalizeNormalVector() noexcept
Normalize the normal vector, ensuring it has a length of 1.
virtual ~FaceT()
Destructor (does nothing)
Vec3T< T > projectPointIntoFacePlane(const Vec3 &a_p) const noexcept
Compute the projection of a point onto the polygon face plane.
std::shared_ptr< Vertex > VertexPtr
Alias for vertex pointer type.
Definition: EBGeometry_DCEL_Face.hpp:74
std::vector< Vec3T< T > > getAllVertexCoordinates() const noexcept
Return the coordinates of all the vertices on this polygon.
void setHalfEdge(const EdgePtr &a_halfEdge) noexcept
Set the half edge.
std::shared_ptr< Edge > EdgePtr
Alias for edge pointer type.
Definition: EBGeometry_DCEL_Face.hpp:79
EdgePtr m_halfEdge
This polygon's half-edge. A valid face will always have != nullptr.
Definition: EBGeometry_DCEL_Face.hpp:278
Vec3 m_normal
Polygon face normal vector.
Definition: EBGeometry_DCEL_Face.hpp:283
void reconcile() noexcept
Reconcile face. This will compute the normal vector, area, centroid, and the 2D embedding of the poly...
Meta & getMetaData() noexcept
Get meta-data.
void computePolygon2D() noexcept
Compute the 2D embedding of this polygon.
std::vector< VertexPtr > gatherVertices() const noexcept
Return all the vertices on this polygon.
FaceT(const EdgePtr &a_edge)
Partial constructor. Calls default constructor but associates a half-edge.
Polygon2D< T >::InsideOutsideAlgorithm m_poly2Algorithm
Algorithm for inside/outside tests.
Definition: EBGeometry_DCEL_Face.hpp:304
std::shared_ptr< Face > FacePtr
Alias for face pointer type.
Definition: EBGeometry_DCEL_Face.hpp:84
Vec3T< T > getHighestCoordinate() const noexcept
Get the upper-right-most coordinate of this polygon face.
T signedDistance(const Vec3 &a_x0) const noexcept
Compute the signed distance to a point.
void computeNormal() noexcept
Compute the normal position of this polygon.
void setInsideOutsideAlgorithm(typename Polygon2D< T >::InsideOutsideAlgorithm &a_algorithm) noexcept
Set the inside/outside algorithm when determining if a point projects to the inside or outside of the...
Vec3T< T > getSmallestCoordinate() const noexcept
Get the lower-left-most coordinate of this polygon face.
Vec3 m_centroid
Polygon face centroid position.
Definition: EBGeometry_DCEL_Face.hpp:288
Vec3T< T > & getNormal() noexcept
Get modifiable normal vector.
Vec3T< T > & getCentroid() noexcept
Get modifiable centroid.
T computeArea() noexcept
Compute the area of this polygon.
void computeCentroid() noexcept
Compute the centroid position of this polygon.
void flip() noexcept
Flip the normal vector.
T getArea() noexcept
Get the area of this polygon face.
Meta m_metaData
Meta-data attached to this face.
Definition: EBGeometry_DCEL_Face.hpp:293
FaceT(const Face &a_otherFace)
Partial constructor.
T unsignedDistance2(const Vec3 &a_x0) const noexcept
Compute the unsigned squared distance to a point.
EdgePtr & getHalfEdge() noexcept
Get modifiable half-edge.
std::shared_ptr< Polygon2D< T > > m_poly2
2D embedding of this polygon. This is the 2D view of the current object projected along its normal ve...
Definition: EBGeometry_DCEL_Face.hpp:299
void define(const Vec3 &a_normal, const EdgePtr &a_edge) noexcept
Define function which sets the normal vector and half-edge.
FaceT()
Default constructor. Sets the half-edge to zero and the inside/outside algorithm to crossing number a...
bool isPointInsideFace(const Vec3 &a_p) const noexcept
Check if a point projects to inside or outside the polygon face.
void computeAndStoreEdges() noexcept
Compute and store all the half-edges around this polygon face.
Vertex class.
Definition: EBGeometry_DCEL_Vertex.hpp:40
Class for embedding a polygon face into 2D.
Definition: EBGeometry_Polygon2D.hpp:43
Three-dimensional vector class with arithmetic operators.
Definition: EBGeometry_Vec.hpp:218
Namespace containing various double-connected edge list (DCEL) functionality.