Visual Computing Library
|
The EdgeContainer class represents a container of Edge elements that can be used in a Mesh class. More...
#include <vclib/mesh/containers/edge_container.h>
Public Types | |
using | Edge = T |
using | EdgeType = T |
using | EdgeIterator = Base::ElementIterator |
using | ConstEdgeIterator = Base::ConstElementIterator |
Public Member Functions | |
EdgeContainer ()=default | |
Empty constructor that creates an empty container of Edges. | |
const EdgeType & | edge (uint i) const |
Returns a const reference of the Edge at the i-th position in the Edge Container of the Mesh, which will be the Edge having index = i. | |
EdgeType & | edge (uint i) |
Returns a reference of the Edge at the i-th position in the Edge Container of the Mesh, which will be the Edge having index = i. | |
uint | edgeNumber () const |
Returns the number of non-deleted Edges contained in the Edge container of the Mesh. | |
uint | edgeContainerSize () const |
Returns the number of Edges (also deleted) contained in the Edge container of the Mesh. | |
uint | deletedEdgeNumber () const |
Returns the number of deleted Edges in the Edge container, that is edgeContainerSize() - edgeNumber(). | |
uint | addEdge () |
Add an Edge to the container, returning its index. | |
uint | addEdge (uint v0, uint v1) |
Add an Edge having the two given vertices to the container, returning its index. | |
uint | addEdge (typename T::VertexType *v0, typename T::VertexType *v1) |
Add an Edge having the two given vertices to the container, returning its index. | |
uint | addEdges (uint n) |
Add an arbitrary number of n Edges, returning the id of the first added Edge. | |
void | clearEdges () |
Clears the Edge container of the Mesh, deleting all the Edges. | |
void | resizeEdges (uint n) |
Resizes the Edge container to contain n Edges. | |
void | reserveEdges (uint n) |
Reserve a number of Edges in the container of Edges. This is useful when you know (or you have an idea) of how much Edges are going to add into a newly of existing mesh. Calling this function before any addEdge() call will avoid unuseful reallocations of the container, saving execution time. | |
void | compactEdges () |
Compacts the EdgeContainer, removing all the Edges marked as deleted. Edges indices will change accordingly. The function will automatically take care of updating all the Edge pointers contained in the Mesh. | |
void | deleteEdge (uint i) |
Marks as deleted the Edge with the given id. | |
void | deleteEdge (const EdgeType *e) |
Marks as deleted the given Edge, before asserting that the Edge belongs to this container. | |
uint | edgeIndexIfCompact (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 Edge with the given index. | |
std::vector< uint > | edgeCompactIndices () const |
Returns a vector that tells, for each actual Edge index, the new index that the Edge would have in a compacted container. For each deleted Edge index, the value of the vector will be UINT_NULL. | |
void | updateEdgeIndices (const std::vector< uint > &newIndices) |
Updates all the indices and pointers of the Edges 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 Edge index, the new Edge index. | |
EdgeIterator | edgeBegin (bool jumpDeleted=true) |
Returns an iterator to the beginning of the container. | |
EdgeIterator | edgeEnd () |
Returns an iterator to the end of the container. | |
ConstEdgeIterator | edgeBegin (bool jumpDeleted=true) const |
Returns a const iterator to the beginning of the container. | |
ConstEdgeIterator | edgeEnd () const |
Returns a const iterator to the end of the container. | |
auto | edges (bool jumpDeleted=true) |
Returns a small view object that allows to iterate over the Edges of the containers, providing two member functions begin() and end(). | |
auto | edges (bool jumpDeleted=true) const |
Returns a small view object that allows to iterate over the Edges of the containers, providing two member functions begin() and end(). | |
void | enableAllPerEdgeOptionalComponents () |
Enables all the optional components associated to the Edge type contained in the EdgeContainer. | |
void | disableAllPerEdgeOptionalComponents () |
Disables all the optional components associated to the Edge type contained in the EdgeContainer. | |
bool | isPerEdgeAdjacentEdgesEnabled () const |
Checks if the Edge Optional AdjacentEdges is enabled. | |
void | enablePerEdgeAdjacentEdges () |
Enable the Optional AdjacentEdges of the Edge. | |
void | disablePerEdgeAdjacentEdges () |
Disables the Optional AdjacentEdges of the Edge. | |
bool | isPerEdgeAdjacentFacesEnabled () const |
Checks if the Edge Optional AdjacentFaces is enabled. | |
void | enablePerEdgeAdjacentFaces () |
Enable the Optional AdjacentFaces of the Edge. | |
void | disablePerEdgeAdjacentFaces () |
Disables the Optional AdjacentFaces of the Edge. | |
bool | isPerEdgeColorEnabled () const |
Checks if the Edge Optional Color is enabled. | |
void | enablePerEdgeColor () |
Enable the Optional Color of the Edge. | |
void | disablePerEdgeColor () |
Disables the Optional Color of the Edge. | |
bool | isPerEdgeMarkEnabled () const |
Checks if the Edge Optional Mark is enabled. | |
void | enablePerEdgeMark () |
Enable the Optional Mark of the Edge. | |
void | disablePerEdgeMark () |
Disables the Optional Mark of the Edge. | |
bool | isPerEdgeQualityEnabled () const |
Checks if the Edge Optional Quality is enabled. | |
void | enablePerEdgeQuality () |
Enable the Optional Quality of the Edge. | |
void | disablePerEdgeQuality () |
Disables the Optional Quality of the Edge. | |
bool | hasPerEdgeCustomComponent (const std::string &name) const |
Checks if Edges have a custom component with the given name. | |
std::vector< std::string > | perEdgeCustomComponentNames () const |
Returns a vector containing all the names of the custom components of any type associated to the Edge Element. | |
template<typename K > requires edge::HasCustomComponents<T> | |
bool | isPerEdgeCustomComponentOfType (const std::string &name) const |
Checks if the custom component of the Edge Element having the given name has the same type of the given template argument type of this function. | |
std::type_index | perEdgeCustomComponentType (const std::string &name) const |
Returns the std::type_index of the custom component of the Edge Element having the given input name. | |
template<typename K > requires edge::HasCustomComponents<T> | |
std::vector< std::string > | perEdgeCustomComponentNamesOfType () const |
Returns a vector containing all the names of the custom components associated to the Edge Element having the same type of the given template argument type of this function. | |
template<typename K > requires edge::HasCustomComponents<T> | |
void | addPerEdgeCustomComponent (const std::string &name) |
Adds a custom component of type K to the Edge, having the given name. | |
void | deletePerEdgeCustomComponent (const std::string &name) |
Deletes the custom component of the given name from the Edge Element. | |
template<typename K > requires edge::HasCustomComponents<T> | |
CustomComponentVectorHandle< K > | perEdgeCustomComponentVectorHandle (const std::string &name) |
Returns a vector handle to the custom component having the type K and the given name. | |
template<typename K > requires edge::HasCustomComponents<T> | |
ConstCustomComponentVectorHandle< K > | perEdgeCustomComponentVectorHandle (const std::string &name) const |
Returns a const vector handle to the custom component having type K and the given name. | |
Private Types | |
using | EdgeContainerType = EdgeContainer< T > |
using | Base = ElementContainer< T > |
The EdgeContainer class represents a container of Edge elements that can be used in a Mesh class.
This class adds a container (vector) of Edges to the Mesh, making available the accessors members to them and their components.
It provides all the add, delete, reserve, compact and other functions to manage the Edges, plus the iterators and views to iterate over them. It also provides the functions to enable and disable the optional components of the Edges.
T | The type of the Edge elements. It must satisfy the EdgeConcept. |
|
inline |
Add an Edge to the container, returning its index.
If the call of this function will cause a reallocation of the EdgeContainer, the function will automatically take care of updating all the Edge pointers contained in the Mesh.
|
inline |
Add an Edge having the two given vertices to the container, returning its index.
If the call of this function will cause a reallocation of the EdgeContainer, the function will automatically take care of updating all the Edge pointers contained in the Mesh.
[in] | v0 | the pointer to the first vertex of the edge. |
[in] | v1 | the pointer to the second vertex of the edge. |
|
inline |
Add an Edge having the two given vertices to the container, returning its index.
If the call of this function will cause a reallocation of the EdgeContainer, the function will automatically take care of updating all the Edge pointers contained in the Mesh.
[in] | v0 | the index of the first vertex of the edge. |
[in] | v1 | the index of the second vertex of the edge. |
|
inline |
Add an arbitrary number of n Edges, returning the id of the first added Edge.
This means that, if you want to add 5 Edges and this member function returns 4, the added Edges will have id from 4 to id 8 included.
If the call of this function will cause a reallocation of the EdgeContainer, the function will automatically take care of updating all the Edge pointers contained in the Mesh.
n | the number of Edges to add to the mesh. |
|
inline |
|
inline |
Clears the Edge container of the Mesh, deleting all the Edges.
The contained edges are actually removed from the container, not only marked as deleted. Therefore, the container will have size 0 (edgeContainerSize() == 0
) after the call of this function.
|
inline |
Returns the number of deleted Edges in the Edge container, that is edgeContainerSize() - edgeNumber().
|
inline |
Marks as deleted the given Edge, before asserting that the Edge belongs to this container.
This member function does not perform any reallocation of the Edges: the deleted Edges will stay in the Edge Container, but will be marked as deleted.
Deleted Edges are automatically jumped by the iterators provided by the Edge Container.
[in] | e | the pointer of the Edge that will be marked as deleted. |
|
inline |
Marks as deleted the Edge with the given id.
This member function does not perform any reallocation of the Edges: the deleted Edges will stay in the Edge Container, but will be marked as deleted.
Deleted Edges are automatically jumped by the iterators provided by the Edge Container.
[in] | i | the id of the Edge that will be marked as deleted. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns a reference of the Edge at the i-th position in the Edge Container of the Mesh, which will be the Edge having index = i.
This function does not perform any sanity check: if i is less than edgeContainerSize(), this function will return a valid Edge reference (note that the Edge may have been flagged as deleted).
[in] | i | the index of the Edge that will be returned. |
|
inline |
Returns a const reference of the Edge at the i-th position in the Edge Container of the Mesh, which will be the Edge having index = i.
This function does not perform any sanity check: if i is less than edgeContainerSize(), this function will return a valid Edge reference (note that the Edge may have been flagged as deleted).
[in] | i | the index of the Edge that will be returned. |
|
inline |
Returns an iterator to the beginning of the container.
The iterator is automatically initialized to jump deleted Edges of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Edges. |
|
inline |
Returns a const iterator to the beginning of the container.
The iterator is automatically initialized to jump deleted Edges of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Edges. |
|
inline |
Returns a vector that tells, for each actual Edge index, the new index that the Edge would have in a compacted container. For each deleted Edge index, the value of the vector will be UINT_NULL.
This is useful if you need to know the indices of the Edges that they would have in a compact container, without considering the deleted ones.
|
inline |
Returns the number of Edges (also deleted) contained in the Edge container of the Mesh.
If edgeNumber() != edgeContainerSize(), it means that there are some Edges 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 Edge with the given index.
Complexity: O(n), with n the number of Edges in the container.
This function does not perform any sanity check on the given index.
[in] | i | the index of a Edge of the container. |
|
inline |
Returns the number of non-deleted Edges contained in the Edge container of the Mesh.
If edgeNumber() != edgeContainerSize(), it means that there are some Edges that are flagged as deleted.
|
inline |
Returns a small view object that allows to iterate over the Edges of the containers, providing two member functions begin() and end().
This member function is very useful when you want to iterate over the Edges using the C++ foreach syntax:
The iterator used to iterate over Edges is automatically initialized to jump deleted Edges of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Edges. |
|
inline |
Returns a small view object that allows to iterate over the Edges of the containers, providing two member functions begin() and end().
This member function is very useful when you want to iterate over the Edges using the C++ foreach syntax:
The iterator used to iterate over Edges is automatically initialized to jump deleted Edges of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Edges. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Checks if Edges 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 |
Checks if the custom component of the Edge 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 |
|
inline |
Returns a vector containing all the names of the custom components associated to the Edge 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 Edge 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 Edge 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 Edge 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. |
|
inline |
Reserve a number of Edges in the container of Edges. This is useful when you know (or you have an idea) of how much Edges are going to add into a newly of existing mesh. Calling this function before any addEdge() 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 Edge container, the function will automatically take care of updating all the Edge pointers contained in the Mesh.
n | the new capacity of the Edge container. |
|
inline |
Resizes the Edge container to contain n
Edges.
If the new size is greater than the old one, new Edges 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
Edges, and the remaining Edges are marked as deleted.
If the call of this function will cause a reallocation of the Edge container, the function will automatically take care of updating all the Edge pointers contained in the Mesh.
n
is relative to the number of non-deleted Edges, not to the size of the Edge container. For example, if you have a mesh with 10 Edges and edgeContainerSize() == 20, calling resizeEdges(5) will not cause a reallocation of the container, but will mark as deleted the least 5 non-deleted Edges of the container. In the same scenario, calling resizeEdges(15) will result in a Edge container having 15 Edges and edgeContainerSize() == 25. The latest 5 Edges will be the newly added.[in] | n | the new size of the Edge container. |
|
inline |
Updates all the indices and pointers of the Edges 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 Edge index, the new Edge index.
This function is useful when delete some Edges, 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 Edges, you can give to this function the vector telling, for each one of the old Edge indices, the new Edge 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 Edges).