23#ifndef VCL_MESH_COMPONENTS_VERTEX_REFERENCES_H
24#define VCL_MESH_COMPONENTS_VERTEX_REFERENCES_H
26#include "bases/reference_container_component.h"
28#include <vclib/concepts/mesh/components/vertex_references.h>
29#include <vclib/types/view.h>
86 typename ParentElemType = void,
91 VertexReferences<STORE_INDICES, Vertex, N, ParentElemType, VERT>,
92 CompId::VERTEX_REFERENCES,
103 CompId::VERTEX_REFERENCES,
119 using VertexIterator = Base::Iterator;
120 using ConstVertexIterator = Base::ConstIterator;
121 using ConstVertexIndexIterator = Base::ConstIndexIterator;
124 static const int VERTEX_NUMBER = Base::SIZE;
242 Base::setElement(
it, v);
253 Base::setElement(
it,
vi);
264 Base::setElement(
it, v);
275 Base::setElement(
it,
vi);
332 Base::setElements(
r);
349 Base::setElements(
r);
362 return Base::containsElement(v);
386 return Base::indexOfElement(v);
420 Base::indexFromPointer(v1), Base::indexFromPointer(v2));
432 return (((
int)
vid - 1) %
n +
n) %
n;
468 return (((
int)
vid - 1) %
n +
n) %
n;
476 Base::elemFromParent(
vi1), Base::elemFromParent(
vi2));
561 VertexIterator
vertexEnd() {
return Base::elementEnd(); }
569 ConstVertexIterator
vertexBegin()
const {
return Base::elementBegin(); }
577 ConstVertexIterator
vertexEnd()
const {
return Base::elementEnd(); }
587 return Base::elementIndexBegin();
597 return Base::elementIndexEnd();
654 return Base::elementIndices();
659 template<
typename Element>
664 if constexpr (N > 0) {
666 if constexpr (N == Element::VERTEX_NUMBER) {
667 importIndicesFrom(e);
671 else if constexpr (Element::VERTEX_NUMBER < 0) {
672 if (e.vertexNumber() == N) {
673 importIndicesFrom(e);
685 importIndicesFrom(e);
691 void serialize(std::ostream& os)
const
695 if constexpr (N < 0) {
703 void deserialize(std::istream& is)
705 if constexpr (N < 0) {
707 vcl::deserialize(is, n);
712 vcl::deserialize(is, vi);
718 template<
typename Element>
719 void importIndicesFrom(
const Element& e)
721 for (uint i = 0; i < e.vertexNumber(); ++i) {
The Element class.
Definition element.h:57
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
The Vertex class represents an Vertex element of the vcl::Mesh class.
Definition vertex.h:47
The ReferenceContainerComponent is a class that inherits from the IndexContainerComponent or PointerC...
Definition reference_container_component.h:99
The VertexReferences class represents a component that stores a container of indices or pointers to v...
Definition vertex_references.h:99
void setVertex(ConstVertexIterator it, uint vi)
Sets the vertex pointed by the iterator.
Definition vertex_references.h:251
Vertex * vertexMod(int i)
Returns a reference of the pointer to the i-th vertex of the element, but using as index the module b...
Definition vertex_references.h:187
void setVertex(uint i, uint vi)
Sets the i-th vertex of the element.
Definition vertex_references.h:232
void pushVertex(uint vi)
Pushes in the back of the container the given vertex.
Definition vertex_references.h:506
void setVertex(uint i, Vertex *v)
Sets the i-th vertex of the element.
Definition vertex_references.h:224
View< ConstVertexIterator > vertices() const
Returns a lightweight const view object that stores the begin and end iterators of the container of v...
Definition vertex_references.h:634
bool containsVertex(uint vi) const
Returns true if the container of vertices contains the vertex with the given index,...
Definition vertex_references.h:373
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 vertic...
Definition vertex_references.h:296
void setVertex(ConstVertexIterator it, Vertex *v)
Sets the vertex pointed by the iterator.
Definition vertex_references.h:240
VertexReferences()=default
Empty constructor.
ConstVertexIterator vertexEnd() const
Returns a const iterator to the end of the container of this component.
Definition vertex_references.h:577
ConstVertexIndexIterator vertexIndexEnd() const
Returns an iterator to the end of the container of this component.
Definition vertex_references.h:595
void setVertices(Rng &&r)
Sets all the vertex pointers of the element.
Definition vertex_references.h:330
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 ...
Definition vertex_references.h:384
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 el...
Definition vertex_references.h:416
ConstVertexIndexIterator vertexIndexBegin() const
Returns an iterator to the first vertex index in the container of this component.
Definition vertex_references.h:585
View< VertexIterator > vertices()
Returns a lightweight view object that stores the begin and end iterators of the container of vertice...
Definition vertex_references.h:616
void clearVertices()
Clears the container of vertices, making it empty.
Definition vertex_references.h:543
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...
Definition vertex_references.h:456
void pushVertex(Vertex *v)
Pushes in the back of the container the given vertex.
Definition vertex_references.h:497
uint vertexNumber() const
Returns the number of vertices of the element.
Definition vertex_references.h:143
uint indexOfVertex(uint vi) const
Returns the index of the vertex with the given index in the container of the element....
Definition vertex_references.h:398
uint vertexIndex(uint i) const
Returns the index in the vertex container of the i-th vertex of the element.
Definition vertex_references.h:167
void resizeVertices(uint n)
Resize the container of the vertices to the given size.
Definition vertex_references.h:488
const Vertex * vertexMod(int i) const
Same of vertexMod, but returns a const pointer to the vertex.
Definition vertex_references.h:195
VertexIterator vertexBegin()
Returns an iterator to the first vertex in the container of this component.
Definition vertex_references.h:553
void eraseVertex(uint i)
Removes the vertex at the given position from the container.
Definition vertex_references.h:536
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 vertic...
Definition vertex_references.h:316
void insertVertex(uint i, Vertex *v)
Inserts the given vertex in the container at the given position.
Definition vertex_references.h:515
ConstVertexIterator vertexBegin() const
Returns a const iterator to the first vertex in the container of this component.
Definition vertex_references.h:569
VertexIterator vertexEnd()
Returns an iterator to the end of the container of this component.
Definition vertex_references.h:561
View< ConstVertexIndexIterator > vertexIndices() const
Returns a lightweight view object that stores the begin and end iterators of the container of vertex ...
Definition vertex_references.h:652
void insertVertex(uint i, uint vi)
Inserts the vertex with the given index in the container at the given position.
Definition vertex_references.h:528
void setVertex(ConstVertexIndexIterator it, uint vi)
Sets the vertex pointed by the iterator.
Definition vertex_references.h:273
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 m...
Definition vertex_references.h:216
const Vertex * vertex(uint i) const
Returns a const pointer to the i-th vertex of the element.
Definition vertex_references.h:159
void setVertices(Rng &&r)
Sets all the vertex pointers of the element.
Definition vertex_references.h:347
void setVertex(ConstVertexIndexIterator it, Vertex *v)
Sets the vertex pointed by the iterator.
Definition vertex_references.h:262
bool containsVertex(const Vertex *v) const
Returns true if the container of vertices contains the given vertex, false otherwise.
Definition vertex_references.h:360
Vertex * vertex(uint i)
Returns the pointer to the i-th vertex of the element.
Definition vertex_references.h:151
HasVertexReferences concept is satisfied only if a Element class provides the types and member functi...
Definition vertex_references.h:43
constexpr uint UINT_NULL
The UINT_NULL value represent a null value of uint that is the maximum value that can be represented ...
Definition base.h:48