EBGeometry  1.0
EBGeometry_MeshDistanceFunctions.hpp
Go to the documentation of this file.
1 /* EBGeometry
2  * Copyright © 2023 Robert Marskar
3  * Please refer to Copyright.txt and LICENSE in the EBGeometry root directory.
4  */
5 
12 #ifndef EBGeometry_MeshDistanceFunctions
13 #define EBGeometry_MeshDistanceFunctions
14 
15 // Our includes
18 #include "EBGeometry_DCEL_Mesh.hpp"
19 #include "EBGeometry_BVH.hpp"
21 
22 namespace DCEL {
23 
30  template <class T, class Meta, class BV, size_t K>
31  std::shared_ptr<EBGeometry::BVH::NodeT<T, FaceT<T, Meta>, BV, K>>
32  buildFullBVH(const std::shared_ptr<EBGeometry::DCEL::MeshT<T, Meta>>& a_dcelMesh,
33  const BVH::Build a_build = BVH::Build::TopDown) noexcept;
34 } // namespace DCEL
35 
39 template <class T, class Meta = DCEL::DefaultMetaData>
41 {
42 public:
46  using Mesh = EBGeometry::DCEL::MeshT<T, Meta>;
47 
51  MeshSDF() = delete;
52 
57  MeshSDF(const std::shared_ptr<Mesh>& a_mesh) noexcept;
58 
62  virtual ~MeshSDF() = default;
63 
67  virtual T
68  signedDistance(const Vec3T<T>& a_point) const noexcept override;
69 
73  const std::shared_ptr<Mesh>
74  getMesh() const noexcept;
75 
79  template <class BV>
80  BV
81  computeBoundingVolume() const noexcept;
82 
83 protected:
87  std::shared_ptr<Mesh> m_mesh;
88 };
89 
93 template <class T, class Meta, class BV, size_t K>
95 {
96 public:
100  using Face = typename EBGeometry::DCEL::FaceT<T, Meta>;
101 
105  using Mesh = typename EBGeometry::DCEL::MeshT<T, Meta>;
106 
110  using Node = EBGeometry::BVH::NodeT<T, Face, BV, K>;
111 
115  FastMeshSDF() = delete;
116 
122  FastMeshSDF(const std::shared_ptr<Mesh>& a_mesh, const BVH::Build a_build = BVH::Build::TopDown) noexcept;
123 
127  virtual ~FastMeshSDF() = default;
128 
133  virtual T
134  signedDistance(const Vec3T<T>& a_point) const noexcept override;
135 
144  virtual std::vector<std::pair<std::shared_ptr<const Face>, T>>
145  getClosestFaces(const Vec3T<T>& a_point, const bool a_sorted) const noexcept;
146 
150  virtual std::shared_ptr<Node>&
151  getBVH() noexcept;
152 
156  virtual const std::shared_ptr<Node>&
157  getBVH() const noexcept;
158 
162  BV
163  computeBoundingVolume() const noexcept;
164 
165 protected:
169  std::shared_ptr<Node> m_bvh;
170 };
171 
175 template <class T, class Meta, class BV, size_t K>
177 {
178 public:
182  using Face = typename EBGeometry::DCEL::FaceT<T, Meta>;
183 
187  using Mesh = typename EBGeometry::DCEL::MeshT<T, Meta>;
188 
192  using Root = typename EBGeometry::BVH::LinearBVH<T, Face, BV, K>;
193 
197  using Node = typename Root::LinearNode;
198 
202  FastCompactMeshSDF() = delete;
203 
209  FastCompactMeshSDF(const std::shared_ptr<Mesh>& a_mesh, const BVH::Build a_build = BVH::Build::TopDown) noexcept;
210 
214  virtual ~FastCompactMeshSDF() = default;
215 
220  virtual T
221  signedDistance(const Vec3T<T>& a_point) const noexcept override;
222 
231  virtual std::vector<std::pair<std::shared_ptr<const Face>, T>>
232  getClosestFaces(const Vec3T<T>& a_point, const bool a_sorted) const noexcept;
233 
237  virtual std::shared_ptr<Root>&
238  getRoot() noexcept;
239 
243  virtual const std::shared_ptr<Root>&
244  getRoot() const noexcept;
245 
249  BV
250  computeBoundingVolume() const noexcept;
251 
252 protected:
256  std::shared_ptr<Root> m_bvh;
257 };
258 
259 #include "EBGeometry_NamespaceFooter.hpp"
260 
261 #include "EBGeometry_MeshDistanceFunctionsImplem.hpp"
262 
263 #endif
Declaration of a bounding volume hierarchy (BVH) class.
Declaration of a various bounding volumes used for bounding volume hierarchy.
Declaration of a mesh class which stores a DCEL mesh (with signed distance functions)
Abstract base class for representing a signed distance function.
Signed distance function for a DCEL mesh. This class uses the compact BVH representation.
Definition: EBGeometry_MeshDistanceFunctions.hpp:177
FastCompactMeshSDF()=delete
Default disallowed constructor.
virtual ~FastCompactMeshSDF()=default
Destructor.
typename EBGeometry::BVH::LinearBVH< T, Face, BV, K > Root
Alias for which BVH root node.
Definition: EBGeometry_MeshDistanceFunctions.hpp:192
FastCompactMeshSDF(const std::shared_ptr< Mesh > &a_mesh, const BVH::Build a_build=BVH::Build::TopDown) noexcept
Full constructor. Takes the input mesh and creates the BVH.
typename Root::LinearNode Node
Alias for linearized BVH.
Definition: EBGeometry_MeshDistanceFunctions.hpp:197
virtual std::vector< std::pair< std::shared_ptr< const Face >, T > > getClosestFaces(const Vec3T< T > &a_point, const bool a_sorted) const noexcept
Get the closest faces to the input point.
virtual std::shared_ptr< Root > & getRoot() noexcept
Get the bounding volume hierarchy enclosing the mesh.
typename EBGeometry::DCEL::MeshT< T, Meta > Mesh
Alias for DCEL mesh type.
Definition: EBGeometry_MeshDistanceFunctions.hpp:187
typename EBGeometry::DCEL::FaceT< T, Meta > Face
Alias for DCEL face type.
Definition: EBGeometry_MeshDistanceFunctions.hpp:182
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Value function.
Signed distance function for a DCEL mesh. This class uses the full BVH representation.
Definition: EBGeometry_MeshDistanceFunctions.hpp:95
EBGeometry::BVH::NodeT< T, Face, BV, K > Node
Alias for BVH root node.
Definition: EBGeometry_MeshDistanceFunctions.hpp:110
virtual std::shared_ptr< Node > & getBVH() noexcept
Get the bounding volume hierarchy enclosing the mesh.
FastMeshSDF(const std::shared_ptr< Mesh > &a_mesh, const BVH::Build a_build=BVH::Build::TopDown) noexcept
Full constructor. Takes the input mesh and creates the BVH.
FastMeshSDF()=delete
Default disallowed constructor.
virtual ~FastMeshSDF()=default
Destructor.
typename EBGeometry::DCEL::FaceT< T, Meta > Face
Alias for DCEL face type.
Definition: EBGeometry_MeshDistanceFunctions.hpp:100
virtual std::vector< std::pair< std::shared_ptr< const Face >, T > > getClosestFaces(const Vec3T< T > &a_point, const bool a_sorted) const noexcept
Get the closest faces to the input point.
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Value function.
typename EBGeometry::DCEL::MeshT< T, Meta > Mesh
Alias for DCEL mesh type.
Definition: EBGeometry_MeshDistanceFunctions.hpp:105
Signed distance function for a DCEL mesh. Does not use BVHs.
Definition: EBGeometry_MeshDistanceFunctions.hpp:41
std::shared_ptr< Mesh > m_mesh
DCEL mesh.
Definition: EBGeometry_MeshDistanceFunctions.hpp:87
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Value function.
MeshSDF(const std::shared_ptr< Mesh > &a_mesh) noexcept
Full constructor.
MeshSDF()=delete
Disallowed constructor.
EBGeometry::DCEL::MeshT< T, Meta > Mesh
Alias for DCEL mesh type.
Definition: EBGeometry_MeshDistanceFunctions.hpp:46
virtual ~MeshSDF()=default
Destructor.
const std::shared_ptr< Mesh > getMesh() const noexcept
Get the surface mesh.
BV computeBoundingVolume() const noexcept
Compute bounding volume for this mesh.
Abstract representation of a signed distance function.
Definition: EBGeometry_SignedDistanceFunction.hpp:32
Three-dimensional vector class with arithmetic operators.
Definition: EBGeometry_Vec.hpp:218
Build
Enum for specifying whether or not the construction is top-down or bottom-up.
Definition: EBGeometry_BVH.hpp:36
Namespace containing various double-connected edge list (DCEL) functionality.
std::shared_ptr< EBGeometry::BVH::NodeT< T, FaceT< T, Meta >, BV, K > > buildFullBVH(const std::shared_ptr< EBGeometry::DCEL::MeshT< T, Meta >> &a_dcelMesh, const BVH::Build a_build=BVH::Build::TopDown) noexcept
One-liner for turning a DCEL mesh into a full-tree BVH.