14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/scene/api.h>
16#include <lagrange/utils/invalid.h>
19#include <Eigen/Geometry>
24namespace lagrange::scene {
34template <
typename Scalar,
typename Index,
size_t Dimension = 3>
38 using AffineTransform = Eigen::Transform<Scalar, static_cast<int>(Dimension), Eigen::Affine>;
50 constexpr static size_t Dim = Dimension;
60template <
typename Scalar,
typename Index,
size_t Dimension = 3>
74 constexpr static size_t Dim = Dimension;
93 return static_cast<Index
>(
m_instances[mesh_index].size());
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
A lightweight non-owning reference to a callable.
Definition function_ref.h:47
Simple scene container for instanced meshes.
Definition SimpleScene.h:62
MeshInstance< Scalar, Index, Dimension > InstanceType
Instance type.
Definition SimpleScene.h:68
static constexpr size_t Dim
Definition SimpleScene.h:74
typename InstanceType::AffineTransform AffineTransform
Affine transform matrix.
Definition SimpleScene.h:71
Index get_num_instances(Index mesh_index) const
Gets the number of instances for a given mesh.
Definition SimpleScene.h:91
InstanceType & ref_instance(Index mesh_index, Index instance_index)
Get a reference to a mesh instance in the scene.
Definition SimpleScene.h:142
Index add_mesh(MeshType mesh)
Adds a mesh to the scene, possibly with existing instances.
Definition SimpleScene.cpp:37
MeshType & ref_mesh(Index mesh_index)
Gets a modifiable reference to a mesh in a scene.
Definition SimpleScene.h:119
void foreach_instances_for_mesh(Index mesh_index, function_ref< void(const InstanceType &)> func) const
Iterates over all instances of a specific mesh.
Definition SimpleScene.cpp:61
void foreach_instances(function_ref< void(const InstanceType &)> func) const
Iterates over all instances of the scene.
Definition SimpleScene.cpp:71
void reserve_meshes(Index num_meshes)
Pre-allocate a number of meshes in the scene.
Definition SimpleScene.cpp:30
const InstanceType & get_instance(Index mesh_index, Index instance_index) const
Get a const reference to a mesh instance in the scene.
Definition SimpleScene.h:129
std::vector< std::vector< InstanceType > > m_instances
Definition SimpleScene.h:201
std::vector< MeshType > m_meshes
Definition SimpleScene.h:198
const MeshType & get_mesh(Index mesh_index) const
Gets a const reference to a mesh in the scene.
Definition SimpleScene.h:110
Index get_num_meshes() const
Gets the number of meshes in the scene.
Definition SimpleScene.h:82
void reserve_instances(Index mesh_index, Index num_instances)
Pre-allocate a number of instances for a given mesh.
Definition SimpleScene.cpp:46
Index compute_num_instances() const
Calculates the total number instances for all meshes in the scene.
Definition SimpleScene.cpp:20
SurfaceMesh< Scalar, Index > MeshType
Mesh type.
Definition SimpleScene.h:65
Index add_instance(InstanceType instance)
Adds a new instance of an existing mesh.
Definition SimpleScene.cpp:52
constexpr T invalid()
You can use invalid<T>() to get a value that can represent "invalid" values, such as invalid indices ...
Definition invalid.h:40
A single mesh instance in a scene.
Definition SimpleScene.h:36
static constexpr size_t Dim
Definition SimpleScene.h:50
std::any user_data
Definition SimpleScene.h:47
Index mesh_index
Definition SimpleScene.h:41
AffineTransform transform
Definition SimpleScene.h:44
Eigen::Transform< Scalar, static_cast< int >(Dimension), Eigen::Affine > AffineTransform
Affine transformation matrix.
Definition SimpleScene.h:38