Visual Computing Library
|
The VertexReferences class represents a component that stores a container of indices or pointers to vertices that will be part of an Element (e.g. Face, Edge, Tetrahedron, etc.). More...
#include <vclib/mesh/components/vertex_references.h>
Public Types | |
using | VertexType = Vertex |
Expose the type of the Vertex. | |
using | VertexIterator = Base::Iterator |
using | ConstVertexIterator = Base::ConstIterator |
using | ConstVertexIndexIterator = Base::ConstIndexIterator |
Public Member Functions | |
VertexReferences ()=default | |
Empty constructor. | |
uint | vertexNumber () const |
Returns the number of vertices of the element. | |
Vertex * | vertex (uint i) |
Returns the pointer to the i-th vertex of the element. | |
const Vertex * | vertex (uint i) const |
Returns a const pointer to the i-th vertex of the element. | |
uint | vertexIndex (uint i) const |
Returns the index in the vertex container of the i-th vertex of the element. | |
Vertex * | vertexMod (int i) |
Returns a reference of the pointer to the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to get the "next vertex
after position k", without check if it is less than the number of vertices. Works also for negative numbers: | |
const Vertex * | vertexMod (int i) const |
Same of vertexMod, but returns a const pointer to the vertex. | |
uint | vertexIndexMod (int i) const |
Returns the index in the vertex container of the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to get the "index of the
vertex next to position k", without check if it is less than the number of vertices. Works also for negative numbers: | |
void | setVertex (uint i, Vertex *v) |
Sets the i-th vertex of the element. | |
void | setVertex (uint i, uint vi) |
Sets the i-th vertex of the element. | |
void | setVertex (ConstVertexIterator it, Vertex *v) |
Sets the vertex pointed by the iterator. | |
void | setVertex (ConstVertexIterator it, uint vi) |
Sets the vertex pointed by the iterator. | |
void | setVertex (ConstVertexIndexIterator it, Vertex *v) |
Sets the vertex pointed by the iterator. | |
void | setVertex (ConstVertexIndexIterator it, uint vi) |
Sets the vertex pointed by the iterator. | |
void | setVertexMod (int i, Vertex *v) |
Sets the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to set the "next vertex after position k", without check if it is less than the number of vertices. Works also for negative numbers: | |
void | setVertexMod (int i, uint vi) |
Sets the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to set the "next vertex after position k", without check if it is less than the number of vertices. Works also for negative numbers: | |
template<Range Rng> requires InputRange<Rng, Vertex*> | |
void | setVertices (Rng &&r) |
Sets all the vertex pointers of the element. | |
template<Range Rng> requires InputRange<Rng, uint> | |
void | setVertices (Rng &&r) |
Sets all the vertex pointers of the element. | |
bool | containsVertex (const Vertex *v) const |
Returns true if the container of vertices contains the given vertex, false otherwise. | |
bool | containsVertex (uint vi) const |
Returns true if the container of vertices contains the vertex with the given index, false otherwise. | |
uint | indexOfVertex (const Vertex *v) const |
Returns the index of the given vertex in the container of the element. If the given vertex is not in the container, returns UINT_NULL. | |
uint | indexOfVertex (uint vi) const |
Returns the index of the vertex with the given index in the container of the element. If the vertex with the given index is not in the container, returns UINT_NULL. | |
uint | indexOfEdge (const Vertex *v1, const Vertex *v2) const |
Returns the index of the given edge composed of the two vertices v1 and v2 in the container of the element. | |
uint | indexOfEdge (uint vi1, uint vi2) const |
Returns the index of the edge composed of the two vertices with the given indices in the container of the element. | |
void | resizeVertices (uint n) |
Resize the container of the vertices to the given size. | |
void | pushVertex (Vertex *v) |
Pushes in the back of the container the given vertex. | |
void | pushVertex (uint vi) |
Pushes in the back of the container the given vertex. | |
void | insertVertex (uint i, Vertex *v) |
Inserts the given vertex in the container at the given position. | |
void | insertVertex (uint i, uint vi) |
Inserts the vertex with the given index in the container at the given position. | |
void | eraseVertex (uint i) |
Removes the vertex at the given position from the container. | |
void | clearVertices () |
Clears the container of vertices, making it empty. | |
VertexIterator | vertexBegin () |
Returns an iterator to the first vertex in the container of this component. | |
VertexIterator | vertexEnd () |
Returns an iterator to the end of the container of this component. | |
ConstVertexIterator | vertexBegin () const |
Returns a const iterator to the first vertex in the container of this component. | |
ConstVertexIterator | vertexEnd () const |
Returns a const iterator to the end of the container of this component. | |
ConstVertexIndexIterator | vertexIndexBegin () const |
Returns an iterator to the first vertex index in the container of this component. | |
ConstVertexIndexIterator | vertexIndexEnd () const |
Returns an iterator to the end of the container of this component. | |
View< VertexIterator > | vertices () |
Returns a lightweight view object that stores the begin and end iterators of the container of vertices of the element. 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: | |
View< ConstVertexIterator > | vertices () const |
Returns a lightweight const view object that stores the begin and end iterators of the container of vertices of the element. 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: | |
View< ConstVertexIndexIterator > | vertexIndices () const |
Returns a lightweight view object that stores the begin and end iterators of the container of vertex indices of the element. 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: | |
Static Public Attributes | |
static const bool | INDEXED = STORE_INDICES |
static const int | VERTEX_NUMBER = Base::SIZE |
Protected Member Functions | |
template<typename Element > | |
void | importFrom (const Element &e, bool importRefs=true) |
void | serialize (std::ostream &os) const |
void | deserialize (std::istream &is) |
![]() | |
uint | size () const |
Elem * | element (uint i) |
const Elem * | element (uint i) const |
uint | elementIndex (uint i) const |
Elem * | elementMod (int i) |
const Elem * | elementMod (int i) const |
uint | elementIndexMod (int i) const |
void | setElement (uint i, Elem *e) |
void | setElement (uint i, uint ei) |
void | setElement (Base::ConstIterator it, Elem *v) |
void | setElement (Base::ConstIterator it, uint vi) |
void | setElement (Base::ConstIndexIterator it, Elem *v) |
void | setElement (Base::ConstIndexIterator it, uint vi) |
void | setElementMod (int i, Elem *e) |
void | setElementMod (int i, uint ei) |
template<Range Rng> requires InputRange<Rng, Elem*> | |
void | setElements (Rng &&r) |
template<Range Rng> requires InputRange<Rng, uint> | |
void | setElements (Rng &&r) |
bool | containsElement (const Elem *e) const |
bool | containsElement (uint ei) const |
uint | indexOfElement (const Elem *e) const |
uint | indexOfElement (uint ei) const |
Base::Iterator | elementBegin () |
Base::Iterator | elementEnd () |
Base::ConstIterator | elementBegin () const |
Base::ConstIterator | elementEnd () const |
Base::ConstIndexIterator | elementIndexBegin () const |
Base::ConstIndexIterator | elementIndexEnd () const |
View< typename Base::Iterator > | elements () |
View< typename Base::ConstIterator > | elements () const |
View< typename Base::ConstIndexIterator > | elementIndices () const |
void | resize (uint n) |
void | pushBack (Elem *e=nullptr) |
void | pushBack (uint ei) |
void | insert (uint i, Elem *e=nullptr) |
void | insert (uint i, uint ei) |
void | erase (uint i) |
void | clear () |
uint | indexFromPointer (const Elem *v) const |
Elem * | elemFromParent (uint vi) |
const Elem * | elemFromParent (uint vi) const |
Private Types | |
using | Base = ReferenceContainerComponent< STORE_INDICES, VertexReferences< STORE_INDICES, Vertex, N, ParentElemType, VERT >, CompId::VERTEX_REFERENCES, Vertex, N, ParentElemType, VERT, false, false > |
Private Member Functions | |
template<typename Element > | |
void | importIndicesFrom (const Element &e) |
Additional Inherited Members | |
![]() | |
using | Base = std::conditional_t< STORE_INDICES, IndexContainerComponent< DerivedComponent, COMP_ID, Elem, N, ParentElemType, VERT, OPT, TTVN >, PointerContainerComponent< DerivedComponent, COMP_ID, Elem, N, ParentElemType, VERT, OPT, TTVN > > |
The VertexReferences class represents a component that stores a container of indices or pointers to vertices that will be part of an Element (e.g. Face, Edge, Tetrahedron, etc.).
The container of Vertex references is a random access container that could have static or dynamic size, depending on the value of the template argument N (a negative number means dynamic).
For example, if a Face element should represent only triangles, N could be
The member functions of this class will be available in the instance of any Element that will contain this component.
For example, if you have a Face Element f
that has the VertexReferences component, you'll be able to access to this component member functions from f
:
STORE_INDICES | If true, the component will store indices, otherwise pointers to Vertex. |
Vertex | The type of the vertices. |
N | The size of the container, that will represent the number of storable vertices. If negative, the container is dynamic. |
ParentElemType | This type is used to get access to the Element that has the component (and, in case, to the Mesh that has the Element). If the component doesn't need to access the Element, this type can be void. Note: if the component is vertical (or optional), this type cannot be void. |
VERT | If true, the component will be stored vertically. This argument is considered only if the ElementType is not void. |
|
default |
Empty constructor.
If the VertexReferences container size is static, initializes all the pointers/indices to nullptr
/UINT_NULL
, otherwise the container will be empty.
|
inline |
Clears the container of vertices, making it empty.
|
inline |
Returns true
if the container of vertices contains the given vertex, false
otherwise.
[in] | v | the pointer to the vertex to search. |
true
if the container of vertices contains the given vertex, false
otherwise.
|
inline |
Returns true
if the container of vertices contains the vertex with the given index, false
otherwise.
[in] | vi | the index of the vertex to search. |
true
if the container of vertices contains the vertex with the given index, false
otherwise.
|
inline |
Removes the vertex at the given position from the container.
[in] | i | The position of the vertex to remove from this container. |
|
inline |
Returns the index of the given edge composed of the two vertices v1 and v2 in the container of the element.
The order of the two vertices is not important. The index of the edge corresponds to the index of the first vertex found in the container. If the edge formed by the two vertices is not in the container, returns UINT_NULL.
[in] | v1 | the pointer to the first vertex that compose the edge to search. |
[in] | v2 | the pointer to the second vertex that compose the edge to search. |
|
inline |
Returns the index of the edge composed of the two vertices with the given indices in the container of the element.
The order of the two vertices is not important. The index of the edge corresponds to the index of the first vertex found in the container. If the edge formed by the two vertices is not in the container, returns UINT_NULL.
[in] | vi1 | the index of the first vertex that compose the edge to search. |
[in] | vi2 | the index of the second vertex that compose the edge to search. |
|
inline |
Returns the index of the given vertex in the container of the element. If the given vertex is not in the container, returns UINT_NULL.
[in] | v | the pointer to the vertex to search. |
|
inline |
Returns the index of the vertex with the given index in the container of the element. If the vertex with the given index is not in the container, returns UINT_NULL.
[in] | vi | the index of the vertex to search. |
|
inline |
Inserts the vertex with the given index in the container at the given position.
[in] | i | The position in this container where to insert the vertex. |
[in] | vi | The index of the vertex to insert in the container. |
|
inline |
Inserts the given vertex in the container at the given position.
[in] | i | The position in this container where to insert the vertex. |
[in] | v | The pointer to the vertex to insert in the container. |
|
inline |
Pushes in the back of the container the given vertex.
[in] | vi | The index to the vertex to push in the back of the container. |
|
inline |
Pushes in the back of the container the given vertex.
[in] | v | The pointer to the vertex to push in the back of the container. |
|
inline |
Resize the container of the vertices to the given size.
[in] | n | The new size of the vertices container. |
|
inline |
Sets the vertex pointed by the iterator.
[in] | it | the iterator in this container on which set the vertex; the value must be between begin() and end(). |
[in] | vi | The index in the vertex container of the vertex to set. |
|
inline |
Sets the vertex pointed by the iterator.
[in] | it | iterator in this container on which set the vertex; the value must be between begin() and end(). |
[in] | v | The pointer to the vertex to set to the element. |
|
inline |
Sets the vertex pointed by the iterator.
[in] | it | the iterator in this container on which set the vertex; the value must be between begin() and end(). |
[in] | vi | The index in the vertex container of the vertex to set. |
|
inline |
Sets the vertex pointed by the iterator.
[in] | it | the iterator in this container on which set the vertex; the value must be between begin() and end(). |
[in] | v | The pointer to the vertex to set to the element. |
|
inline |
Sets the i-th vertex of the element.
[in] | i | the position in this container on which set the vertex; the value must be between 0 and the number of vertices. |
[in] | vi | The index in the vertex container of the vertex to set. |
|
inline |
Sets the i-th vertex of the element.
[in] | i | the position in this container on which set the vertex; the value must be between 0 and the number of vertices. |
[in] | v | The pointer to the vertex to set to the element. |
|
inline |
Sets the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to set the "next vertex after position k", without check if it is less than the number of vertices. Works also for negative numbers:
[in] | i | the position in this container w.r.t. the position 0 on which set the vertex; value is modularized on vertexNumber(). |
[in] | vi | The index in the vertex container of the vertex to set. |
|
inline |
Sets the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to set the "next vertex after position k", without check if it is less than the number of vertices. Works also for negative numbers:
[in] | i | the position in this container w.r.t. the position 0 on which set the vertex; value is modularized on vertexNumber(). |
[in] | v | The pointer to the vertex to set to the element. |
|
inline |
Sets all the vertex pointers of the element.
If the size of the container is static, the size of the input range must be the same one of the container.
Rng | The type of the range of vertex pointers to set. The value type of the range must be convertible to a pointer to a Vertex. |
[in] | r | range of vertex pointers to set. |
|
inline |
Sets all the vertex pointers of the element.
If the size of the container is static, the size of the input range must be the same one of the container.
Rng | The type of the range of vertex indices to set. The value type of the range must be convertible to unsigned integer. |
[in] | r | range of vertex indices to set. |
|
inline |
Returns the pointer to the i-th vertex of the element.
[in] | i | the position of the required vertex in this container. |
|
inline |
Returns a const pointer to the i-th vertex of the element.
[in] | i | the position of the required vertex in this container; the value must be between 0 and the number of vertices. |
|
inline |
Returns an iterator to the first vertex in the container of this component.
|
inline |
Returns a const iterator to the first vertex in the container of this component.
|
inline |
Returns an iterator to the end of the container of this component.
|
inline |
Returns a const iterator to the end of the container of this component.
|
inline |
Returns the index in the vertex container of the i-th vertex of the element.
[in] | i | the position of the required vertex in this container. |
|
inline |
Returns an iterator to the first vertex index in the container of this component.
|
inline |
Returns an iterator to the end of the container of this component.
|
inline |
Returns the index in the vertex container of the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to get the "index of the vertex next to position k", without check if it is less than the number of vertices. Works also for negative numbers:
[in] | i | the position of the required vertex in this container, w.r.t. the position 0; value is modularized on vertexNumber(). |
|
inline |
Returns a lightweight view object that stores the begin and end iterators of the container of vertex indices of the element. 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:
|
inline |
Returns a reference of the pointer to the i-th vertex of the element, but using as index the module between i and the number of vertices. You can use this function if you need to get the "next vertex after position k", without check if it is less than the number of vertices. Works also for negative numbers:
[in] | i | the position of the required vertex in this container, w.r.t. the position 0; value is modularized on vertexNumber(). |
|
inline |
Same of vertexMod, but returns a const pointer to the vertex.
[in] | i | the position of the required vertex in this container, w.r.t. the position 0; value is modularized on vertexNumber(). |
|
inline |
Returns the number of vertices of the element.
|
inline |
Returns a lightweight view object that stores the begin and end iterators of the container of vertices of the element. 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:
|
inline |
Returns a lightweight const view object that stores the begin and end iterators of the container of vertices of the element. 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: