EBGeometry  1.0
EBGeometry_DCEL_Mesh.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_Mesh
14 #define EBGeometry_DCEL_Mesh
15 
16 // Std includes
17 #include <vector>
18 #include <memory>
19 #include <functional>
20 #include <map>
21 
22 // Our includes
23 #include "EBGeometry_DCEL.hpp"
24 #include "EBGeometry_Polygon2D.hpp"
26 
27 namespace DCEL {
28 
44  template <class T, class Meta>
45  class MeshT
46  {
47  public:
53  enum class SearchAlgorithm
54  {
55  Direct,
56  Direct2,
57  };
58 
62  enum class VertexNormalWeight
63  {
64  None,
65  Angle,
66  };
67 
71  using Vec3 = Vec3T<T>;
72 
77 
82 
87 
92 
96  using VertexPtr = std::shared_ptr<Vertex>;
97 
101  using EdgePtr = std::shared_ptr<Edge>;
102 
106  using FacePtr = std::shared_ptr<Face>;
107 
111  MeshT() noexcept;
112 
117  MeshT(const Mesh& a_otherMesh) = delete;
118 
130  MeshT(std::vector<FacePtr>& a_faces, std::vector<EdgePtr>& a_edges, std::vector<VertexPtr>& a_vertices) noexcept;
131 
135  virtual ~MeshT() noexcept;
136 
148  inline void
149  define(std::vector<FacePtr>& a_faces, std::vector<EdgePtr>& a_edges, std::vector<VertexPtr>& a_vertices) noexcept;
150 
158  inline void
159  sanityCheck() const noexcept;
160 
165  inline void
166  setSearchAlgorithm(const SearchAlgorithm a_algorithm) noexcept;
167 
176  inline void
177  setInsideOutsideAlgorithm(typename Polygon2D<T>::InsideOutsideAlgorithm a_algorithm) noexcept;
178 
188  inline void
189  reconcile(const DCEL::VertexNormalWeight a_weight = DCEL::VertexNormalWeight::Angle) noexcept;
190 
195  inline void
196  flip() noexcept;
197 
201  inline std::vector<VertexPtr>&
202  getVertices() noexcept;
203 
207  inline const std::vector<VertexPtr>&
208  getVertices() const noexcept;
209 
213  inline std::vector<Vec3T<T>>
214  getAllVertexCoordinates() const noexcept;
215 
219  inline std::vector<EdgePtr>&
220  getEdges() noexcept;
221 
225  inline const std::vector<EdgePtr>&
226  getEdges() const noexcept;
227 
231  inline std::vector<FacePtr>&
232  getFaces() noexcept;
233 
237  inline const std::vector<FacePtr>&
238  getFaces() const noexcept;
239 
249  inline T
250  signedDistance(const Vec3& a_x0) const noexcept;
251 
261  inline T
262  signedDistance(const Vec3& a_x0, SearchAlgorithm a_algorithm) const noexcept;
263 
273  inline T
274  unsignedDistance2(const Vec3& a_x0) const noexcept;
275 
276  protected:
281 
285  std::vector<VertexPtr> m_vertices;
286 
290  std::vector<EdgePtr> m_edges;
291 
295  std::vector<FacePtr> m_faces;
296 
301  inline void
302  reconcileFaces() noexcept;
303 
308  inline void
309  reconcileEdges() noexcept;
310 
317  inline void
318  reconcileVertices(const DCEL::VertexNormalWeight a_weight) noexcept;
319 
323  inline void
324  flipFaces() noexcept;
325 
329  inline void
330  flipEdges() noexcept;
331 
335  inline void
336  flipVertices() noexcept;
337 
343  inline T
344  DirectSignedDistance(const Vec3& a_point) const noexcept;
345 
354  inline T
355  DirectSignedDistance2(const Vec3& a_point) const noexcept;
356 
363  inline void
364  incrementWarning(std::map<std::string, size_t>& a_warnings, const std::string& a_warn) const noexcept;
365 
369  inline void
370  printWarnings(const std::map<std::string, size_t>& a_warnings) const noexcept;
371  };
372 } // namespace DCEL
373 
374 #include "EBGeometry_NamespaceFooter.hpp"
375 
376 #include "EBGeometry_DCEL_MeshImplem.hpp"
377 
378 #endif
Namespace documentation.
Declaration of a two-dimensional polygon class for embedding 3D polygon faces.
Edge class.
Definition: EBGeometry_DCEL_Edge.hpp:47
Face class.
Definition: EBGeometry_DCEL_Face.hpp:49
Mesh class.
Definition: EBGeometry_DCEL_Mesh.hpp:46
T unsignedDistance2(const Vec3 &a_x0) const noexcept
Compute the unsigned square distance from a point to this mesh.
std::shared_ptr< Vertex > VertexPtr
Alias for vertex pointer type.
Definition: EBGeometry_DCEL_Mesh.hpp:96
std::vector< VertexPtr > m_vertices
Mesh vertices.
Definition: EBGeometry_DCEL_Mesh.hpp:285
void reconcileVertices(const DCEL::VertexNormalWeight a_weight) noexcept
Function which computes internal things for the vertices.
std::vector< FacePtr > m_faces
Mesh faces.
Definition: EBGeometry_DCEL_Mesh.hpp:295
SearchAlgorithm
Possible search algorithms for DCEL::MeshT.
Definition: EBGeometry_DCEL_Mesh.hpp:54
void reconcileEdges() noexcept
Function which computes internal things for the half-edges.
VertexNormalWeight
How to weight vertex normal.
Definition: EBGeometry_DCEL_Mesh.hpp:63
std::vector< EdgePtr > & getEdges() noexcept
Get modifiable half-edges in this mesh.
void define(std::vector< FacePtr > &a_faces, std::vector< EdgePtr > &a_edges, std::vector< VertexPtr > &a_vertices) noexcept
Define function. Puts Mesh in usable state.
void flipEdges() noexcept
Flip all edge normals.
std::shared_ptr< Face > FacePtr
Alias for face pointer type.
Definition: EBGeometry_DCEL_Mesh.hpp:106
void setSearchAlgorithm(const SearchAlgorithm a_algorithm) noexcept
Search algorithm for direct signed distance computations.
void flipFaces() noexcept
Flip all face normals.
void reconcile(const DCEL::VertexNormalWeight a_weight=DCEL::VertexNormalWeight::Angle) noexcept
Reconcile function which computes the internal parameters in vertices, edges, and faces for use with ...
std::shared_ptr< Edge > EdgePtr
Alias for edge pointer type.
Definition: EBGeometry_DCEL_Mesh.hpp:101
std::vector< FacePtr > & getFaces() noexcept
Get modifiable faces in this mesh.
std::vector< VertexPtr > & getVertices() noexcept
Get modifiable vertices in this mesh.
void sanityCheck() const noexcept
Perform a sanity check.
std::vector< EdgePtr > m_edges
Mesh half-edges.
Definition: EBGeometry_DCEL_Mesh.hpp:290
void incrementWarning(std::map< std::string, size_t > &a_warnings, const std::string &a_warn) const noexcept
Increment a warning. This is used in sanityCheck() for locating holes or bad inputs in the mesh.
void flipVertices() noexcept
Flip all vertex normal.
T DirectSignedDistance(const Vec3 &a_point) const noexcept
Implementation of signed distance function which iterates through all faces.
void flip() noexcept
Flip the mesh, making all the normals change direction.
void setInsideOutsideAlgorithm(typename Polygon2D< T >::InsideOutsideAlgorithm a_algorithm) noexcept
Set the inside/outside algorithm to use when computing the signed distance to polygon faces.
void reconcileFaces() noexcept
Function which computes internal things for the polygon faces.
T DirectSignedDistance2(const Vec3 &a_point) const noexcept
Implementation of squared signed distance function which iterates through all faces.
T signedDistance(const Vec3 &a_x0) const noexcept
Compute the signed distance from a point to this mesh.
std::vector< Vec3T< T > > getAllVertexCoordinates() const noexcept
Return all vertex coordinates in the mesh.
MeshT() noexcept
Default constructor. Leaves unobject in an unusable state.
void printWarnings(const std::map< std::string, size_t > &a_warnings) const noexcept
Print all warnings to std::cerr.
SearchAlgorithm m_algorithm
Search algorithm. Only used in signed distance functions.
Definition: EBGeometry_DCEL_Mesh.hpp:280
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.