23#ifndef VCL_MESH_COMPONENTS_ADJACENT_FACES_H
24#define VCL_MESH_COMPONENTS_ADJACENT_FACES_H
26#include "bases/reference_container_component.h"
28#include <vclib/concepts/mesh/components/adjacent_faces.h>
29#include <vclib/types/view.h>
84 typename ParentElemType = void,
98 CompId::ADJACENT_FACES,
109 CompId::ADJACENT_FACES,
125 using AdjacentFaceIterator = Base::Iterator;
126 using ConstAdjacentFaceIterator = Base::ConstIterator;
127 using ConstAdjacentFaceIndexIterator = Base::ConstIndexIterator;
258 Base::setElement(
it, f);
269 Base::setElement(
it,
fi);
280 Base::setElement(
it, f);
291 Base::setElement(
it,
fi);
350 Base::setElements(
r);
367 Base::setElements(
r);
380 return Base::containsElement(f);
505 AdjacentFaceIterator
adjFaceEnd() {
return Base::elementEnd(); }
515 return Base::elementBegin();
524 ConstAdjacentFaceIterator
adjFaceEnd()
const {
return Base::elementEnd(); }
534 return Base::elementIndexBegin();
544 return Base::elementIndexEnd();
583 return Base::elements();
604 return Base::elementIndices();
609 void __adjacentFaces()
const {}
613 template<
typename Element>
618 if (isAdjacentFacesAvailableOn(e)) {
619 if constexpr (N > 0) {
621 if constexpr (N == Element::ADJ_FACE_NUMBER) {
622 importIndicesFrom(e);
626 else if constexpr (Element::ADJ_FACE_NUMBER < 0) {
627 if (e.adjFacesNumber() == N) {
628 importIndicesFrom(e);
639 Base::resize(e.adjFacesNumber());
640 importIndicesFrom(e);
647 void serialize(std::ostream& os)
const
651 if constexpr (N < 0) {
659 void deserialize(std::istream& is)
661 if constexpr (N < 0) {
663 vcl::deserialize(is, n);
668 vcl::deserialize(is, afi);
674 template<
typename Element>
675 void importIndicesFrom(
const Element& e)
677 for (uint i = 0; i < e.adjFacesNumber(); ++i) {
696bool isAdjacentFacesAvailableOn(
const ElementConcept
auto& element)
698 return isComponentAvailableOn<CompId::ADJACENT_FACES>(element);
The Element class.
Definition element.h:57
The Face class represents an Face element of the vcl::Mesh class.
Definition face.h:49
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
The AdjacentFaces class is a container of Face indices or pointers. It could be used by any Element t...
Definition adjacent_faces.h:105
View< ConstAdjacentFaceIndexIterator > adjFaceIndices() const
Returns a lightweight view object that stores the begin and end iterators of the container of adjacen...
Definition adjacent_faces.h:602
ConstAdjacentFaceIndexIterator adjFaceIndexEnd() const
Returns an iterator to the end of the container of this component.
Definition adjacent_faces.h:542
void setAdjFaces(Rng &&r)
Sets all the adjacent faces of this element.
Definition adjacent_faces.h:365
ConstAdjacentFaceIterator adjFaceBegin() const
Returns a const iterator to the first adjacent face in the container of this component.
Definition adjacent_faces.h:513
ConstAdjacentFaceIterator adjFaceEnd() const
Returns a const iterator to the end of the container of this component.
Definition adjacent_faces.h:524
void setAdjFace(uint i, uint fi)
Sets the i-th adjacent face of the element.
Definition adjacent_faces.h:248
Face * adjFaceMod(int i)
Returns the pointer to the i-th adjacent face of this element but using as index the module between i...
Definition adjacent_faces.h:200
View< ConstAdjacentFaceIterator > adjFaces() const
Returns a lightweight const view object that stores the begin and end iterators of the container of a...
Definition adjacent_faces.h:581
void setAdjFace(ConstAdjacentFaceIterator it, uint fi)
Sets the adjacent face pointed by the iterator.
Definition adjacent_faces.h:267
void setAdjFaceMod(int i, Face *f)
Sets the i-th adjacent face of the element, but using as index the module between i and the number of...
Definition adjacent_faces.h:313
uint adjFacesNumber() const
Returns the number of adjacent faces of this element.
Definition adjacent_faces.h:152
void setAdjFace(ConstAdjacentFaceIndexIterator it, Face *f)
Sets the adjacent face pointed by the iterator.
Definition adjacent_faces.h:278
void pushAdjFace(Face *f)
Pushes in the back of the container the given adjacent face.
Definition adjacent_faces.h:432
void setAdjFace(ConstAdjacentFaceIterator it, Face *f)
Sets the adjacent face pointed by the iterator.
Definition adjacent_faces.h:256
AdjacentFaceIterator adjFaceBegin()
Returns an iterator to the first adjacent face in the container of this component.
Definition adjacent_faces.h:497
uint adjFaceIndex(uint i) const
Returns the index in the face container of the i-th adjacent face of the element.
Definition adjacent_faces.h:177
static const int ADJ_FACE_NUMBER
Static size of the container. If the container is dynamic, this value will be negative and you should...
Definition adjacent_faces.h:134
uint indexOfAdjFace(const Face *f) const
Returns the index of the given adjacent face in the container of this element. If the given adjacent ...
Definition adjacent_faces.h:402
uint indexOfAdjFace(uint fi) const
Returns the index of the adjacent face with the given index in the container of this element....
Definition adjacent_faces.h:413
const Face * adjFace(uint i) const
Returns a const pointer to the i-th adjacent face of this element.
Definition adjacent_faces.h:169
View< AdjacentFaceIterator > adjFaces()
Returns a lightweight view object that stores the begin and end iterators of the container of adjacen...
Definition adjacent_faces.h:563
void pushAdjFace(uint fi)
Pushes in the back of the container the given adjacent face.
Definition adjacent_faces.h:441
bool containsAdjFace(const Face *f) const
Returns true if the container of adjacent faces contains the given face, false otherwise.
Definition adjacent_faces.h:378
void resizeAdjFaces(uint n)
Resize the container of the adjacent faces to the given size.
Definition adjacent_faces.h:423
void clearAdjFaces()
Clears the container of adjacent faces, making it empty.
Definition adjacent_faces.h:487
const Face * adjFaceMod(int i) const
Same of adjFaceMod, but returns a const Pointer to the adjacent face.
Definition adjacent_faces.h:210
void setAdjFaceMod(int i, uint fi)
Sets the i-th adjacent face of the element, but using as index the module between i and the number of...
Definition adjacent_faces.h:334
ConstAdjacentFaceIndexIterator adjFaceIndexBegin() const
Returns an iterator to the first adjacent face index in the container of this component.
Definition adjacent_faces.h:532
Face * adjFace(uint i)
Returns the pointer to the i-th adjacent face of this element.
Definition adjacent_faces.h:161
void setAdjFace(uint i, Face *f)
Sets the i-th adjacent face of this element.
Definition adjacent_faces.h:240
void setAdjFaces(Rng &&r)
Sets all the adjacent faces of this element.
Definition adjacent_faces.h:348
AdjacentFaces()=default
Empty constructor.
uint adjFaceIndexMod(int i) const
Returns the index in the face container of the i-th adjacent face of the element, but using as index ...
Definition adjacent_faces.h:232
bool containsAdjFace(uint fi) const
Returns true if the container of adjacent faces contains the face with the given index,...
Definition adjacent_faces.h:391
void setAdjFace(ConstAdjacentFaceIndexIterator it, uint fi)
Sets the adjacent face pointed by the iterator.
Definition adjacent_faces.h:289
void insertAdjFace(uint i, Face *f)
Inserts the given adjacent face in the container at the given position.
Definition adjacent_faces.h:453
AdjacentFaceIterator adjFaceEnd()
Returns an iterator to the end of the container of this component.
Definition adjacent_faces.h:505
void insertAdjFace(uint i, uint fi)
Inserts the adjacent face with the given index in the container at the given position.
Definition adjacent_faces.h:467
void eraseAdjFace(uint i)
Removes the adjacent face at the given position from the container.
Definition adjacent_faces.h:480
The ReferenceContainerComponent is a class that inherits from the IndexContainerComponent or PointerC...
Definition reference_container_component.h:99