Visual Computing Library
Loading...
Searching...
No Matches
vcl::mesh::EdgeContainer< T > Class Template Reference

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>

Inheritance diagram for vcl::mesh::EdgeContainer< T >:

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< uintedgeCompactIndices () 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 >
 

Detailed Description

template<EdgeConcept T>
class vcl::mesh::EdgeContainer< 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.

Template Parameters
TThe type of the Edge elements. It must satisfy the EdgeConcept.

Member Function Documentation

◆ addEdge() [1/3]

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::addEdge ( )
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.

Returns
the id of the newly added Edge.

◆ addEdge() [2/3]

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::addEdge ( typename T::VertexType *  v0,
typename T::VertexType *  v1 
)
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.

Parameters
[in]v0the pointer to the first vertex of the edge.
[in]v1the pointer to the second vertex of the edge.
Returns
the id of the newly added Edge.

◆ addEdge() [3/3]

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::addEdge ( uint  v0,
uint  v1 
)
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.

Parameters
[in]v0the index of the first vertex of the edge.
[in]v1the index of the second vertex of the edge.
Returns
the id of the newly added Edge.

◆ addEdges()

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::addEdges ( uint  n)
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.

Parameters
nthe number of Edges to add to the mesh.
Returns
the id of the first added Edge.

◆ addPerEdgeCustomComponent()

template<EdgeConcept T>
template<typename K >
requires edge::HasCustomComponents<T>
void vcl::mesh::EdgeContainer< T >::addPerEdgeCustomComponent ( const std::string &  name)
inline

Adds a custom component of type K to the Edge, having the given name.

Note
This function is available only if the Edge Element has the CustomComponents Component.
Template Parameters
Kthe type of the custom component added to the Edge.
Parameters
[in]namethe name of the custom component added to the Edge.

◆ clearEdges()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::clearEdges ( )
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.

Note
This function does not cause a reallocation of the Edge container.
Warning
Any pointer to Edges in the Mesh will be left unchanged, and therefore will point to invalid Edges. This means that, if you have a pointer to a Edge and you call this function, you will have a dangling pointer.

◆ deletedEdgeNumber()

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::deletedEdgeNumber ( ) const
inline

Returns the number of deleted Edges in the Edge container, that is edgeContainerSize() - edgeNumber().

Returns
The number of deleted Edges in the container.

◆ deleteEdge() [1/2]

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::deleteEdge ( const EdgeType *  e)
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.

Parameters
[in]ethe pointer of the Edge that will be marked as deleted.

◆ deleteEdge() [2/2]

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::deleteEdge ( uint  i)
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.

Parameters
[in]ithe id of the Edge that will be marked as deleted.

◆ deletePerEdgeCustomComponent()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::deletePerEdgeCustomComponent ( const std::string &  name)
inline

Deletes the custom component of the given name from the Edge Element.

The function does nothing if the custom component does not exists.

Note
This function is available only if the Edge Element has the CustomComponents Component.
Parameters
[in]namethe name of the custom component that will be removed from the Edge.

◆ disablePerEdgeAdjacentEdges()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::disablePerEdgeAdjacentEdges ( )
inline

Disables the Optional AdjacentEdges of the Edge.

Note
This function is available only if the Edge Element has the OptionalAdjacentEdges Component.

◆ disablePerEdgeAdjacentFaces()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::disablePerEdgeAdjacentFaces ( )
inline

Disables the Optional AdjacentFaces of the Edge.

Note
This function is available only if the Edge Element has the OptionalAdjacentFaces Component.

◆ disablePerEdgeColor()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::disablePerEdgeColor ( )
inline

Disables the Optional Color of the Edge.

Note
This function is available only if the Edge Element has the OptionalColor Component.

◆ disablePerEdgeMark()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::disablePerEdgeMark ( )
inline

Disables the Optional Mark of the Edge.

Note
This function is available only if the Edge Element has the OptionalMark Component.

