Visual Computing Library
Loading...
Searching...
No Matches
vcl::Mesh< Args > Class Template Reference

The Mesh class represents a generic 3D mesh. A mesh is composed of a generic number of containers of Elements (which can be vertices, faces, edges...), plus some other components. More...

#include <vclib/mesh/mesh.h>

Inheritance diagram for vcl::Mesh< Args >:

Classes

struct  ContainerOf
 The ContainerOf struct allows to get the Container of an Element on this Mesh. More...
 
struct  ContainerOfElement
 

Public Types

using Containers = FilterTypesByCondition< mesh::IsElementContainerPred, TypeWrapper< Args... > >::type
 Containers is a vcl::TypeWrapper that wraps all the types from which the Mesh inherits (Args) that are ElementContainers (they satisfy the ElementContainerConcept).
 
using Components = FilterTypesByCondition< comp::IsComponentPred, TypeWrapper< Args... > >::type
 Components is an alias to a vcl::TypeWrapper that wraps all the types from which the Mesh inherits (Args) that are Components (they satisfy the ComponentConcept).
 
template<uint ELEM_ID>
using ContainerType = ContainerOfElement< ELEM_ID >::type
 ContainerType is an alias that exposes the type of the Container that stores the Element identified by the template parameter ELEM_ID.
 
template<uint ELEM_ID>
using ElementType = ContainerType< ELEM_ID >::ElementType
 ElementType is an alias that exposes the type of the Element identified by the template parameter ELEM_ID.
 

Public Member Functions

 Mesh ()
 Empty constructor, constructs an empty mesh.
 
 Mesh (const Mesh &oth)
 Copy constructor of the Mesh. Will create a deep copy of the given input mesh, taking care of copying everithing and then update all the pointers.
 
 Mesh (Mesh &&oth)
 Move constructor, moves the given mesh into this one, without any other resource acquisition.
 
bool isCompact () const
 Returns true if this mesh is compact, meaning that all its containers have no deleted elements (size == element number).
 
void clear ()
 Clears all the Elements contained in the mesh.
 
void compact ()
 Compacts all the containers of the mesh.
 
void enableAllOptionalComponents ()
 Enables all the optional components of the elements of the containers if the mesh.
 
void disableAllOptionalComponents ()
 Disables all the optional components of the elements of the containers if the mesh.
 
template<typename OtherMeshType >
void enableSameOptionalComponentsOf (const OtherMeshType &m)
 Enables all the OptionalComponents of this mesh according to the Components available on the OtherMeshType m.
 
void append (const Mesh &m)
 Appends all the elements contained in the mesh m to this mesh.
 
template<typename OtherMeshType >
void importFrom (const OtherMeshType &m)
 Imports all the components that can be imported from another type of mesh.
 
void swap (Mesh &m2)
 Swaps this mesh with the other input Mesh m2.
 
Meshoperator= (Mesh oth)
 Assignment operator of the Mesh.
 
template<ElementConcept El>
requires (hasContainerOf<El>())
uint index (const El &e) const
 Returns the index of the given element in its Container of the Mesh.
 
template<ElementConcept El>
requires (hasContainerOf<El>())
uint index (const El *e) const
 Returns the index of the given element in its Container of the Mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
const autoelement (uint i) const
 Returns the element of the given type at the given index inside its container of this mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
autoelement (uint i)
 Returns the element of the given type at the given index inside its container of this mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint number () const
 Returns the number of elements of the given type in this mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint containerSize () const
 Returns the size of the container of elements of the given type in this mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint deletedNumber () const
 Returns the number of deleted elements of the given type in this mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint add ()
 Adds a new element of the given type into its container, returning the index of the added element in its container.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint add (uint n)
 Adds n new elements of the given type into its container, returning the index of the first added element in its container.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void clearElements ()
 Clears the container of ELEM_ID elements the Mesh, deleting all the Elements.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void resize (uint n)
 Resizes the Element container to contain n Elements of type ELEM_ID.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void reserve (uint n)
 Reserves a number of elements of the given type in its container. The function does not add any element to the container, but it just reserves a number of elements that can be added without causing a reallocation of the container.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void compactElements ()
 Compacts the Container of the given element, removing all the elements marked as deleted. Element indices will change accordingly. The function will automatically take care of updating all the Element pointers contained in the Mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void deleteElement (uint i)
 Marks as deleted the element at the given index from its container, deduced from the template index ELEM_ID.
 
template<ElementConcept El>
requires (hasContainerOf<El>())
void deleteElement (const El *e) const
 Marks as deleted the given element from its container.
 
template<ElementConcept El>
requires (hasContainerOf<El>())
void deleteElement (const El &e) const
 Marks as deleted the given element from its container.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
std::vector< uintcompactIndices () const
 Returns a vector that tells, for each element of the container of ELEM_ID in the mesh, the new index of the element after the container has been compacted. For each deleted element, its position will be set to UINT_NULL.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void updateIndices (const std::vector< uint > &newIndices)
 Updates all the indices and pointers of the elements of the container of ELEM_ID in the mesh, according to the mapping stored in the newIndices vector, that tells for each old element index, the new index of the element in the same container (or UINT_NULL if the element must be left as unreferenced - useful when a vertex is deleted).
 
void serialize (std::ostream &os) const
 
void deserialize (std::istream &is)
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto begin (bool jumpDeleted=true)
 Returns an iterator to the begining of the container of the elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto end ()
 Returns an iterator to the end of the container of the elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto begin (bool jumpDeleted=true) const
 Returns a const iterator to the begining of the container of the elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto end () const
 Returns a const iterator to the end of the container of the elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto elements (bool jumpDeleted=true)
 
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto elements (bool jumpDeleted=true) const
 
template<uint ELEM_ID, uint COMP_ID>
requires (hasPerElementOptionalComponent<ELEM_ID, COMP_ID>())
bool isPerElementComponentEnabled () const
 Returns true if optional Component having ID COMP_ID is enabled for elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID, uint COMP_ID>
requires (hasPerElementOptionalComponent<ELEM_ID, COMP_ID>())
void enablePerElementComponent ()
 Enables the optional Component having ID COMP_ID for elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID, uint COMP_ID>
requires (hasPerElementOptionalComponent<ELEM_ID, COMP_ID>())
void disablePerElementComponent ()
 Disables the optional Component having ID COMP_ID for elements having ID ELEM_ID in the mesh.
 
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
bool hasPerElementCustomComponent (const std::string &name) const
 Returns true if the Element having ID ELEM_ID has a custom component with the given name.
 
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
std::vector< std::string > perElementCustomComponentNames () const
 Returns a vector containing all the names of the custom components of any type associated to the Element having ID ELEM_ID.
 
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
bool isPerElementCustomComponentOfType (const std::string &name) const
 Returns true if the Element having ID ELEM_ID has a custom component of type K with the given name.
 
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
std::type_index perElementCustomComponentType (const std::string &name) const
 Returns the std::type_index of the custom component having the given name associated to the Element having ID ELEM_ID.
 
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
std::vector< std::string > perElementCustomComponentNamesOfType () const
 Returns a vector containing all the names of the custom components of type K associated to the Element having ID ELEM_ID.
 
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
void addPerElementCustomComponent (const std::string &name)
 Adds a custom component of type K having the given name to the Element having ID ELEM_ID.
 
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
void deletePerElementCustomComponent (const std::string &name)
 Deletes the custom component of the given name from the Element having ID ELEM_ID.
 
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
CustomComponentVectorHandle< K > perElementCustomComponentVectorHandle (const std::string &name)
 Returns a vector handle to the custom component of type K having the given name associated to the Element having ID ELEM_ID.
 
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
ConstCustomComponentVectorHandle< K > perElementCustomComponentVectorHandle (const std::string &name) const
 Returns a const vector handle to the custom component of type K having the given name associated to the Element having ID ELEM_ID.
 

Static Public Member Functions

template<ElementConcept El>
static constexpr bool hasContainerOf ()
 Returns true if this Mesh has a container of elements having the same Element ID of the template Element El.
 
template<uint ELEM_ID>
static constexpr bool hasContainerOf ()
 Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID.
 
template<uint ELEM_ID, uint COMP_ID>
static constexpr bool hasPerElementComponent ()
 Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID and the Element of that container has a Component having the same Component ID of the template COMP_ID.
 
template<uint ELEM_ID, uint COMP_ID>
static constexpr bool hasPerElementOptionalComponent ()
 Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID and the Element of that container has an Optional Component having the same Component ID of the template COMP_ID.
 

Protected Member Functions

template<typename Cont >
bool isContainerCompact () const
 
template<typename Cont >
void compactContainer ()
 
template<typename Cont >
void enableAllOptionalComponentsInContainer ()
 
template<typename Cont >
void disableAllOptionalComponentsInContainer ()
 
template<typename Cont >
void clearContainer ()
 
template<ElementConcept Element>
void updateAllReferences (const Element *oldBase)
 
template<typename Element , typename... A>
void updateReferences (const Element *oldBase, TypeWrapper< A... >)
 
template<typename Cont , typename Element >
void updateReferences (const Element *oldBase)
 
template<typename Element , std::size_t N, typename... A>
void updateReferences (const Element *oldBase, TypeWrapper< A... >, const std::array< std::size_t, N > &sizes=std::array< std::size_t, 0 >(), uint offset=0)
 
template<typename Cont , typename Element , std::size_t N>
void updateReferences (const Element *oldBase, const std::array< std::size_t, N > &sizes=std::array< std::size_t, 0 >(), uint offset=0)
 
template<ElementConcept Element>
void updateAllReferences (const std::vector< uint > &newIndices)
 
template<typename Cont , typename Element >
void updateReferences (const std::vector< uint > &newIndices)
 

Private Member Functions

void init ()
 
bool isAvailable () const
 
template<typename Cont , typename OtherMeshType >
void enableSameOptionalComponentsOf (const OtherMeshType &m)
 
void updateAllParentMeshPointers ()
 
template<typename Cont >
void setParentMeshPointers ()
 
template<typename Cont >
void appendContainer (const Mesh &m)
 
template<typename Cont >
void preSerialization (std::ostream &os) const
 
template<typename Cont >
void postSerialization (std::ostream &os) const
 
template<typename Cont >
void preDeserialization (std::istream &is)
 
