Lagrange
SimpleScene< Scalar, Index, Dimension > Class Template Reference

Simple scene container for instanced meshes. More...

#include <lagrange/scene/SimpleScene.h>

Public Types

using MeshType = SurfaceMesh< Scalar, Index >
 Mesh type.
 
using InstanceType = MeshInstance< Scalar, Index, Dimension >
 Instance type.
 
using AffineTransform = typename InstanceType::AffineTransform
 Affine transform matrix.
 

Public Member Functions

Index get_num_meshes () const
 Gets the number of meshes in the scene. More...
 
Index get_num_instances (Index mesh_index) const
 Gets the number of instances for a given mesh. More...
 
Index compute_num_instances () const
 Calculates the total number instances for all meshes in the scene. More...
 
const MeshTypeget_mesh (Index mesh_index) const
 Gets a const reference to a mesh in the scene. More...
 
MeshTyperef_mesh (Index mesh_index)
 Gets a modifiable reference to a mesh in a scene. More...
 
const InstanceTypeget_instance (Index mesh_index, Index instance_index) const
 Get a const reference to a mesh instance in the scene. More...
 
InstanceTyperef_instance (Index mesh_index, Index instance_index)
 Get a reference to a mesh instance in the scene. More...
 
void reserve_meshes (Index num_meshes)
 Pre-allocate a number of meshes in the scene. More...
 
Index add_mesh (MeshType mesh)
 Adds a mesh to the scene, possibly with existing instances. More...
 
void reserve_instances (Index mesh_index, Index num_instances)
 Pre-allocate a number of instances for a given mesh. More...
 
Index add_instance (InstanceType instance)
 Adds a new instance of an existing mesh. More...
 
void foreach_instances_for_mesh (Index mesh_index, function_ref< void(const InstanceType &)> func) const
 Iterates over all instances of a specific mesh. More...
 
void foreach_instances (function_ref< void(const InstanceType &)> func) const
 Iterates over all instances of the scene. More...
 

Static Public Attributes

static constexpr size_t Dim = Dimension
 Access dimension from outside the class.
 

Protected Attributes

std::vector< MeshTypem_meshes
 List of meshes in the scene.
 
std::vector< std::vector< InstanceType > > m_instances
 List of mesh instances in the scene. Stored as a list of instance per parent mesh.
 

Detailed Description

template<typename Scalar, typename Index, size_t Dimension = 3>
class lagrange::scene::SimpleScene< Scalar, Index, Dimension >

Simple scene container for instanced meshes.

Template Parameters
ScalarMesh scalar type.
IndexMesh index type.
DimensionMesh dimension.

Member Function Documentation

◆ get_num_meshes()

Index get_num_meshes ( ) const
inline

Gets the number of meshes in the scene.

Returns
Number of meshes.

◆ get_num_instances()

Index get_num_instances ( Index  mesh_index) const
inline

Gets the number of instances for a given mesh.

Parameters
[in]mesh_indexMesh index.
Returns
Number of instances for a given mesh.

◆ compute_num_instances()

Index compute_num_instances

Calculates the total number instances for all meshes in the scene.

Returns
Total number of instances in the scene.

◆ get_mesh()

const MeshType & get_mesh ( Index  mesh_index) const
inline

Gets a const reference to a mesh in the scene.

Parameters
[in]mesh_indexMesh index.
Returns
Reference to the specified mesh.

◆ ref_mesh()

MeshType & ref_mesh ( Index  mesh_index)
inline

Gets a modifiable reference to a mesh in a scene.

Parameters
[in]mesh_indexMesh index.
Returns
Reference to the specified mesh.

◆ get_instance()

const InstanceType & get_instance ( Index  mesh_index,
Index  instance_index 
) const
inline

Get a const reference to a mesh instance in the scene.

Parameters
[in]mesh_indexIndex of the parent mesh in the scene.
[in]instance_indexLocal instance index respective to the parent mesh.
Returns
Reference to the specified mesh instance.

◆ ref_instance()

InstanceType & ref_instance ( Index  mesh_index,
Index  instance_index 
)
inline

Get a reference to a mesh instance in the scene.

Parameters
[in]mesh_indexIndex of the parent mesh in the scene.
[in]instance_indexLocal instance index respective to the parent mesh.
Returns
Reference to the specified mesh instance.

◆ reserve_meshes()

void reserve_meshes ( Index  num_meshes)

Pre-allocate a number of meshes in the scene.

Parameters
[in]num_meshesNumber of meshes to reserve in the scene.

◆ add_mesh()

Index add_mesh ( MeshType  mesh)

Adds a mesh to the scene, possibly with existing instances.

Parameters
[in]meshMesh to be added to the scene. The object will be moved into the scene.
Returns
Index of the newly added mesh in the scene.

◆ reserve_instances()

void reserve_instances ( Index  mesh_index,
Index  num_instances 
)

Pre-allocate a number of instances for a given mesh.

Parameters
[in]mesh_indexMesh index.
[in]num_instancesNumber of instances to reserve for this mesh.

◆ add_instance()

Index add_instance ( InstanceType  instance)

Adds a new instance of an existing mesh.

Parameters
[in]instanceMesh instance to add to the scene.
Returns
Index of the newly added instance, respective to the specified mesh.

◆ foreach_instances_for_mesh()

void foreach_instances_for_mesh ( Index  mesh_index,
function_ref< void(const InstanceType &)>  func 
) const

Iterates over all instances of a specific mesh.

Parameters
[in]mesh_indexMesh index on which to iterate over.
[in]funcCallback function to call for each mesh instance.

◆ foreach_instances()

void foreach_instances ( function_ref< void(const InstanceType &)>  func) const

Iterates over all instances of the scene.

Parameters
[in]funcCallback function to call for each mesh instance.

The documentation for this class was generated from the following files: