EBGeometry 1.0
Loading...
Searching...
No Matches
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
19#include "EBGeometry_BVH.hpp"
22
23namespace DCEL {
24
31 template <class T, class Meta, class BV, size_t K>
32 std::shared_ptr<EBGeometry::BVH::NodeT<T, FaceT<T, Meta>, BV, K>>
33 buildFullBVH(const std::shared_ptr<EBGeometry::DCEL::MeshT<T, Meta>>& a_dcelMesh,
34 const BVH::Build a_build = BVH::Build::TopDown) noexcept;
35} // namespace DCEL
36
40template <class T, class Meta = DCEL::DefaultMetaData>
42{
43public:
47 using Mesh = EBGeometry::DCEL::MeshT<T, Meta>;
48
52 MeshSDF() = delete;
53
58 MeshSDF(const std::shared_ptr<Mesh>& a_mesh) noexcept;
59
63 virtual ~MeshSDF() = default;
64
68 virtual T
69 signedDistance(const Vec3T<T>& a_point) const noexcept override;
70
74 const std::shared_ptr<Mesh>
76
81 BV
83
89};
90
94template <class T, class Meta, class BV, size_t K>
96{
97public:
101 using Face = typename EBGeometry::DCEL::FaceT<T, Meta>;
102
106 using Mesh = typename EBGeometry::DCEL::MeshT<T, Meta>;
107
111 using Node = EBGeometry::BVH::NodeT<T, Face, BV, K>;
112
116 FastMeshSDF() = delete;
117
123 FastMeshSDF(const std::shared_ptr<Mesh>& a_mesh, const BVH::Build a_build = BVH::Build::TopDown) noexcept;
124
128 virtual ~FastMeshSDF() = default;
129
134 virtual T
135 signedDistance(const Vec3T<T>& a_point) const noexcept override;
136
145 virtual std::vector<std::pair<std::shared_ptr<const Face>, T>>
146 getClosestFaces(const Vec3T<T>& a_point, const bool a_sorted) const noexcept;
147
151 virtual std::shared_ptr<Node>&
153
158 getBVH() const noexcept;
159
163 BV
165
170 std::shared_ptr<Node> m_bvh;
171};
172
176template <class T, class Meta, class BV, size_t K>
178{
179public:
183 using Face = typename EBGeometry::DCEL::FaceT<T, Meta>;
184
188 using Mesh = typename EBGeometry::DCEL::MeshT<T, Meta>;
189
193 using Root = typename EBGeometry::BVH::LinearBVH<T, Face, BV, K>;
194
198 using Node = typename Root::LinearNode;
199
204
210 FastCompactMeshSDF(const std::shared_ptr<Mesh>& a_mesh, const BVH::Build a_build = BVH::Build::TopDown) noexcept;
211
215 virtual ~FastCompactMeshSDF() = default;
216
221 virtual T
222 signedDistance(const Vec3T<T>& a_point) const noexcept override;
223
232 virtual std::vector<std::pair<std::shared_ptr<const Face>, T>>
233 getClosestFaces(const Vec3T<T>& a_point, const bool a_sorted) const noexcept;
234
238 virtual std::shared_ptr<Root>&
240
245 getRoot() const noexcept;
246
250 BV
252
257 std::shared_ptr<Root> m_bvh;
258};
259
263template <class T, class Meta, class BV, size_t K>
265{
266public:
270 using Mesh = EBGeometry::DCEL::MeshT<T, Meta>;
271
276
280 using Root = typename EBGeometry::BVH::LinearBVH<T, Tri, BV, K>;
281
285 using Node = typename Root::LinearNode;
286
290 FastTriMeshSDF() = delete;
291
297 FastTriMeshSDF(const std::shared_ptr<Mesh>& a_mesh, const BVH::Build a_build = BVH::Build::TopDown) noexcept;
298
304 FastTriMeshSDF(const std::vector<std::shared_ptr<Tri>>& a_triangles,
305 const BVH::Build a_build = BVH::Build::TopDown) noexcept;
306
310 virtual ~FastTriMeshSDF() = default;
311
316 virtual T
317 signedDistance(const Vec3T<T>& a_point) const noexcept override;
318
327 virtual std::vector<std::pair<std::shared_ptr<const Tri>, T>>
328 getClosestTriangles(const Vec3T<T>& a_point, const bool a_sorted) const noexcept;
329
333 virtual std::shared_ptr<Root>&
335
340 getRoot() const noexcept;
341
345 BV
347
352 std::shared_ptr<Root> m_bvh;
353};
354
355#include "EBGeometry_NamespaceFooter.hpp"
356
357#include "EBGeometry_MeshDistanceFunctionsImplem.hpp"
358
359#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.
Declaration of a triangle class with signed distance functionality.
Triangle class with signed distance functionality.
Definition EBGeometry_Triangle.hpp:49
Signed distance function for a DCEL mesh. This class uses the compact BVH representation.
Definition EBGeometry_MeshDistanceFunctions.hpp:178
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:193
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:198
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:188
typename EBGeometry::DCEL::FaceT< T, Meta > Face
Alias for DCEL face type.
Definition EBGeometry_MeshDistanceFunctions.hpp:183
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:96
EBGeometry::BVH::NodeT< T, Face, BV, K > Node
Alias for BVH root node.
Definition EBGeometry_MeshDistanceFunctions.hpp:111
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.
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:101
virtual std::shared_ptr< Node > & getBVH() noexcept
Get the bounding volume hierarchy enclosing the mesh.
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:106
Signed distance function for a triangle mesh. This class uses the full BVH representation.
Definition EBGeometry_MeshDistanceFunctions.hpp:265
virtual std::vector< std::pair< std::shared_ptr< const Tri >, T > > getClosestTriangles(const Vec3T< T > &a_point, const bool a_sorted) const noexcept
Get the closest triangles to the input point.
virtual ~FastTriMeshSDF()=default
Destructor.
EBGeometry::DCEL::MeshT< T, Meta > Mesh
Alias for DCEL mesh type.
Definition EBGeometry_MeshDistanceFunctions.hpp:270
virtual std::shared_ptr< Root > & getRoot() noexcept
Get the bounding volume hierarchy enclosing the mesh.
FastTriMeshSDF(const std::vector< std::shared_ptr< Tri > > &a_triangles, const BVH::Build a_build=BVH::Build::TopDown) noexcept
Full constructor. Takes the input triangles and creates the BVH.
FastTriMeshSDF()=delete
Default disallowed constructor.
typename EBGeometry::BVH::LinearBVH< T, Tri, BV, K > Root
Alias for which BVH root node.
Definition EBGeometry_MeshDistanceFunctions.hpp:280
FastTriMeshSDF(const std::shared_ptr< Mesh > &a_mesh, const BVH::Build a_build=BVH::Build::TopDown) noexcept
Full constructor. Takes a DCEL mesh and creates the input triangles. Then creates the BVH.
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Value function.
typename EBGeometry::Triangle< T, Meta > Tri
Alias for DCEL face type.
Definition EBGeometry_MeshDistanceFunctions.hpp:275
typename Root::LinearNode Node
Alias for linearized BVH.
Definition EBGeometry_MeshDistanceFunctions.hpp:285
Signed distance function for a DCEL mesh. Does not use BVHs.
Definition EBGeometry_MeshDistanceFunctions.hpp:42
std::shared_ptr< Mesh > m_mesh
DCEL mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:88
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:47
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.