4#ifndef GREM_CORE_DATA_TRIANGLE_MESH_HPP
5#define GREM_CORE_DATA_TRIANGLE_MESH_HPP
27template <
size_t N,
typename Scalar>
39template <
size_t N,
typename Scalar>
59 : vertices(std::
move(vertices))
60 , indices(std::
move(indices))
63 , faceOrthtree(boundingBox,
maxComponent(boundingBox.
max - boundingBox.
min) * Scalar{0.002}) {
65 GREM_ASSERT(this->indices.
size() / 3 <=
size_t{Limits<FaceIndex>::MAX});
67 for (
FaceIndex faceIndex = 0; faceIndex < faceCount; ++faceIndex) {
68 const size_t indexOffset =
static_cast<size_t>(faceIndex) * 3;
73 .pointA = this->vertices[this->indices[indexOffset + 0]],
74 .pointB = this->vertices[this->indices[indexOffset + 1]],
75 .pointC = this->vertices[this->indices[indexOffset + 2]],
78 faceOrthtree.insert(triangleAABB, faceIndex);
135 return boundingRadius;
154 Scalar boundingRadius;
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
Definition Allocation.hpp:25
constexpr iterator begin() noexcept
Definition Allocation.hpp:433
constexpr size_type size() const noexcept
Definition Allocation.hpp:485
constexpr iterator end() noexcept
Definition Allocation.hpp:445
Orthtree-based space subdivision structure, optimized for intersection queries between axis-aligned b...
Definition LooseOrthtree.hpp:65
TriangleMeshVertexIndex VertexIndex
Vertex index type of the triangle mesh.
Definition TriangleMesh.hpp:43
TriangleMeshVertex< N, Scalar > Vertex
Vertex type of the triangle mesh.
Definition TriangleMesh.hpp:42
TriangleMeshFaceIndex FaceIndex
Face index type of the triangle mesh.
Definition TriangleMesh.hpp:44
const LooseOrthtree< N, Scalar, FaceIndex > & getFaceOrthtree() const noexcept
Get the orthtree of faces in the mesh.
Definition TriangleMesh.hpp:146
TriangleMesh(Allocation< Vertex > vertices, Allocation< VertexIndex > indices)
Construct a triangle mesh from a set of vertices.
Definition TriangleMesh.hpp:58
Scalar getBoundingRadius() const noexcept
Get the bounding radius of the mesh.
Definition TriangleMesh.hpp:134
TriangleMesh(Span< const Vertex > vertices, Span< const VertexIndex > indices)
Construct a triangle mesh from a set of vertices and indices.
Definition TriangleMesh.hpp:95
Span< const Vertex > getVertices() const noexcept
Get the vertices of the mesh.
Definition TriangleMesh.hpp:103
Box< N, Scalar > getBoundingBox() const noexcept
Get the bounding box of the mesh.
Definition TriangleMesh.hpp:125
Span< const VertexIndex > getIndices() const noexcept
Get the vertex indices of the mesh.
Definition TriangleMesh.hpp:115
constexpr T calculateBoundingRadius(StridedSpan< const Point< N, T > > points) noexcept
Calculate the bounding radius from the origin of a set of points.
Definition geometry.hpp:1618
uint32_t TriangleMeshVertexIndex
Index of a vertex in a triangle mesh.
Definition TriangleMesh.hpp:30
constexpr auto move(input_range auto &&range, auto outputIterator)
Definition algorithms.hpp:669
vec< N, Scalar > TriangleMeshVertex
Vertex in a triangle mesh.
Definition TriangleMesh.hpp:28
GREM_ALWAYS_INLINE constexpr decltype(auto) max(A &&a, B &&b)
Get the greater of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:598
uint32_t TriangleMeshFaceIndex
Index of a triangle in a triangle mesh, equal to the index of the first vertex index divided by 3.
Definition TriangleMesh.hpp:31
GREM_ALWAYS_INLINE constexpr decltype(auto) min(A &&a, B &&b)
Get the smaller of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:585
constexpr Box< N, T > calculateBoundingBox(StridedSpan< const Point< N, T > > points) noexcept
Calculate the axis-aligned bounding box of a set of points.
Definition geometry.hpp:1595
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL maxComponent(vec< 1, T > a)
Definition math.hpp:1920
Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space.
Definition geometry.hpp:149
Generic triangle shape in N-dimensional space.
Definition geometry.hpp:586
constexpr Box< N, T > getBoundingBox() const noexcept
Get the axis-aligned bounding box of the triangle.
Definition geometry.hpp:760