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>;
41 Index mesh_index = invalid<Index>();
47 std::any user_data = {};
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());
101 Index compute_num_instances()
const;
131 return m_instances[mesh_index][instance_index];
144 return m_instances[mesh_index][instance_index];
152 void reserve_meshes(Index num_meshes);
169 void reserve_instances(Index mesh_index, Index num_instances);
178 Index add_instance(InstanceType instance);
186 void foreach_instances_for_mesh(Index mesh_index,
function_ref<
void(
const InstanceType&)> func)
194 void foreach_instances(
function_ref<
void(
const InstanceType&)> func)
const;
A lightweight non-owning reference to a callable.
Definition: function_ref.h:47
Simple scene container for instanced meshes.
Definition: SimpleScene.h:62
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
MeshType & ref_mesh(Index mesh_index)
Gets a modifiable reference to a mesh in a scene.
Definition: SimpleScene.h:119
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
List of mesh instances in the scene. Stored as a list of instance per parent mesh.
Definition: SimpleScene.h:201
std::vector< MeshType > m_meshes
List of meshes in the scene.
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
A single mesh instance in a scene.
Definition: SimpleScene.h:36
Eigen::Transform< Scalar, static_cast< int >(Dimension), Eigen::Affine > AffineTransform
Affine transformation matrix.
Definition: SimpleScene.h:38