EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_DCEL_Mesh.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
12#ifndef EBGEOMETRY_DCEL_MESH_HPP
13#define EBGEOMETRY_DCEL_MESH_HPP
14
15// Std includes
16#include <cstddef>
17#include <map>
18#include <memory>
19#include <string>
20#include <type_traits>
21#include <vector>
22
23// Our includes
24#include "EBGeometry_DCEL.hpp"
26
27namespace EBGeometry {
28
29namespace DCEL {
30
48template <class T, class Meta>
49class MeshT
50{
51 static_assert(std::is_floating_point_v<T>, "MeshT requires a floating-point T");
52
53public:
57 enum class SearchAlgorithm
58 {
59 Direct,
61 Direct2
64 };
65
69 using Vec3 = Vec3T<T>;
70
75
80
85
90
94 using VertexPtr = std::shared_ptr<Vertex>;
95
99 using EdgePtr = std::shared_ptr<Edge>;
100
104 using FacePtr = std::shared_ptr<Face>;
105
112
123
129
143 MeshT(std::vector<FacePtr>& a_faces, std::vector<EdgePtr>& a_edges, std::vector<VertexPtr>& a_vertices) noexcept;
144
149
156 Mesh&
158
164 Mesh&
166
179 [[nodiscard]] inline std::shared_ptr<Mesh>
181
190 inline void
192
197 inline void
199
208 inline void
210
220 inline void
222
227 inline void
229
234 [[nodiscard]] inline std::vector<VertexPtr>&
236
241 [[nodiscard]] inline const std::vector<VertexPtr>&
243
248 [[nodiscard]] inline std::vector<Vec3T<T>>
250
255 [[nodiscard]] inline std::vector<EdgePtr>&
257
262 [[nodiscard]] inline const std::vector<EdgePtr>&
264
269 [[nodiscard]] inline std::vector<FacePtr>&
271
276 [[nodiscard]] inline const std::vector<FacePtr>&
278
290 [[nodiscard]] inline T
292
304 [[nodiscard]] inline T
306
316 [[nodiscard]] inline T
318
324
328 std::vector<VertexPtr> m_vertices;
329
333 std::vector<EdgePtr> m_edges;
334
338 std::vector<FacePtr> m_faces;
339
344 inline void
346
351 inline void
353
360 inline void
362
366 inline void
368
372 inline void
374
378 inline void
380
387 [[nodiscard]] inline T
389
399 [[nodiscard]] inline T
401
408 inline void
409 incrementWarning(std::map<std::string, size_t>& a_warnings, const std::string& a_warn) const;
410
416 inline void
417 printWarnings(const std::map<std::string, size_t>& a_warnings, const std::string& a_id) const;
418};
419} // namespace DCEL
420
421} // namespace EBGeometry
422
423#include "EBGeometry_DCEL_MeshImplem.hpp"
424
425#endif
Namespace documentation.
Declaration of a two-dimensional polygon class for embedding 3D polygon faces.
DCEL mesh class - stores a doubly-connected edge mesh.
Definition EBGeometry_DCEL_Mesh.hpp:50
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 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::vector< FacePtr > & getFaces() noexcept
Get modifiable faces in this mesh.
void reconcileVertices(const DCEL::VertexNormalWeight a_weight) noexcept
Function which computes internal things for the vertices.
std::shared_ptr< Face > FacePtr
Alias for face pointer type.
Definition EBGeometry_DCEL_Mesh.hpp:104
std::vector< FacePtr > m_faces
Mesh faces.
Definition EBGeometry_DCEL_Mesh.hpp:338
std::shared_ptr< Mesh > deepCopy() const
Create an independent, fully-decoupled copy of this mesh.
T unsignedDistance2(const Vec3 &a_x0) const noexcept
Compute the unsigned square distance from a point to this mesh.
std::vector< EdgePtr > & getEdges() noexcept
Get modifiable half-edges in this mesh.
std::vector< Vec3T< T > > getAllVertexCoordinates() const noexcept
Return all vertex coordinates in the mesh.
SearchAlgorithm
Possible search algorithms for DCEL::MeshT.
Definition EBGeometry_DCEL_Mesh.hpp:58
void flip() noexcept
Flip the mesh, making all the normals change direction.
T DirectSignedDistance2(const Vec3 &a_point) const noexcept
Implementation of squared signed distance function which iterates through all faces.
void printWarnings(const std::map< std::string, size_t > &a_warnings, const std::string &a_id) const
Print all warnings to std::cerr.
std::vector< VertexPtr > & getVertices() noexcept
Get modifiable vertices in this mesh.
void sanityCheck(const std::string a_id) const
Perform a sanity check.
MeshT() noexcept=default
Default constructor.
void reconcileFaces() noexcept
Function which computes internal things for the polygon faces.
SearchAlgorithm m_algorithm
Search algorithm. Only used in signed distance functions.
Definition EBGeometry_DCEL_Mesh.hpp:323
void setSearchAlgorithm(const SearchAlgorithm a_algorithm) noexcept
Search algorithm for direct signed distance computations.
std::vector< VertexPtr > m_vertices
Mesh vertices.
Definition EBGeometry_DCEL_Mesh.hpp:328
void reconcileEdges() noexcept
Function which computes internal things for the half-edges.
std::shared_ptr< Edge > EdgePtr
Alias for edge pointer type.
Definition EBGeometry_DCEL_Mesh.hpp:99
std::vector< EdgePtr > m_edges
Mesh half-edges.
Definition EBGeometry_DCEL_Mesh.hpp:333
void flipFaceNormals() noexcept
Flip all face normals.
void incrementWarning(std::map< std::string, size_t > &a_warnings, const std::string &a_warn) const
Increment a warning. This is used in sanityCheck() for locating holes or bad inputs in the mesh.
std::shared_ptr< Vertex > VertexPtr
Alias for vertex pointer type.
Definition EBGeometry_DCEL_Mesh.hpp:94
T signedDistance(const Vec3 &a_x0) const noexcept
Compute the signed distance from a point to this mesh.
T DirectSignedDistance(const Vec3 &a_point) const noexcept
Implementation of signed distance function which iterates through all faces.
void flipVertexNormals() noexcept
Flip all vertex normals.
void flipEdgeNormals() noexcept
Flip all edge normals.
Class for embedding a polygon face into 2D.
Definition EBGeometry_Polygon2D.hpp:46
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:225
VertexNormalWeight
Various supported vertex normal vector calculation methods.
Definition EBGeometry_DCEL.hpp:74
@ Angle
Angle-weighted pseudonormal (Baerentzen and Aanes, DOI: 10.1109/TVCG.2005.49).
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:31