Visual Computing Library
|
The CustomComponents Component is a container of additional components associated to an Element (e.g. Vertex, Face). More...
#include <vclib/mesh/components/custom_components.h>
Public Member Functions | |
CustomComponents ()=default | |
Initilizes an empty container of custom components. | |
bool | hasCustomComponent (const std::string &compName) const |
Returns true if the element has a custom component with the given name, false otherwise. The type of the custom component is not checked. | |
template<typename CompType > | |
bool | isCustomComponentOfType (const std::string &compName) const |
Returns true if the custom component of the given name is of the type given as template argument, false otherwise. | |
std::type_index | customComponentType (const std::string &compName) const |
Returns the std::type_index of the custom component of the given name. | |
template<typename CompType > | |
std::vector< std::string > | customComponentNamesOfType () const |
Returns a std::vector of std::strings containing the names of the custom components of the type given as template argument. | |
template<typename CompType > | |
const CompType & | customComponent (const std::string &compName) const |
Returns the const reference to the custom component of the given name having the type given as template argument. | |
template<typename CompType > | |
CompType & | customComponent (const std::string &compName) |
Returns the reference to the custom component of the given name having the type given as template argument. | |
template<typename CompType > requires (!IS_VERTICAL) | |
void | addCustomComponent (const std::string &compName, const CompType &value=CompType()) |
void | deleteCustomComponent (const std::string &compName) |
Static Public Attributes | |
static const uint | COMPONENT_ID = CompId::CUSTOM_COMPONENTS |
The ID of component. | |
Protected Member Functions | |
template<typename Element > | |
void | importFrom (const Element &e, bool=true) |
void | serialize (std::ostream &os) const |
void | deserialize (std::istream &is) |
Private Attributes | |
detail::CustomComponentsData< ParentElemType, IS_VERTICAL > | mData |
Static Private Attributes | |
static const bool | IS_VERTICAL = !std::is_same_v<ParentElemType, void> |
The CustomComponents Component is a container of additional components associated to an Element (e.g. Vertex, Face).
CustomComponents are components that can be added at runtime. Each custom component is composed of:
E.g., to access to a CustomComponent of type 'int' called "myCustomComponent" from an element el:
CustomComponents can be stored horizontally or vertically.
If the CustomComponents component is horizontal (this happens mostly on Mesh data structures), a custom component can be added or removed from the object itself.
For example, having a Mesh m of type 'MyMesh' that has horizontal CustomComponents:
Otherwise, if the CustomComponents component is vertical (this happens mostly on Element types stored in a container, like Vertex, Face...), the addition/deletion of a custom component cannot be performed by the object, because its storage its managed by the Container of objects (that must provide a proper member function to do that).
For example, having a Mesh m of type MyMesh that has a VertexContainer where its Vertex has (vertical) CustomComponents:
After this call, all the Vertices of the VertexContainer will have their custom component of type int called "myCustomComponent". The member function addPerVertexCustomComponent is provided by the VertexContainer and can be accessed directly from the Mesh.
ParentElemType | This template argument must be void if the component needs to be stored horizontally, or the type of the parent element that will contain this component if the component needs to be stored vertically. |
|
inline |
Returns the reference to the custom component of the given name having the type given as template argument.
std::out_of_range | if the element does not have a custom component with the given name. |
std::bad_any_cast | if the custom component is not of the type given as template argument. |
CompType | the type of the custom component to retrieve. |
[in] | compName | the name of the custom component. |
|
inline |
Returns the const reference to the custom component of the given name having the type given as template argument.
std::out_of_range | if the element does not have a custom component with the given name. |
std::bad_any_cast | if the custom component is not of the type given as template argument. |
CompType | the type of the custom component to retrieve. |
[in] | compName | the name of the custom component. |
|
inline |
Returns a std::vector of std::strings containing the names of the custom components of the type given as template argument.
CompType | the type of the custom components to retrieve. |
|
inline |
Returns the std::type_index
of the custom component of the given name.
std::out_of_range | if the element does not have a custom component with the given name. |
[in] | compName | the name of the custom component. |
std::type_index
of the custom component of the given name.
|
inline |
Returns true if the element has a custom component with the given name, false otherwise. The type of the custom component is not checked.
[in] | compName | the name of the custom component. |
|
inline |
Returns true if the custom component of the given name is of the type given as template argument, false otherwise.
std::out_of_range | if the element does not have a custom component with the given name. |
CompType | the type of the custom component to check. |
[in] | compName | the name of the custom component. |