template<typename Cont >
void postDeserialization (std::istream &is)
 
template<uint ELEM_ID, typename T >
uint elementIndex (const T *el) const
 
template<typename El >
autocustomComponents ()
 
template<typename El >
const autocustomComponents () const
 
template<typename El >
autoverticalComponents ()
 
template<typename El >
const autoverticalComponents () const
 

Static Private Member Functions

template<uint I, typename Cont , typename Array , typename... A>
static void setContainerBase (const Mesh< A... > &m, Array &bases)
 
template<typename... A>
static auto getContainerBases (const Mesh< A... > &m)
 
template<uint I, typename Cont , typename Array , typename... A>
static void setContainerSize (const Mesh< A... > &m, Array &sizes)
 
template<typename... A>
static auto getContainerSizes (const Mesh< A... > &m)
 
template<typename Cont , typename Array , typename... A>
static void updateReferencesOfContainerType (Mesh< A... > &m, const Array &bases)
 
template<typename Cont , typename ArrayB , typename ArrayS , typename... A>
static void updateReferencesOfContainerTypeAfterAppend (Mesh< A... > &m, const ArrayB &bases, const ArrayS &sizes)
 

Friends

template<ElementConcept T>
class mesh::ElementContainer
 
template<uint ELEM_ID, typename MeshType , typename... Comps>
class Element
 
void swap (Mesh &a, Mesh &b)
 Specializes the swap function to allow the swapping of two Mesh objects.
 

Detailed Description

template<typename... Args>
class vcl::Mesh< Args >

The Mesh class represents a generic 3D mesh. A mesh is composed of a generic number of containers of Elements (which can be vertices, faces, edges...), plus some other components.

The Mesh class will expose all the public members of its containers and is components, and its role is to implement all the functionalities that allow these containers to comunicate (e.g. an operation on the vertex container that requires to update also some face information).

Therefore, in this page are documented only the functions that in some way need to modify the status of more than one Container of the Mesh. Other functions are inherited by the Container classes of the Elements of the Mesh, or from its Components, and depend on all the templates that compose a specific Mesh definition.

Member Typedef Documentation

◆ ContainerType

template<typename... Args>
template<uint ELEM_ID>
using vcl::Mesh< Args >::ContainerType = ContainerOfElement<ELEM_ID>::type

ContainerType is an alias that exposes the type of the Container that stores the Element identified by the template parameter ELEM_ID.

To be used, the Mesh must have an ElementContainer having ID ELEM_ID.

Usage:

using VertexContainer = MeshType::template ContainerType<ElemId::VERTEX>;
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43

◆ ElementType

template<typename... Args>
template<uint ELEM_ID>
using vcl::Mesh< Args >::ElementType = ContainerType<ELEM_ID>::ElementType

ElementType is an alias that exposes the type of the Element identified by the template parameter ELEM_ID.

To be used, the Mesh must have an ElementContainer having ID ELEM_ID.

Usage:

using VertexType = MeshType::template ElementType<ElemId::VERTEX>;

Constructor & Destructor Documentation

◆ Mesh() [1/2]

template<typename... Args>
vcl::Mesh< Args >::Mesh ( const Mesh< Args > &  oth)
inline

Copy constructor of the Mesh. Will create a deep copy of the given input mesh, taking care of copying everithing and then update all the pointers.

Parameters
oththe mesh from which constructo this Mesh.

◆ Mesh() [2/2]

template<typename... Args>
vcl::Mesh< Args >::Mesh ( Mesh< Args > &&  oth)
inline

Move constructor, moves the given mesh into this one, without any other resource acquisition.

Parameters
oththe mesh that will be moved into this Mesh.

Member Function Documentation