◆ disablePerEdgeQuality()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::disablePerEdgeQuality ( )
inline

Disables the Optional Quality of the Edge.

Note
This function is available only if the Edge Element has the OptionalQuality Component.

◆ edge() [1/2]

template<EdgeConcept T>
EdgeType & vcl::mesh::EdgeContainer< T >::edge ( uint  i)
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).

Parameters
[in]ithe index of the Edge that will be returned.

◆ edge() [2/2]

template<EdgeConcept T>
const EdgeType & vcl::mesh::EdgeContainer< T >::edge ( uint  i) const
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).

Parameters
[in]ithe index of the Edge that will be returned.

◆ edgeBegin() [1/2]

template<EdgeConcept T>
EdgeIterator vcl::mesh::EdgeContainer< T >::edgeBegin ( bool  jumpDeleted = true)
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.

Parameters
[in]jumpDeletedboolean that tells if the iterator should jump deleted Edges.
Returns
An iterator the the first Edge of the container.

◆ edgeBegin() [2/2]

template<EdgeConcept T>
ConstEdgeIterator vcl::mesh::EdgeContainer< T >::edgeBegin ( bool  jumpDeleted = true) const
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.

Parameters
[in]jumpDeletedboolean that tells if the iterator should jump deleted Edges.
Returns
A const iterator the the first Edge of the container.

◆ edgeCompactIndices()

template<EdgeConcept T>
std::vector< uint > vcl::mesh::EdgeContainer< T >::edgeCompactIndices ( ) const
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.

Returns
A vector containing, for each Edge index, its index if the container would be compact.

◆ edgeContainerSize()

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::edgeContainerSize ( ) const
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.

Returns
the number of all the Edges contained in the Mesh.

◆ edgeEnd() [1/2]

template<EdgeConcept T>
EdgeIterator vcl::mesh::EdgeContainer< T >::edgeEnd ( )
inline

Returns an iterator to the end of the container.

Returns
An iterator to the end of the container.

◆ edgeEnd() [2/2]

template<EdgeConcept T>
ConstEdgeIterator vcl::mesh::EdgeContainer< T >::edgeEnd ( ) const
inline

Returns a const iterator to the end of the container.

Returns
A const iterator to the end of the container.

◆ edgeIndexIfCompact()

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::edgeIndexIfCompact ( uint  i) const
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.

Parameters
[in]ithe index of a Edge of the container.
Returns
The index that the Edge with index i would have if this container would be compact.

◆ edgeNumber()

template<EdgeConcept T>
uint vcl::mesh::EdgeContainer< T >::edgeNumber ( ) const
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.

Returns
the number of non-deleted Edges of the Mesh.

◆ edges() [1/2]

template<EdgeConcept T>
auto vcl::mesh::EdgeContainer< T >::edges ( bool  jumpDeleted = true)
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:

for (Edge& e : m.edges()){
// do something with this Edge
}
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
auto edges(bool jumpDeleted=true)
Returns a small view object that allows to iterate over the Edges of the containers,...
Definition edge_container.h:430

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.

Parameters
[in]jumpDeletedboolean that tells if the iterator should jump deleted Edges.
Returns
An object having begin() and end() function, allowing to iterate over the container.

◆ edges() [2/2]

template<EdgeConcept T>
auto vcl::mesh::EdgeContainer< T >::edges ( bool  jumpDeleted = true) const
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:

for (const Edge& e : m.edges()){
// do something with this Edge
}

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.

Parameters
[in]jumpDeletedboolean that tells if the iterator should jump deleted Edges.
Returns
An object having begin() and end() function, allowing to iterate over the container.

◆ enablePerEdgeAdjacentEdges()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::enablePerEdgeAdjacentEdges ( )
inline

Enable the Optional AdjacentEdges of the Edge.

Note
This function is available only if the Edge Element has the OptionalAdjacentEdges Component.

◆ enablePerEdgeAdjacentFaces()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::enablePerEdgeAdjacentFaces ( )
inline

Enable the Optional AdjacentFaces of the Edge.

Note
This function is available only if the Edge Element has the OptionalAdjacentFaces Component.

◆ enablePerEdgeColor()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::enablePerEdgeColor ( )
inline

Enable the Optional Color of the Edge.

Note
This function is available only if the Edge Element has the OptionalColor Component.

◆ enablePerEdgeMark()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::enablePerEdgeMark ( )
inline

Enable the Optional Mark of the Edge.

Note
This function is available only if the Edge Element has the OptionalMark Component.

◆ enablePerEdgeQuality()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::enablePerEdgeQuality ( )
inline

Enable the Optional Quality of the Edge.

Note
This function is available only if the Edge Element has the OptionalQuality Component.

◆ hasPerEdgeCustomComponent()

template<EdgeConcept T>
bool vcl::mesh::EdgeContainer< T >::hasPerEdgeCustomComponent ( const std::string &  name) const
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.

Note
This function is available only if the Edge Element has the CustomComponents Component.
Returns
true if the Edge Element has a custom component with the given name.

◆ isPerEdgeAdjacentEdgesEnabled()

template<EdgeConcept T>
bool vcl::mesh::EdgeContainer< T >::isPerEdgeAdjacentEdgesEnabled ( ) const
inline

Checks if the Edge Optional AdjacentEdges is enabled.

Note
This function is available only if the Edge Element has the OptionalAdjacentEdges Component.
Returns
true if the Optional AdjacentEdges is enabled, false otherwise.

◆ isPerEdgeAdjacentFacesEnabled()

template<EdgeConcept T>
bool vcl::mesh::EdgeContainer< T >::isPerEdgeAdjacentFacesEnabled ( ) const
inline

Checks if the Edge Optional AdjacentFaces is enabled.

Note
This function is available only if the Edge Element has the OptionalAdjacentFaces Component.
Returns
true if the Optional AdjacentFaces is enabled, false otherwise.

◆ isPerEdgeColorEnabled()

template<EdgeConcept T>
bool vcl::mesh::EdgeContainer< T >::isPerEdgeColorEnabled ( ) const
inline

Checks if the Edge Optional Color is enabled.

Note
This function is available only if the Edge Element has the OptionalColor Component.
Returns
true if the Optional Color is enabled, false otherwise.

◆ isPerEdgeCustomComponentOfType()

template<EdgeConcept T>
template<typename K >
requires edge::HasCustomComponents<T>
bool vcl::mesh::EdgeContainer< T >::isPerEdgeCustomComponentOfType ( const std::string &  name) const
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:

if (m.isPerEdgeCustomComponentOfType<double>("cc")) {
...
}
Note
This function is available only if the Edge Element has the CustomComponents Component.
Template Parameters
Kthe type of the custom component to check.
Parameters
[in]namethe name of the custom component to check.
Exceptions
std::out_of_rangeif no custom component of the given name was found.
Returns
true if the custom component is of the same type of the template argument.

◆ isPerEdgeMarkEnabled()

template<EdgeConcept T>
bool vcl::mesh::EdgeContainer< T >::isPerEdgeMarkEnabled ( ) const
inline

Checks if the Edge Optional Mark is enabled.

Note
This function is available only if the Edge Element has the OptionalMark Component.
Returns
true if the Optional Mark is enabled, false otherwise.

◆ isPerEdgeQualityEnabled()

template<EdgeConcept T>
bool vcl::mesh::EdgeContainer< T >::isPerEdgeQualityEnabled ( ) const
inline

Checks if the Edge Optional Quality is enabled.

Note
This function is available only if the Edge Element has the OptionalQuality Component.
Returns
true if the Optional Quality is enabled, false otherwise.

◆ perEdgeCustomComponentNames()

template<EdgeConcept T>
std::vector< std::string > vcl::mesh::EdgeContainer< T >::perEdgeCustomComponentNames ( ) const
inline

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

