Visual Computing Library
|
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>
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. | |
Mesh & | operator= (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 auto & | element (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>()) | |
auto & | element (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< uint > | compactIndices () 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 > | |
auto & | customComponents () |
template<typename El > | |
const auto & | customComponents () const |
template<typename El > | |
auto & | verticalComponents () |
template<typename El > | |
const auto & | verticalComponents () 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. | |
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.
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 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:
Move constructor, moves the given mesh into this one, without any other resource acquisition.
oth | the mesh that will be moved into this Mesh. |
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.
ELEM_ID | the ID of the element. |
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.
ELEM_ID | the ID of the element. |
[in] | n | the number of elements to add. |
|
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.
ELEM_ID | the ID of the element. |
K | the type of the custom component. |
[in] | name | the name of the custom component. |
Appends all the elements contained in the mesh m to this mesh.
m |
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.
ELEM_ID | the ID of the element. |
[in] | jumpDeleted | if 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 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.
ELEM_ID | the ID of the element. |
[in] | jumpDeleted | if true , the iterator will be initialized to jump deleted elements in the container. |
Clears all the Elements contained in the mesh.
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:
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.
ELEM_ID | the ID of the element. |
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.
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:
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.
ELEM_ID | the ID of the element. |
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.
ELEM_ID | the ID of the element. |
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.
ELEM_ID | the ID of the element. |
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.
El | the type of the element to delete. It must satisfy the ElementConcept. |
[in] | e | the element to delete. |
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.
El | the type of the element to delete. It must satisfy the ElementConcept. |
[in] | e | a pointer to the element to delete. |
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.
ELEM_ID | the ID of the element. |
[in] | i | the index of the element to delete. |
|
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.
ELEM_ID | the ID of the element. |
[in] | name | the name of the custom component. |
|
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:
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.
ELEM_ID | the ID of the element. |
COMP_ID | the ID of the component. |
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.
ELEM_ID | the ID of the element to return. |
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.
ELEM_ID | the ID of the element to return. |
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:
The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.
ELEM_ID | the ID of the element. |
[in] | jumpDeleted | if true , the view will be initialized to jump deleted elements in the container. |
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:
The function requires that the Mesh has a Container of Elements having ID ELEM_ID. Otherwise, a compiler error will be triggered.
ELEM_ID | the ID of the element. |
[in] | jumpDeleted | if true , the view will be initialized to jump deleted elements in the container. |
|
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:
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.
ELEM_ID | the ID of the element. |
COMP_ID | the ID of the component. |
|
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:
Example of usage:
m |
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.
ELEM_ID | the ID of the element. |
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.
ELEM_ID | the ID of the element. |
|
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):
El | the Element type to check. |
|
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):
ELEM_ID | the Element ID to check. |
|
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):
|
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.
ELEM_ID | the ID of the element. |
[in] | name | the name of the custom component. |
true
if the Element having ID ELEM_ID
has a custom component having the given name.
|
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):
|
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.
[in] | m | the mesh from which import all the data. |
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.
El | The type of the Element, it must satisfy the ElementConcept. |
e | a reference of an element of the Mesh. |
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.
El | The type of the Element, it must satisfy the ElementConcept. |
e | a pointer to an element of the Mesh. |
Returns true if this mesh is compact, meaning that all its containers have no deleted elements (size == element number).
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.
ELEM_ID | the ID of the element. |
COMP_ID | the ID of the component. |
true
if optional Component COMP_ID
is enabled for elements of type ELEM_ID
in the mesh.
|
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.
ELEM_ID | the ID of the element. |
K | the type of the custom component. |
[in] | name | the name of the custom component. |
true
if the Element having ID ELEM_ID
has a custom component of type K
having the given name. 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.
ELEM_ID | the ID of the element. |
|
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.
ELEM_ID | the ID of the element. |
ELEM_ID
.
|
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.
ELEM_ID | the ID of the element. |
K | the type of the custom component. |
K
for the Element having ID ELEM_ID
.
|
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.
ELEM_ID | the ID of the element. |
[in] | name | the name of the custom component. |
ELEM_ID
.
|
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:
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.
ELEM_ID | the ID of the element. |
K | the type of the custom component. |
[in] | name | the name of the custom component. |
K
having the given name associated to the Element having ID ELEM_ID
.
|
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:
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.
ELEM_ID | the ID of the element. |
K | the type of the custom component. |
[in] | name | the name of the custom component. |
K
having the given name associated to the Element having ID ELEM_ID
. 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.
ELEM_ID | the type ID of the element. |
[in] | n | the new capacity of the container in the mesh. |
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.
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.ELEM_ID | the ID of the element. |
[in] | n | the new size of the container in the mesh. |
|
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.
|
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.
|
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.
ELEM_ID | the ID of the element. |
[in] | newIndices | a 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. |
|
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:
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.