◆ add() [1/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint vcl::Mesh< Args >::add ( )
inline

Adds a new element of the given type into its container, returning the index of the added element in its container.

If the call of this function will cause a reallocation of the container, the function will automatically take care of updating all the pointers to the elements stored in all the containers of the Mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
the index of the added element in its container.

◆ add() [2/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint vcl::Mesh< Args >::add ( uint  n)
inline

Adds n new elements of the given type into its container, returning the index of the first added element in its container.

If the call of this function will cause a reallocation of the container, the function will automatically take care of updating all the pointers to the elements stored in all the containers of the Mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]nthe number of elements to add.
Returns
the index of the first added element in its container.

◆ addPerElementCustomComponent()

template<typename... Args>
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
void vcl::Mesh< Args >::addPerElementCustomComponent ( const std::string &  name)
inline

Adds a custom component of type K having the given name to the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Kthe type of the custom component.
Parameters
[in]namethe name of the custom component.

◆ append()

template<typename... Args>
void vcl::Mesh< Args >::append ( const Mesh< Args > &  m)
inline

Appends all the elements contained in the mesh m to this mesh.

Note
This function does not enable the optional components that are disabled in this mesh, but are available in m. Enabling the components that are available in m, but not in this mesh, is up to the user.
Warning
This function is applied only to the containers of the meshes. It does not import all the other components of the mesh m (e.g BoundingBox, TransformMatrix, ...).
Parameters
m

◆ begin() [1/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto vcl::Mesh< Args >::begin ( bool  jumpDeleted = true)
inline

Returns an iterator to the begining of the container of the elements having ID ELEM_ID in the mesh.

The iterator is automatically initialized to jump deleted elements in the container. You can change this option by calling this member function with the jumpDeleted parameter set to false.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]jumpDeletedif true, the iterator will be initialized to jump deleted elements in the container.
Returns
an iterator to the begining of the container of the elements of type ELEM_ID in the mesh.

◆ begin() [2/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto vcl::Mesh< Args >::begin ( bool  jumpDeleted = true) const
inline

Returns a const iterator to the begining of the container of the elements having ID ELEM_ID in the mesh.

The iterator is automatically initialized to jump deleted elements in the container. You can change this option by calling this member function with the jumpDeleted parameter set to false.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]jumpDeletedif true, the iterator will be initialized to jump deleted elements in the container.
Returns
a const iterator to the begining of the container of the elements of type ELEM_ID in the mesh.

◆ clear()

template<typename... Args>
void vcl::Mesh< Args >::clear ( )
inline

Clears all the Elements contained in the mesh.

Todo:
manage also other components

◆ clearContainer()

template<typename... Args>
template<typename Cont >
void vcl::Mesh< Args >::clearContainer ( )
inlineprotected

This function will clear the Cont container of this mesh (if Cont is actually a container).

This function is made to be called trough pack expansion:

◆ clearElements()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void vcl::Mesh< Args >::clearElements ( )
inline

Clears the container of ELEM_ID elements the Mesh, deleting all the Elements.

The contained elements are actually removed from the container, not only marked as deleted. Therefore, the container will have size 0 (mesh.containerSize<ELEM_ID>() == 0) after the call of this function.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Note
This function does not cause a reallocation of the container.
Warning
Any pointer to ELEM_ID elements in the Mesh will be left unchanged, and therefore will point to invalid elements. This means that, if you have a pointer to a ELEM_ID element and you call this function, you will have a dangling pointer.
Template Parameters
ELEM_IDthe ID of the element.

◆ compact()

template<typename... Args>
void vcl::Mesh< Args >::compact ( )
inline

Compacts all the containers of the mesh.

Removes all the deleted elements from each container, compacting the the containers and then updating automatically all the pointers/indices.

◆ compactContainer()

template<typename... Args>
template<typename Cont >
void vcl::Mesh< Args >::compactContainer ( )
inlineprotected

This function will compact the Cont container of this mesh (if Cont is actually a container).

This function is made to be called trough pack expansion:

◆ compactIndices()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
std::vector< uint > vcl::Mesh< Args >::compactIndices ( ) const
inline

Returns a vector that tells, for each element of the container of ELEM_ID in the mesh, the new index of the element after the container has been compacted. For each deleted element, its position will be set to UINT_NULL.

This function is useful when you need to know the indices of the elements that they would have in a compact container, without considering the deleted ones.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
a vector containing, for each element index, the new index if the container would be compacted.

◆ containerSize()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint vcl::Mesh< Args >::containerSize ( ) const
inline

Returns the size of the container of elements of the given type in this mesh.

The size of a container may be different from the number of elements, if the container has some deleted elements.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
the size of the container of elements of the given type in this mesh.

◆ deletedNumber()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint vcl::Mesh< Args >::deletedNumber ( ) const
inline

Returns the number of deleted elements of the given type in this mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
the number of deleted elements of the given type in this mesh.

◆ deleteElement() [1/3]

template<typename... Args>
template<ElementConcept El>
requires (hasContainerOf<El>())
void vcl::Mesh< Args >::deleteElement ( const El e) const
inline

Marks as deleted the given element from its container.

The function does not remove the element from the container, and therefore it does not cause reallocation or compacting of the container. The element will be removed from the container only when the container will be compacted.

The complexity of this function is O(1).

The function requires that the Mesh has a Container of Elements of type of the argument. Otherwise, a compiler error will be triggered.

Template Parameters
Elthe type of the element to delete. It must satisfy the ElementConcept.
Parameters
[in]ethe element to delete.

◆ deleteElement() [2/3]

template<typename... Args>
template<ElementConcept El>
requires (hasContainerOf<El>())
void vcl::Mesh< Args >::deleteElement ( const El e) const
inline

Marks as deleted the given element from its container.

The function does not remove the element from the container, and therefore it does not cause reallocation or compacting of the container. The element will be removed from the container only when the container will be compacted.

The complexity of this function is O(1).

The function requires that the Mesh has a Container of Elements of type of the argument. Otherwise, a compiler error will be triggered.

Template Parameters
Elthe type of the element to delete. It must satisfy the ElementConcept.
Parameters
[in]ea pointer to the element to delete.

◆ deleteElement() [3/3]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void vcl::Mesh< Args >::deleteElement ( uint  i)
inline

Marks as deleted the element at the given index from its container, deduced from the template index ELEM_ID.

The function does not remove the element from the container, and therefore it does not cause reallocation or compacting of the container. The element will be removed from the container only when the container will be compacted.

The complexity of this function is O(1).

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]ithe index of the element to delete.

◆ deletePerElementCustomComponent()

template<typename... Args>
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
void vcl::Mesh< Args >::deletePerElementCustomComponent ( const std::string &  name)
inline

Deletes the custom component of the given name from the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]namethe name of the custom component.

