23#ifndef VCL_MESH_COMPONENTS_VERTEX_REFERENCES_H
24#define VCL_MESH_COMPONENTS_VERTEX_REFERENCES_H
26#include "base/predicates.h"
27#include "base/reference_container_component.h"
29#include <vclib/base.h>
86 typename ParentElemType = void,
89 public ReferenceContainerComponent<
91 VertexReferences<STORE_INDICES, Vertex, N, ParentElemType, VERT>,
92 CompId::VERTEX_REFERENCES,
100 using Base = ReferenceContainerComponent<
103 CompId::VERTEX_REFERENCES,
119 using VertexIterator = Base::Iterator;
120 using ConstVertexIterator = Base::ConstIterator;
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);
432 return (((
int)
vid - 1) %
n +
n) %
n;
468 return (((
int)
vid - 1) %
n +
n) %
n;
659 template<
typename Element>
662 void serialize(std::ostream&
os)
const
666 if constexpr (N < 0) {
674 void deserialize(std::istream& is)
676 if constexpr (N < 0) {
678 vcl::deserialize(is, n);
683 vcl::deserialize(is, vi);
689 template<
typename Element>
690 void importIndicesFrom(
const Element& e)
692 for (uint i = 0; i < e.vertexNumber(); ++i) {
713 BTITB::IsDerivedFromSpecializationOfV<T, VertexReferences>;
721 typename ParentElemType,
723template<
typename Element>
724void VertexReferences<STORE_INDICES, Vertex, N, ParentElemType, VERT>::
725 importFrom(
const Element& e,
bool importRefs)
729 if constexpr (N > 0) {
731 if constexpr (N == Element::VERTEX_NUMBER) {
732 importIndicesFrom(e);
736 else if constexpr (Element::VERTEX_NUMBER < 0) {
737 if (e.vertexNumber() == N) {
738 importIndicesFrom(e);
749 resizeVertices(e.vertexNumber());
750 importIndicesFrom(e);
A class representing a box in N-dimensional space.
Definition box.h:46
Box()
The Empty constructor of a box, initializes a null box.
Definition box.h:65
PointT size() const
Computes the size of the box.
Definition box.h:267
The Element class.
Definition element.h:75
The Vertex class represents an Vertex element of the vcl::Mesh class.
Definition vertex.h:46
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
A concept that checks whether a type T (that should be a Element) has the VertexReferences component ...
Definition vertex_references.h:712
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