Visual Computing Library
|
The Vertex Container class, will be used when the template argument given to the Mesh is a Vertex. More...
#include <vclib/mesh/containers/vertex_container.h>
Public Types | |
using | Vertex = T |
using | VertexType = T |
using | VertexIterator = Base::ElementIterator |
using | ConstVertexIterator = Base::ConstElementIterator |
Public Member Functions | |
VertexContainer ()=default | |
Empty constructor that creates an empty container of Vertices. | |
const VertexType & | vertex (uint i) const |
Returns a const reference of the vertex at the i-th position in the Vertex Container of the Mesh, which will be the vertex having index = i. | |
VertexType & | vertex (uint i) |
Returns a reference of the vertex at the i-th position in the Vertex Container of the Mesh, which will be the vertex having index = i. | |
uint | vertexNumber () const |
Returns the number of non-deleted vertices contained in the Vertex container of the Mesh. | |
uint | vertexContainerSize () const |
Returns the number of vertices (also deleted) contained in the Vertex container of the Mesh. | |
uint | deletedVertexNumber () const |
Returns the number of deleted vertices in the Vertex container, that is vertexContainerSize() - vertexNumber(). | |
uint | addVertex () |
Add a new vertex into the vertex container, returning the index of the added vertex. | |
uint | addVertex (const typename T::CoordType &p) |
Add a new vertex with the given coordinate into the vertex container, returning the id of the added vertex. | |
uint | addVertices (uint n) |
Add an arbitrary number of n vertices, returning the id of the first added vertex. | |
template<typename... VC> | |
uint | addVertices (const typename T::CoordType &p, const VC &... v) |
Add an arbitrary number of vertices with the given coordinates, returning the id of the first added vertex. | |
template<vcl::Range R> requires RangeOf<R, typename T::CoordType> | |
uint | addVertices (R &&range) |
Add an arbitrary number of vertices with the coordinates contained in the given range, returning the id of the first added vertex. | |
void | clearVertices () |
Clears the Vertex container of the Mesh, deleting all the vertices. | |
void | resizeVertices (uint n) |
Resizes the Vertex container to contain n vertices. | |
void | reserveVertices (uint n) |
Reserve a number of vertices in the container of Vertices. This is useful when you know (or you have an idea) of how much vertices are going to add into a newly or existing mesh. Calling this function before any add_vertex() call will avoid unuseful reallocations of the container, saving execution time. | |
void | compactVertices () |
Compacts the Vertex Container, removing all the vertices marked as deleted. Vertices indices will change accordingly. The function will automatically take care of updating all the Vertex pointers contained in the Mesh. | |
void | deleteVertex (uint i) |
Marks as deleted the vertex with the given id. | |
void | deleteVertex (const VertexType *v) |
Marks as deleted the given vertex, before asserting that the vertex belongs to this container. | |
uint | vertexIndexIfCompact (uint i) const |
This is an utility member function that returns the index of an element if the container would be compact, that is the number of non-deleted elements before the vertex with the given index. | |
std::vector< uint > | vertexCompactIndices () const |
Returns a vector that tells, for each actual vertex index, the new index that the vertex would have in a compacted container. For each deleted vertex index, the value of the vector will be UINT_NULL. | |
void | updateVertexIndices (const std::vector< uint > &newIndices) |
Updates all the indices and pointers of the vertices of this container that are stored in any container of the mesh, according to the mapping stored in the newIndices vector, that tells for each old vertex index, the new vertex index. | |
VertexIterator | vertexBegin (bool jumpDeleted=true) |
Returns an iterator to the beginning of the container. | |
VertexIterator | vertexEnd () |
Returns an iterator to the end of the container. | |
ConstVertexIterator | vertexBegin (bool jumpDeleted=true) const |
Returns a const iterator to the beginning of the container. | |
ConstVertexIterator | vertexEnd () const |
Returns a const iterator to the end of the container. | |
auto | vertices (bool jumpDeleted=true) |
Returns a small utility object that allows to iterate over the vertices of the containers, providing two member functions begin() and end(). | |
auto | vertices (bool jumpDeleted=true) const |
Returns a small utility object that allows to iterate over the vertices of the containers, providing two member functions begin() and end(). | |
void | enableAllPerVertexOptionalComponents () |
Enables all the optional components associated to the Vertex type contained in the VertexContainer. | |
void | disableAllPerVertexOptionalComponents () |
Disables all the optional components associated to the Vertex type contained in the VertexContainer. | |
bool | isPerVertexAdjacentEdgesEnabled () const |
Checks if the vertex Optional Adjacent Edges component is enabled. | |
void | enablePerVertexAdjacentEdges () |
Enables the Optional Adjacent Edges of the vertex. | |
void | disablePerVertexAdjacentEdges () |
Disables the Optional Adjacent Edges of the vertex. | |
bool | isPerVertexAdjacentFacesEnabled () const |
Checks if the vertex Optional Adjacent Faces component is enabled. | |
void | enablePerVertexAdjacentFaces () |
Enables the Optional Adjacent Faces of the vertex. | |
void | disablePerVertexAdjacentFaces () |
Disables the Optional Adjacent Faces of the vertex. | |
bool | isPerVertexAdjacentVerticesEnabled () const |
Checks if the vertex Optional Adjacent Vertices component is enabled. | |
void | enablePerVertexAdjacentVertices () |
Enables the Optional Adjacent Vertices of the vertex. | |
void | disablePerVertexAdjacentVertices () |
Disables the Optional Adjacent Vertices of the vertex. | |
bool | isPerVertexColorEnabled () const |
Checks if the vertex Optional Color is enabled. | |
void | enablePerVertexColor () |
Enables the Optional Color of the vertex. | |
void | disablePerVertexColor () |
Disables the Optional Color of the vertex. | |
bool | isPerVertexMarkEnabled () const |
Checks if the vertex Optional Mark is enabled. | |
void | enablePerVertexMark () |
Enables the Optional Mark of the vertex. | |
void | disablePerVertexMark () |
Container::disableVertexMark disables the Optional Mark of the vertex. | |
bool | isPerVertexNormalEnabled () const |
Checks if the vertex Optional Normal is enabled. | |
void | enablePerVertexNormal () |
Enables the Optional Normal of the vertex. | |
void | disablePerVertexNormal () |
Checks if the vertex Optional PrincipalCurvature is enabled. | |
bool | isPerVertexPrincipalCurvatureEnabled () const |
Checks if the vertex Optional PrincipalCurvature is enabled. | |
void | enablePerVertexPrincipalCurvature () |
Enables the Optional PrincipalCurvature of the vertex. | |
void | disablePerVertexPrincipalCurvature () |
Disables the Optional PrincipalCurvature of the vertex. | |
bool | isPerVertexQualityEnabled () const |
Checks if the vertex Optional Quality is enabled. | |
void | enablePerVertexQuality () |
Enables the Optional Quality of the vertex. | |
void | disablePerVertexQuality () |
Disables the Optional Quality of the vertex. | |
bool | isPerVertexTexCoordEnabled () const |
Checks if the vertex Optional TexCoord is enabled. | |
void | enablePerVertexTexCoord () |
Enables the Optional TexCoord of the vertex. | |
void | disablePerVertexTexCoord () |
Disables the Optional TexCoord of the vertex. | |
bool | hasPerVertexCustomComponent (const std::string &name) const |
Checks if vertices have a custom component with the given name. | |
std::vector< std::string > | perVertexCustomComponentNames () const |
Returns a vector containing all the names of the custom components of any type associated to the Vertex Element. | |
template<typename K > requires vert::HasCustomComponents<T> | |
bool | isPerVertexCustomComponentOfType (const std::string &name) const |
Checks if the custom component of the Vertex Element having the given name has the same type of the given template argument type of this function. | |
std::type_index | perVertexCustomComponentType (const std::string &name) const |
Returns the std::type_index of the custom component of the Vertex Element having the given input name. | |
template<typename K > requires vert::HasCustomComponents<T> | |
std::vector< std::string > | perVertexCustomComponentNamesOfType () const |
Returns a vector containing all the names of the custom components associated to the Vertex Element having the same type of the given template argument type of this function. | |
template<typename K > requires vert::HasCustomComponents<T> | |
void | addPerVertexCustomComponent (const std::string &name) |
Adds a custom component of type K to the Vertex, having the given name. | |
void | deletePerVertexCustomComponent (const std::string &name) |
Deletes the custom component of the given name from the Vertex Element. | |
template<typename K > requires vert::HasCustomComponents<T> | |
CustomComponentVectorHandle< K > | perVertexCustomComponentVectorHandle (const std::string &name) |
Returns a vector handle to the custom component having the type K and the given name. | |
template<typename K > requires vert::HasCustomComponents<T> | |
ConstCustomComponentVectorHandle< K > | perVertexCustomComponentVectorHandle (const std::string &name) const |
Returns a const vector handle to the custom component having type K and the given name. | |
Private Types | |
using | VertexContainerType = VertexContainer< T > |
using | Base = ElementContainer< T > |
The Vertex Container class, will be used when the template argument given to the Mesh is a Vertex.
This class adds a container (vector) of vertices to the Mesh, making available the accessors members to the vertices, the vertex number, iterators... This class will also take care to add enablers/disablers of the eventual optional components of the vertex.
This container can be templated on a type that satisfies the VertexConcept concept.
|
inline |
|
inline |
Add a new vertex into the vertex container, returning the index of the added vertex.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
|
inline |
Add a new vertex with the given coordinate into the vertex container, returning the id of the added vertex.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
p | coordinate of the new vertex. |
|
inline |
Add an arbitrary number of vertices with the given coordinates, returning the id of the first added vertex.
You can call this member function like:
The number of accepted Coordtype arguments is variable.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
p | first vertex coordinate |
v | list of other vertex coordinates |
|
inline |
Add an arbitrary number of vertices with the coordinates contained in the given range, returning the id of the first added vertex.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
range | the range of coordinates of the vertices to add. |
|
inline |
Add an arbitrary number of n vertices, returning the id of the first added vertex.
This means that, if you want to add 5 vertices and this member function returns 4, the added vertices will have id from 4 to id 8 included.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
n | the number of vertices to add to the mesh. |
|
inline |
Clears the Vertex container of the Mesh, deleting all the vertices.
The contained vertices are actually removed from the container, not only marked as deleted. Therefore, the container will have size 0 (vertexContainerSize() == 0
) after the call of this function.
|
inline |
Returns the number of deleted vertices in the Vertex container, that is vertexContainerSize() - vertexNumber().
|
inline |
|
inline |
Marks as deleted the given vertex, before asserting that the vertex belongs to this container.
This member function does not perform any reallocation of the vertices: the deleted vertices will stay in the Vertex Container, but will be marked as deleted.
Deleted vertices are automatically jumped by the iterators provided by the Vertex Container.
[in] | v | the pointer of the vertex that will be marked as deleted. |
|
inline |
Marks as deleted the vertex with the given id.
This member function does not perform any reallocation of the vertices: the deleted vertices will stay in the Vertex Container, but will be marked as deleted.
Deleted vertices are automatically jumped by the iterators provided by the Vertex Container.
[in] | i | the id of the vertex that will be marked as deleted. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Checks if the vertex Optional PrincipalCurvature is enabled.
|
inline |
Disables the Optional PrincipalCurvature of the vertex.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Enables the Optional PrincipalCurvature of the vertex.
|
inline |
|
inline |
|
inline |
Checks if vertices have a custom component with the given name.
This function does not take into account the type of the custom component.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Checks if the custom component of the Vertex Element having the given name has the same type of the given template argument type of this function.
For example, the following code checks if the component called cc
is of type double
:
K | the type of the custom component to check. |
[in] | name | the name of the custom component to check. |
std::out_of_range | if no custom component of the given name was found. |
true
if the custom component is of the same type of the template argument.
|
inline |
|
inline |
|
inline |
Checks if the vertex Optional PrincipalCurvature is enabled.
|
inline |
|
inline |
|
inline |
|
inline |
Returns a vector containing all the names of the custom components associated to the Vertex Element having the same type of the given template argument type of this function.
For example, the following code gets a vector containing all the custom components of type double
:
K | the type of the custom component names. |
|
inline |
Returns the std::type_index of the custom component of the Vertex Element having the given input name.
[in] | name | the name of the custom component to get the std::type_index from. |
std::out_of_range | if no custom component of the given name was found. |
|
inline |
Returns a vector handle to the custom component having the type K and the given name.
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.
K | the type of the custom component on which return the handle. |
[in] | name | name of the custom component on which return the handle. |
std::out_of_range | if no custom component of the given name was found. |
|
inline |
Returns a const vector handle to the custom component having type K and the given name.
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.
K | the type of the custom component on which return the handle. |
[in] | name | name of the custom component on which return the handle. |
std::out_of_range | if no custom component of the given name was found. |
|
inline |
Reserve a number of vertices in the container of Vertices. This is useful when you know (or you have an idea) of how much vertices are going to add into a newly or existing mesh. Calling this function before any add_vertex() call will avoid unuseful reallocations of the container, saving execution time.
The filosofy of this function is similar to the one of the reserve() function of the std::vector class.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
n | the new capacity of the vertex container. |
|
inline |
Resizes the Vertex container to contain n
vertices.
If the new size is greater than the old one, new vertices 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
vertices, and the remaining vertices are marked as deleted.
If the call of this function will cause a reallocation of the Vertex container, the function will automatically take care of updating all the Vertex pointers contained in the Mesh.
n
is relative to the number of non-deleted vertices, not to the size of the vertex container. For example, if you have a mesh with 10 vertices and vertexContainerSize() == 20, calling resizeVertices(5) will not cause a reallocation of the container, but will mark as deleted the least 5 non-deleted vertices of the container. In the same scenario, calling resizeVertices(15) will result in a vertex container having 15 vertices and vertexContainerSize() == 25. The latest 5 vertices will be the newly added.[in] | n | the new size of the Vertex container. |
|
inline |
Updates all the indices and pointers of the vertices of this container that are stored in any container of the mesh, according to the mapping stored in the newIndices vector, that tells for each old vertex index, the new vertex index.
This function is useful when some vertices, and you want to update the indices/pointers stored in all the containers of the mesh accordingly.
E.g. Supposing you deleted a set of vertices, you can give to this function the vector telling, for each of the old vertex indices, the new vertex index (or UINT_NULL if you want to leave it unreferenced). This function will update all the pointers stored in the mesh containers accordingly (if they store adjacencies to the vertices).
[in] | newIndices | a vector that tells, for each old vertex index, the new vertex index. If the old vertex must be left as unreferenced (setting nullptr to the pointers), the value of the vector must be UINT_NULL. |
|
inline |
Returns a reference of the vertex at the i-th position in the Vertex Container of the Mesh, which will be the vertex having index = i.
This function does not perform any sanity check: if i is less than vertexContainerSize(), this function will return a valid Vertex reference (note that the Vertex may have been flagged as deleted).
[in] | i | the index of the vertex that will be returned. |
|
inline |
Returns a const reference of the vertex at the i-th position in the Vertex Container of the Mesh, which will be the vertex having index = i.
This function does not perform any sanity check: if i is less than vertexContainerSize(), this function will return a valid Vertex reference (note that the Vertex may have been flagged as deleted).
[in] | i | the index of the vertex that will be returned. |
|
inline |
Returns an iterator to the beginning of the container.
The iterator is automatically initialized to jump deleted vertices of the container. You can change this option by calling this function with jumpDeleted=false.
[in] | jumpDeleted | (def: true): boolean that tells if the iterator should jump deleted vertices. |
|
inline |
Returns a const iterator to the beginning of the container.
The iterator is automatically initialized to jump deleted vertices of the container. You can change this option by calling this function with jumpDeleted=false.
[in] | jumpDeleted | (def: true): boolean that tells if the iterator should jump deleted vertices. |
|
inline |
Returns a vector that tells, for each actual vertex index, the new index that the vertex would have in a compacted container. For each deleted vertex index, the value of the vector will be UINT_NULL.
This is useful if you need to know the indices of the vertices that they would have in a compact container, without considering the deleted ones.
|
inline |
Returns the number of vertices (also deleted) contained in the Vertex container of the Mesh.
If vertexNumber() != vertexContainerSize(), it means that there are some vertices that are flagged as deleted.
|
inline |
Returns an iterator to the end of the container.
|
inline |
Returns a const iterator to the end of the container.
|
inline |
This is an utility member function that returns the index of an element if the container would be compact, that is the number of non-deleted elements before the vertex with the given index.
Complexity: O(n), with n the number of vertices in the container.
This function does not perform any sanity check on the given index.
[in] | i | the index of a vertex of the container. |
|
inline |
Returns the number of non-deleted vertices contained in the Vertex container of the Mesh.
If vertexNumber() != vertexContainerSize(), it means that there are some vertices that are flagged as deleted.
|
inline |
Returns a small utility object that allows to iterate over the vertices of the containers, providing two member functions begin() and end().
This member function is very useful when you want to iterate over the vertices using the C++ foreach syntax:
The iterator used to iterate over vertices is automatically initialized to jump deleted vertices of the container. You can change this option by calling this function with jumpDeleted=false.
[in] | jumpDeleted | (def: true): boolean that tells if the iterator should jump deleted vertices. |
|
inline |
Returns a small utility object that allows to iterate over the vertices of the containers, providing two member functions begin() and end().
This member function is very useful when you want to iterate over the vertices using the C++ foreach syntax:
The iterator used to iterate over vertices is automatically initialized to jump deleted vertices of the container. You can change this option by calling this function with jumpDeleted=false.
[in] | jumpDeleted | (def: true): boolean that tells if the iterator should jump deleted vertices. |