23#ifndef VCL_ALGORITHMS_MESH_UPDATE_TOPOLOGY_H
24#define VCL_ALGORITHMS_MESH_UPDATE_TOPOLOGY_H
26#include <vclib/algorithms/mesh/sort.h>
28#include <vclib/mesh.h>
45template<MeshConcept MeshType>
46void clearPerVertexAdjacentFaces(MeshType& m)
48 requirePerVertexAdjacentFaces(m);
50 using VertexType = MeshType::VertexType;
68template<FaceMeshConcept MeshType>
69void updatePerVertexAdjacentFaces(MeshType& m)
71 clearPerVertexAdjacentFaces(m);
73 using VertexType = MeshType::VertexType;
74 using FaceType = MeshType::FaceType;
80 for (FaceType& f : m.
faces()) {
100template<MeshConcept MeshType>
101void clearPerVertexAdjacentVertices(MeshType& m)
103 requirePerVertexAdjacentVertices(m);
105 using VertexType = MeshType::VertexType;
107 for (VertexType& v : m.
vertices()) {
108 v.clearAdjVertices();
123template<FaceMeshConcept MeshType>
124void updatePerVertexAdjacentVertices(MeshType& m)
126 clearPerVertexAdjacentVertices(m);
128 using VertexType = MeshType::VertexType;
134 std::vector<MeshEdgeUtil<MeshType>> vec = fillAndSortMeshEdgeUtilVector(m);
137 VertexType* v1 =
nullptr;
138 VertexType* v2 =
nullptr;
139 for (uint i = 0; i < vec.size(); ++i) {
141 if (vec[i].v[0] != v1 || vec[i].v[1] != v2) {
145 v1->pushAdjVertex(v2);
146 v2->pushAdjVertex(v1);
165template<FaceMeshConcept MeshType>
166void clearPerFaceAdjacentFaces(MeshType& m)
170 using FaceType = MeshType::FaceType;
172 for (FaceType& f : m.
faces()) {
173 for (uint i = 0; i < f.adjFacesNumber(); ++i) {
174 f.setAdjFace(i,
nullptr);
223template<FaceMeshConcept MeshType>
224void updatePerFaceAdjacentFaces(MeshType& m)
232 std::vector<MeshEdgeUtil<MeshType>> vec = fillAndSortMeshEdgeUtilVector(m);
234 if (vec.size() > 0) {
238 for (
auto base = vec.begin(); base != vec.end();) {
246 if (j != vec.end()) {
249 i->f->setAdjFace(i->e,
nullptr);
252 while (j != vec.end() && *i == *j) {
253 i->f->setAdjFace(i->e, j->f);
258 i->f->setAdjFace(i->e, first->f);
void requirePerFaceAdjacentFaces(const MeshType &m)
This function asserts that a Mesh has a FaceContainer, the Face has a AdjacentFaces Component,...
Definition face_requirements.h:960
constexpr detail::FacesView faces
A view that allows to iterate overt the Face elements of an object.
Definition face.h:84
constexpr detail::VerticesView vertices
A view that allows to iterate over the Vertex elements of an object.
Definition vertex.h:92