Note
This function is available only if the Edge Element has the CustomComponents Component.
Returns
A vector of strings representing all the names of the custom components.

◆ perEdgeCustomComponentNamesOfType()

template<EdgeConcept T>
template<typename K >
requires edge::HasCustomComponents<T>
std::vector< std::string > vcl::mesh::EdgeContainer< T >::perEdgeCustomComponentNamesOfType ( ) const
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:

std::vector<std::string> cdouble =
m.perEdgeCustomComponentNamesOfType<double>();
Note
This function is available only if the Edge Element has the CustomComponents Component.
Template Parameters
Kthe type of the custom component names.
Returns
A vector of strings representing the names of the custom components of a given type.

◆ perEdgeCustomComponentType()

template<EdgeConcept T>
std::type_index vcl::mesh::EdgeContainer< T >::perEdgeCustomComponentType ( const std::string &  name) const
inline

Returns the std::type_index of the custom component of the Edge Element having the given input name.

Note
This function is available only if the Edge Element has the CustomComponents Component.
Parameters
[in]namethe name of the custom component to get the std::type_index from.
Exceptions
std::out_of_rangeif no custom component of the given name was found.
Returns
The std::type_index of the custom component having the given input name.

◆ perEdgeCustomComponentVectorHandle() [1/2]

template<EdgeConcept T>
template<typename K >
requires edge::HasCustomComponents<T>
CustomComponentVectorHandle< K > vcl::mesh::EdgeContainer< T >::perEdgeCustomComponentVectorHandle ( const std::string &  name)
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:

auto handle = m.getPerEdgeCustomComponentVectorHandle<int>("cc");
for (Edge& e : m.edges() {
handle[m.index(e)] = 5; // e.customComponent<int>("cc") == 5
assert(e.customComponent<int>("cc") == 5);
}

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
This function is available only if the Edge Element has the CustomComponents Component.
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
Kthe type of the custom component on which return the handle.
Parameters
[in]namename of the custom component on which return the handle.
Exceptions
std::out_of_rangeif no custom component of the given name was found.
Returns
a vector handle that allows to access to the custom component.

◆ perEdgeCustomComponentVectorHandle() [2/2]

template<EdgeConcept T>
template<typename K >
requires edge::HasCustomComponents<T>
ConstCustomComponentVectorHandle< K > vcl::mesh::EdgeContainer< T >::perEdgeCustomComponentVectorHandle ( const std::string &  name) const
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:

// access to the const handle by making const the template parameter:
auto handle = m.perEdgeCustomComponentVectorHandle<const int>("cc");
int sum = 0;
for (const Edge& e : m.edges() {
sum += handle[m.index(e)];
// handle[m.index(e)] = 5; // not allowed, because the handle is const
}

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
This function is available only if the Edge Element has the CustomComponents Component.
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
Kthe type of the custom component on which return the handle.
Parameters
[in]namename of the custom component on which return the handle.
Returns
a const vector handle that allows to access to the custom component.

◆ reserveEdges()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::reserveEdges ( uint  n)
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.

Parameters
nthe new capacity of the Edge container.

◆ resizeEdges()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::resizeEdges ( uint  n)
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.

Warning
The given size 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.
Any pointer to deleted Edges in the Mesh will be left unchanged, and therefore will point to invalid Edges. This means that if you call this member function with a lower number of Edges, you'll need to manually manage the pointers to the deleted Edges.
Parameters
[in]nthe new size of the Edge container.

◆ updateEdgeIndices()

template<EdgeConcept T>
void vcl::mesh::EdgeContainer< T >::updateEdgeIndices ( const std::vector< uint > &  newIndices)
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).

Note
This function does not change the position of the Edges in this container. It just updates the indices/pointers of the Edges stored in this or other containers.
Parameters
[in]newIndicesa vector that tells, for each old Edge index, the new Edge index. If the old Edge must be left as unreferenced (setting nullptr to the pointers), the value of the vector must be UINT_NULL.

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