◆ disableAllOptionalComponentsInContainer()

template<typename... Args>
template<typename Cont >
void vcl::Mesh< Args >::disableAllOptionalComponentsInContainer ( )
inlineprotected

This function will disable all the optional components of the element of the Cont container of this mesh (if Cont is actually a container).

This function is made to be called trough pack expansion:

◆ disablePerElementComponent()

template<typename... Args>
template<uint ELEM_ID, uint COMP_ID>
requires (hasPerElementOptionalComponent<ELEM_ID, COMP_ID>())
void vcl::Mesh< Args >::disablePerElementComponent ( )
inline

Disables the optional Component having ID COMP_ID for elements having ID ELEM_ID in the mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has a optional component having ID COMP_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
COMP_IDthe ID of the component.

◆ element() [1/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto & vcl::Mesh< Args >::element ( uint  i)
inline

Returns the element of the given type at the given index inside its container of this mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

The function does not perform any check on the index. If the index is out of range, the behaviour is undefined.

Template Parameters
ELEM_IDthe ID of the element to return.
Returns
the element of the given type ID at the given index inside its container of this mesh.

◆ element() [2/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
const auto & vcl::Mesh< Args >::element ( uint  i) const
inline

Returns the element of the given type at the given index inside its container of this mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

The function does not perform any check on the index. If the index is out of range, the behaviour is undefined.

Template Parameters
ELEM_IDthe ID of the element to return.
Returns
the element of the given type ID at the given index inside its container of this mesh.

◆ elements() [1/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto vcl::Mesh< Args >::elements ( bool  jumpDeleted = true)
inline

Returns a lightweight view object that stores the begin and end iterators of the container of the elements having ID ELEM_ID in the mesh. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops:

for (auto& el : mesh.elements<ElemId::VERTEX>()) {
// Do something with el
}
auto elements(bool jumpDeleted=true)
Definition mesh.h:1098
The ElemId struct enumerates the elements that can compose a mesh.
Definition mesh_elements.h:54

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]jumpDeletedif true, the view will be initialized to jump deleted elements in the container.
Returns
a lightweight view object that can be used in range-based for loops to iterate over elements.

◆ elements() [2/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto vcl::Mesh< Args >::elements ( bool  jumpDeleted = true) const
inline

Returns a lightweight const view object that stores the begin and end const iterators of the container of the elements having ID ELEM_ID in the mesh. The view object exposes the iterators trough the begin() and end() member functions, and therefore the returned object can be used in range-based for loops:

for (const auto& el : mesh.elements<ElemId::VERTEX>()) {
// Do something read-only with el
}

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]jumpDeletedif true, the view will be initialized to jump deleted elements in the container.
Returns
a lightweight view object that can be used in range-based for loops to iterate over elements.

◆ enableAllOptionalComponentsInContainer()

template<typename... Args>
template<typename Cont >
void vcl::Mesh< Args >::enableAllOptionalComponentsInContainer ( )
inlineprotected

This function will enable all the optional components of the element of the Cont container of this mesh (if Cont is actually a container).

This function is made to be called trough pack expansion:

◆ enablePerElementComponent()

template<typename... Args>
template<uint ELEM_ID, uint COMP_ID>
requires (hasPerElementOptionalComponent<ELEM_ID, COMP_ID>())
void vcl::Mesh< Args >::enablePerElementComponent ( )
inline

Enables the optional Component having ID COMP_ID for elements having ID ELEM_ID in the mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has a optional component having ID COMP_TYPE. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
COMP_IDthe ID of the component.

◆ enableSameOptionalComponentsOf()

template<typename... Args>
template<typename OtherMeshType >
void vcl::Mesh< Args >::enableSameOptionalComponentsOf ( const OtherMeshType m)
inline

Enables all the OptionalComponents of this mesh according to the Components available on the OtherMeshType m.

This function is useful to call before importing data from another MeshType, to be sure that all the available data contained in the MeshType mesh will be imported.

This function:

  • disables all the optional components that are not available in m
  • enables all the optional components that are available in m (which can be both optional or not)

Example of usage:

MeshType m1;
// do stuff on m2
m1.enableSameOptionalComponentsOf(m2); // m1 enables all the available
// components of m2
m1.importFrom(m2); // m1 will import all the data contained
// in m2 that can be stored in m1
Parameters
m

◆ end() [1/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto vcl::Mesh< Args >::end ( )
inline

Returns an iterator to the end of the container of the elements having ID ELEM_ID in the mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
an iterator to the end of the container of the elements of type ELEM_ID in the mesh.

◆ end() [2/2]

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
auto vcl::Mesh< Args >::end ( ) const
inline

Returns a const iterator to the end of the container of the elements having ID ELEM_ID in the mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
a const iterator to the end of the container of the elements of type ELEM_ID in the mesh.

◆ hasContainerOf() [1/2]

template<typename... Args>
template<ElementConcept El>
static constexpr bool vcl::Mesh< Args >::hasContainerOf ( )
inlinestaticconstexpr

Returns true if this Mesh has a container of elements having the same Element ID of the template Element El.

This means that this the only value checked is the ELEMENT_ID unsigned int exposed by the Element, meaning that it does not check if the Elements of this mesh are exactly the same of El.

In other words, it returns true also if we pass an Element of another mesh that is of the same ELEMENT_ID (both Vertices, Faces, ecc).

Example of usage (Note: EdgeMesh has Vertices, but not Faces):

"EdgeMesh does not have Vertices");
"EdgeMesh has Faces");
Segment()
Default constructor. Creates a segment with endpoints at the origin.
Definition segment.h:68
Template Parameters
Elthe Element type to check.
Returns
true if this Mesh has a container of elements having the same Element ID of the template Element El.

◆ hasContainerOf() [2/2]

template<typename... Args>
template<uint ELEM_ID>
static constexpr bool vcl::Mesh< Args >::hasContainerOf ( )
inlinestaticconstexpr

Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID.

Example of usage (Note: EdgeMesh has Vertices, but not Faces):

"EdgeMesh does not have Vertices");
"EdgeMesh has Faces");
Template Parameters
ELEM_IDthe Element ID to check.
Returns
true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID.

◆ hasPerElementComponent()

template<typename... Args>
template<uint ELEM_ID, uint COMP_ID>
static constexpr bool vcl::Mesh< Args >::hasPerElementComponent ( )
inlinestaticconstexpr

Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID and the Element of that container has a Component having the same Component ID of the template COMP_ID.

Example of usage (Note: TriMesh has per Vertex TexCoords, but not adj edges):

static_assert(vcl::TriMesh::hasPerElementComponent<
vcl::ElemId::VERTEX, vcl::TEX_COORDS>(),
"TriMesh does not have per Vertex TexCoords");
static_assert(!vcl::TriMesh::hasPerElementComponent<
vcl::ElemId::VERTEX, vcl::ADJ_EDGES>(),
"TriMesh has per Vertex Adjacent Edges");

◆ hasPerElementCustomComponent()

template<typename... Args>
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
bool vcl::Mesh< Args >::hasPerElementCustomComponent ( const std::string &  name) const
inline

Returns true if the Element having ID ELEM_ID has a custom component with the given name.

This function does not take into account the type ot the custom component.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]namethe name of the custom component.
Returns
true if the Element having ID ELEM_ID has a custom component having the given name.

◆ hasPerElementOptionalComponent()

template<typename... Args>
template<uint ELEM_ID, uint COMP_ID>
static constexpr bool vcl::Mesh< Args >::hasPerElementOptionalComponent ( )
inlinestaticconstexpr

Returns true if this Mesh has a container of elements having the same Element ID of the template ELEM_ID and the Element of that container has an Optional Component having the same Component ID of the template COMP_ID.

Example of usage (Note: TriMesh has per Vertex optional TexCoords, and non-optional Normals):

static_assert(vcl::TriMesh::hasPerElementOptionalComponent<
vcl::ElemId::VERTEX, vcl::TEX_COORDS>(),
"TriMesh does not have per Vertex Optional TexCoords");
static_assert(!vcl::TriMesh::hasPerElementOptionalComponent<
vcl::ElemId::VERTEX, vcl::NORMALS>(),
"TriMesh has per Vertex Optional Normals");

◆ importFrom()

template<typename... Args>
template<typename OtherMeshType >
void vcl::Mesh< Args >::importFrom ( const OtherMeshType m)
inline

Imports all the components that can be imported from another type of mesh.

This function can be called from any Mesh type having all the Elements and Components that implement the member function importFrom.

Note that this function does not enable optional components that are disabled. If you want to import all the possible data including also disabled components of this mesh, you should call the function m1.enableSameOptionalComponentsOf(m2) before this function.

Parameters
[in]mthe mesh from which import all the data.

◆ index() [1/2]

template<typename... Args>
template<ElementConcept El>
requires (hasContainerOf<El>())
uint vcl::Mesh< Args >::index ( const El e) const
inline

Returns the index of the given element in its Container of the Mesh.

The function requires that the Mesh has a Container of Elements of type El. Otherwise, a compiler error will be triggered.

Template Parameters
ElThe type of the Element, it must satisfy the ElementConcept.
Parameters
ea reference of an element of the Mesh.
Returns
the index of the given element.

◆ index() [2/2]

template<typename... Args>
template<ElementConcept El>
requires (hasContainerOf<El>())
uint vcl::Mesh< Args >::index ( const El e) const
inline

Returns the index of the given element in its Container of the Mesh.

The function requires that the Mesh has a Container of Elements of type El. Otherwise, a compiler error will be triggered.

Template Parameters
ElThe type of the Element, it must satisfy the ElementConcept.
Parameters
ea pointer to an element of the Mesh.
Returns
the index of the given element.

◆ isCompact()

template<typename... Args>
bool vcl::Mesh< Args >::isCompact ( ) const
inline

Returns true if this mesh is compact, meaning that all its containers have no deleted elements (size == element number).

Returns
true if this mesh is compact, false otherwise.

◆ isPerElementComponentEnabled()

template<typename... Args>
template<uint ELEM_ID, uint COMP_ID>
requires (hasPerElementOptionalComponent<ELEM_ID, COMP_ID>())
bool vcl::Mesh< Args >::isPerElementComponentEnabled ( ) const
inline

Returns true if optional Component having ID COMP_ID is enabled for elements having ID ELEM_ID in the mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has a optional component having ID COMP_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
COMP_IDthe ID of the component.
Returns
true if optional Component COMP_ID is enabled for elements of type ELEM_ID in the mesh.

◆ isPerElementCustomComponentOfType()

template<typename... Args>
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
bool vcl::Mesh< Args >::isPerElementCustomComponentOfType ( const std::string &  name) const
inline

Returns true if the Element having ID ELEM_ID has a custom component of type K with the given name.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Kthe type of the custom component.
Parameters
[in]namethe name of the custom component.
Returns
true if the Element having ID ELEM_ID has a custom component of type K having the given name.

◆ number()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
uint vcl::Mesh< Args >::number ( ) const
inline

Returns the number of elements of the given type in this mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
the number of elements of the given type in this mesh.

◆ operator=()

template<typename... Args>
Mesh & vcl::Mesh< Args >::operator= ( Mesh< Args >  oth)
inline

Assignment operator of the Mesh.

Parameters
oththe Mesh from which will create a copy and assign to this Mesh
Returns
a reference to this Mesh after the assignemnt.

◆ perElementCustomComponentNames()

template<typename... Args>
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
std::vector< std::string > vcl::Mesh< Args >::perElementCustomComponentNames ( ) const
inline

Returns a vector containing all the names of the custom components of any type associated to the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Returns
A vector of strings representing all the names of the custom components for the Element having ID ELEM_ID.

◆ perElementCustomComponentNamesOfType()

template<typename... Args>
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
std::vector< std::string > vcl::Mesh< Args >::perElementCustomComponentNamesOfType ( ) const
inline

Returns a vector containing all the names of the custom components of type K associated to the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Kthe type of the custom component.
Returns
A vector of strings representing all the names of the custom components of type K for the Element having ID ELEM_ID.

◆ perElementCustomComponentType()

template<typename... Args>
template<uint ELEM_ID>
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
std::type_index vcl::Mesh< Args >::perElementCustomComponentType ( const std::string &  name) const
inline

Returns the std::type_index of the custom component having the given name associated to the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]namethe name of the custom component.
Returns
The std::type_index of the custom component having the given name associated to the Element having ID ELEM_ID.

◆ perElementCustomComponentVectorHandle() [1/2]

template<typename... Args>
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
CustomComponentVectorHandle< K > vcl::Mesh< Args >::perElementCustomComponentVectorHandle ( const std::string &  name)
inline

Returns a vector handle to the custom component of type K having the given name associated to the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

The handle can be used like a normal std::vector, but does not have access to the modifiers member functions (resize, push_back...). The handle contains references to the custom component, therefore you can modify the custom component by modifying the element of the handle vector normally. Since the handle stores references, there are no copies performed when calling this function.

For example, assuming that the mesh has a vertex custom component named "cc" of type int:

auto handle = m.perElementCustomComponentVectorHandle<
ElemId::VERTEX, int>("cc");
for (Vertex& v : m.vertices() {
handle[m.index(v)] = 5; // v.customComponent<int>("cc") == 5
assert(v.customComponent<int>("cc") == 5);
}
The Vertex class represents an Vertex element of the vcl::Mesh class.
Definition vertex.h:47

Using handles allows to access more efficiently to custom components rather accessing from an element object. However, note that references are binded to the container of the mesh.

Note
Since the handle contains references, any operation that changes the size of the container could be destructive and invalidate the references contained in the handle.
Template Parameters
ELEM_IDthe ID of the element.
Kthe type of the custom component.
Parameters
[in]namethe name of the custom component.
Returns
A handle to the custom component of type K having the given name associated to the Element having ID ELEM_ID.

◆ perElementCustomComponentVectorHandle() [2/2]

template<typename... Args>
template<uint ELEM_ID, typename K >
requires (hasPerElementComponent<ELEM_ID, CompId::CUSTOM_COMPONENTS>())
ConstCustomComponentVectorHandle< K > vcl::Mesh< Args >::perElementCustomComponentVectorHandle ( const std::string &  name) const
inline

Returns a const vector handle to the custom component of type K having the given name associated to the Element having ID ELEM_ID.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID, and that the Element has CustomComponents. Otherwise, a compiler error will be triggered.

The handle can be used like a normal std::vector, but does not have access to the modifiers member functions (resize, push_back...). The handle contains const references to the custom component, therefore you can access to the custom component by accessing the element of the handle vector normally. Since the handle stores references, there are no copies performed when calling this function.

For example, assuming that the mesh has a vertex custom component named "cc" of type int:

auto handle = m.perElementCustomComponentVectorHandle<
ElemId::VERTEX, int>("cc");
for (const Vertex& v : m.vertices() {
sum += handle[m.index(v)];
// handle[m.index(v)] = 5; // not allowed, const handle
}

Using handles allows to access more efficiently to custom components rather accessing from an element object. However, note that references are binded to the container of the mesh.

Note
Since the handle contains references, any operation that changes the size of the container could be destructive and invalidate the references contained in the handle.
Template Parameters
ELEM_IDthe ID of the element.
Kthe type of the custom component.
Parameters
[in]namethe name of the custom component.
Returns
A const handle to the custom component of type K having the given name associated to the Element having ID ELEM_ID.

◆ reserve()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void vcl::Mesh< Args >::reserve ( uint  n)
inline

Reserves a number of elements of the given type in its container. The function does not add any element to the container, but it just reserves a number of elements that can be added without causing a reallocation of the container.

This is useful when you know (or you have an idea) of how much elements are going to add in a mesh, and you want to avoid multiple (expansive) reallocations of the container during the addition of the elements.

If the call of this function will cause a reallocation of the container, the function will automatically take care of updating all the pointers to the elements stored in all the containers of the Mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Template Parameters
ELEM_IDthe type ID of the element.
Parameters
[in]nthe new capacity of the container in the mesh.

◆ resize()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void vcl::Mesh< Args >::resize ( uint  n)
inline

Resizes the Element container to contain n Elements of type ELEM_ID.

If the new size is greater than the old one, new Elements are added to the container, and a reallocation may happen. If the new size is smaller than the old one, the container will keep its first non-deleted n Elements, and the remaining Elements are marked as deleted.

If the call of this function will cause a reallocation of the container, the function will automatically take care of updating all the pointers to the elements stored in all the containers of the Mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Warning
The given size n is relative to the number of non-deleted Elements, not to the size of the Element container. For example, if you have a mesh with 10 Faces and faceContainerSize() == 20, calling resize<ElemId::FACE>(5) will not cause a reallocation of the container, but will mark as deleted the least 5 non-deleted Faces of the container. In the same scenario, calling resize<ElemId::FACE>(15) will result in a Face container having 15 new Faces and faceContainerSize() == 25. The latest 5 Faces will be the newly added.
Any pointer to deleted Elements in the Mesh will be left unchanged, and therefore will point to invalid Elements. This means that if you call this member function with a lower number of Elements, you'll need to manually manage the pointers/indices to the deleted Elements.
Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]nthe new size of the container in the mesh.

◆ setContainerBase()

template<typename... Args>
template<uint I, typename Cont , typename Array , typename... A>
static void vcl::Mesh< Args >::setContainerBase ( const Mesh< A... > &  m,
Array bases 
)
inlinestaticprivate

This function sets the Ith position of the array bases, where I is an index of a container in a TypeWrapper of containers

In the Ith position will be placed the base pointer of the vector of the elements contained in the container Cont.

◆ setContainerSize()

template<typename... Args>
template<uint I, typename Cont , typename Array , typename... A>
static void vcl::Mesh< Args >::setContainerSize ( const Mesh< A... > &  m,
Array sizes 
)
inlinestaticprivate

This function sets the Ith position of the array sizes, where I is an index of a container in a TypeWrapper of containers

In the Ith position will be placed the size of the vector of the elements contained in the container Cont.

◆ swap()

template<typename... Args>
void vcl::Mesh< Args >::swap ( Mesh< Args > &  m2)
inline

Swaps this mesh with the other input Mesh m2.

Parameters
[in]m2the Mesh to swap with this Mesh.

◆ updateIndices()

template<typename... Args>
template<uint ELEM_ID>
requires (hasContainerOf<ELEM_ID>())
void vcl::Mesh< Args >::updateIndices ( const std::vector< uint > &  newIndices)
inline

Updates all the indices and pointers of the elements of the container of ELEM_ID in the mesh, according to the mapping stored in the newIndices vector, that tells for each old element index, the new index of the element in the same container (or UINT_NULL if the element must be left as unreferenced - useful when a vertex is deleted).

This function is useful when you move some vertices (e.g. it is automatically called after every compacting of a container), and you want to update the indices/pointers of the elements stored in all the containers of the mesh.

The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.

Note
This function does not change the position of the elements in their container. It just updates the indices/pointers of the elements stored in their or other containers. This function should be called after the elements have been actually moved in their container.
Template Parameters
ELEM_IDthe ID of the element.
Parameters
[in]newIndicesa vector that tells, for each old element index, the new element index. If the old element must be left as unreferenced (setting nullptr to the pointers), the value of the vector must be UINT_NULL.

◆ updateReferencesOfContainerType()

template<typename... Args>
template<typename Cont , typename Array , typename... A>
static void vcl::Mesh< Args >::updateReferencesOfContainerType ( Mesh< A... > &  m,
const Array bases 
)
inlinestaticprivate

This function is static, and is generally called for each container of the mesh, that is the template argument Cont.

In general, for each container, we need to update all the references contained in it, that may be of any element of the mesh (example: in the VertexContainer there could be Vertex references, but also Face or Edge references).

Here in this function, we loop into the containers of the Mesh m using pack expansion, and we use the Cont type to choose which references type we are updating:

for each Element E in Mesh:
Cont::updateReferencesToElement(E)

The foreach loop is done using pack expansion inside the last call m.updateReferences, trough the argument ContainerWrapper

bases contains the old bases (the ones of the other mesh) for each container.

Friends And Related Symbol Documentation

◆ swap

template<typename... Args>
void swap ( Mesh< Args > &  a,
Mesh< Args > &  b 
)
friend

Specializes the swap function to allow the swapping of two Mesh objects.

Swaps the content of the two Mesh objects. Calls a.swap(b).

Parameters
[in]aThe first Mesh object.
[in]bThe second Mesh object.

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