23#ifndef VCL_MESH_COMPONENTS_ADJACENT_EDGES_H
24#define VCL_MESH_COMPONENTS_ADJACENT_EDGES_H
26#include "bases/reference_container_component.h"
28#include <vclib/concepts/mesh/components/adjacent_edges.h>
29#include <vclib/types/view.h>
84 typename ParentElemType = void,
98 CompId::ADJACENT_EDGES,
109 CompId::ADJACENT_EDGES,
125 using AdjacentEdgeIterator = Base::Iterator;
126 using ConstAdjacentEdgeIterator = Base::ConstIterator;
127 using ConstAdjacentEdgeIndexIterator = Base::ConstIndexIterator;
258 Base::setElement(
it, e);
269 Base::setElement(
it,
ei);
280 Base::setElement(
it, e);
291 Base::setElement(
it,
ei);
350 Base::setElements(
r);
367 Base::setElements(
r);
380 return Base::containsElement(e);
505 AdjacentEdgeIterator
adjEdgeEnd() {
return Base::elementEnd(); }
515 return Base::elementBegin();
524 ConstAdjacentEdgeIterator
adjEdgeEnd()
const {
return Base::elementEnd(); }
534 return Base::elementIndexBegin();
544 return Base::elementIndexEnd();
583 return Base::elements();
604 return Base::elementIndices();
609 template<
typename Element>
614 if (isAdjacentEdgesAvailableOn(e)) {
615 if constexpr (N > 0) {
617 if constexpr (N == Element::ADJ_EDGE_NUMBER) {
618 importIndicesFrom(e);
622 else if constexpr (Element::ADJ_EDGE_NUMBER < 0) {
623 if (e.adjEdgesNumber() == N) {
624 importIndicesFrom(e);
635 Base::resize(e.adjEdgesNumber());
636 importIndicesFrom(e);
643 void serialize(std::ostream& os)
const
647 if constexpr (N < 0) {
655 void deserialize(std::istream& is)
657 if constexpr (N < 0) {
659 vcl::deserialize(is, n);
664 vcl::deserialize(is, aei);
670 template<
typename Element>
671 void importIndicesFrom(
const Element& e)
673 for (uint i = 0; i < e.adjEdgesNumber(); ++i) {
692bool isAdjacentEdgesAvailableOn(
const ElementConcept
auto& element)
694 return isComponentAvailableOn<CompId::ADJACENT_EDGES>(element);
The Edge class represents an Edge element of the vcl::Mesh class.
Definition edge.h:48
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 AdjacentEdges class is a container of Edge indices or pointers. It could be used by any Element t...
Definition adjacent_edges.h:105
void setAdjEdge(ConstAdjacentEdgeIndexIterator it, uint ei)
Sets the adjacent edge pointed by the iterator.
Definition adjacent_edges.h:289
ConstAdjacentEdgeIndexIterator adjEdgeIndexBegin() const
Returns an iterator to the first adjacent edge index in the container of this component.
Definition adjacent_edges.h:532
AdjacentEdges()=default
Empty constructor.
Edge * adjEdgeMod(int i)
Returns the pointer to the i-th adjacent edge of the element but using as index the module between i ...
Definition adjacent_edges.h:199
void setAdjEdge(uint i, uint ei)
Sets the i-th adjacent edge of the element.
Definition adjacent_edges.h:248
uint adjEdgeIndex(uint i) const
Returns the index in the edge container of the i-th adjacent edge of the element.
Definition adjacent_edges.h:177
const Edge * adjEdgeMod(int i) const
Same of adjEdgeMod, but returns a const Pointer to the adjacent edge.
Definition adjacent_edges.h:209
void insertAdjEdge(uint i, uint ei)
Inserts the adjacent edge with the given index in the container at the given position.
Definition adjacent_edges.h:467
void eraseAdjEdge(uint i)
Removes the adjacent edge at the given position from the container.
Definition adjacent_edges.h:480
ConstAdjacentEdgeIterator adjEdgeBegin() const
Returns a const iterator to the first adjacent edge in the container of this component.
Definition adjacent_edges.h:513
const Edge * adjEdge(uint i) const
Returns a const pointer to the i-th adjacent edge of the element.
Definition adjacent_edges.h:169
void setAdjEdges(Rng &&r)
Sets all the adjacent edges of the element.
Definition adjacent_edges.h:348
View< AdjacentEdgeIterator > adjEdges()
Returns a lightweight view object that stores the begin and end iterators of the container of adjacen...
Definition adjacent_edges.h:563
bool containsAdjEdge(uint ei) const
Returns true if the container of adjacent edges contains the given index, false otherwise.
Definition adjacent_edges.h:391
View< ConstAdjacentEdgeIndexIterator > adjEdgeIndices() const
Returns a lightweight view object that stores the begin and end iterators of the container of adjacen...
Definition adjacent_edges.h:602
void pushAdjEdge(uint ei)
Pushes in the back of the container the given adjacent edge.
Definition adjacent_edges.h:441
void resizeAdjEdges(uint n)
Resize the container of the adjacent edges to the given size.
Definition adjacent_edges.h:423
AdjacentEdgeIterator adjEdgeBegin()
Returns an iterator to the first adjacent edge in the container of this component.
Definition adjacent_edges.h:497
ConstAdjacentEdgeIterator adjEdgeEnd() const
Returns a const iterator to the end of the container of this component.
Definition adjacent_edges.h:524
bool containsAdjEdge(const Edge *e) const
Returns true if the container of adjacent edges contains the given edge, false otherwise.
Definition adjacent_edges.h:378
View< ConstAdjacentEdgeIterator > adjEdges() const
Returns a lightweight const view object that stores the begin and end iterators of the container of a...
Definition adjacent_edges.h:581
static const int ADJ_EDGE_NUMBER
Static size of the container. If the container is dynamic, this value will be negative and you should...
Definition adjacent_edges.h:134
Edge * adjEdge(uint i)
Returns the pointer to the i-th adjacent edge of the element.
Definition adjacent_edges.h:161
void pushAdjEdge(Edge *e)
Pushes in the back of the container the given adjacent edge.
Definition adjacent_edges.h:432
void setAdjEdge(ConstAdjacentEdgeIterator it, Edge *e)
Sets the adjacent edge pointed by the iterator.
Definition adjacent_edges.h:256
void clearAdjEdges()
Clears the container of adjacent edges, making it empty.
Definition adjacent_edges.h:487
void setAdjEdges(Rng &&r)
Sets all the adjacent edges of the element.
Definition adjacent_edges.h:365
void setAdjEdge(ConstAdjacentEdgeIterator it, uint ei)
Sets the adjacent edge pointed by the iterator.
Definition adjacent_edges.h:267
uint adjEdgesNumber() const
Returns the number of adjacent edges of this element.
Definition adjacent_edges.h:152
void setAdjEdge(ConstAdjacentEdgeIndexIterator it, Edge *e)
Sets the adjacent edge pointed by the iterator.
Definition adjacent_edges.h:278
ConstAdjacentEdgeIndexIterator adjEdgeIndexEnd() const
Returns an iterator to the end of the container of this component.
Definition adjacent_edges.h:542
AdjacentEdgeIterator adjEdgeEnd()
Returns an iterator to the end of the container of this component.
Definition adjacent_edges.h:505
void insertAdjEdge(uint i, Edge *e)
Inserts the given adjacent edge in the container at the given position.
Definition adjacent_edges.h:453
uint indexOfAdjEdge(uint ei) const
Returns the index of the adjacent edge with the given index in the container of the element....
Definition adjacent_edges.h:413
uint adjEdgeIndexMod(int i) const
Returns the index in the edge container of the i-th adjacent edge of the element, but using as index ...
Definition adjacent_edges.h:231
void setAdjEdge(uint i, Edge *e)
Sets the i-th adjacent edge of the element.
Definition adjacent_edges.h:239
void setAdjEdgeMod(int i, Edge *e)
Sets the i-th adjacent edge of the element, but using as index the module between i and the number of...
Definition adjacent_edges.h:313
uint indexOfAdjEdge(const Edge *e) const
Returns the index of the given adjacent edge in the container of the element. If the given adjacent e...
Definition adjacent_edges.h:402
void setAdjEdgeMod(int i, uint ei)
Sets the i-th adjacent edge of the element, but using as index the module between i and the number of...
Definition adjacent_edges.h:334
The ReferenceContainerComponent is a class that inherits from the IndexContainerComponent or PointerC...
Definition reference_container_component.h:99
HasAdjacentEdges concept is satisfied only if a Element class provides the types and member functions...
Definition adjacent_edges.h:51