Visual Computing Library  devel
Loading...
Searching...
No Matches
mesh_edge_util.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_SPACE_COMPLEX_MESH_EDGE_UTIL_H
24#define VCL_SPACE_COMPLEX_MESH_EDGE_UTIL_H
25
26#include <vclib/mesh.h>
27#include <vclib/base.h>
28
29namespace vcl {
30
49template<FaceMeshConcept MeshType, bool CNST = false>
51{
52 using VertexType = std::conditional_t<
53 CNST,
54 const typename MeshType::VertexType,
55 typename MeshType::VertexType>;
56 using FaceType = std::conditional_t<
57 CNST,
58 const typename MeshType::FaceType,
59 typename MeshType::FaceType>;
60
61public:
62 VertexType* v[2]; // Pointer to the two (ordered) vertices of the edge
63 FaceType* f; // Pointer to the face of the edge
64 int e; // Index of the edge inside the face
65
66 MeshEdgeUtil() : v {nullptr, nullptr}, f(nullptr), e(-1) {}
67
68 MeshEdgeUtil(FaceType& pf, uint ne)
69 {
70 v[0] = pf.vertex(ne);
71 v[1] = pf.vertexMod(ne + 1);
72 assert(v[0] != v[1]);
73
74 if (v[0] > v[1])
75 std::swap(v[0], v[1]);
76 f = &pf;
77 e = ne;
78 }
79
80 bool operator<(const MeshEdgeUtil& pe) const
81 {
82 if (v[0] < pe.v[0])
83 return true;
84 else if (v[0] > pe.v[0])
85 return false;
86 else
87 return v[1] < pe.v[1];
88 }
89
90 bool operator==(const MeshEdgeUtil& pe) const
91 {
92 return v[0] == pe.v[0] && v[1] == pe.v[1];
93 }
94
95 bool operator!=(const MeshEdgeUtil& pe) const
96 {
97 return v[0] != pe.v[0] || v[1] != pe.v[1];
98 }
99};
100
106template<FaceMeshConcept MeshType>
108
109} // namespace vcl
110
111#endif // VCL_SPACE_COMPLEX_MESH_EDGE_UTIL_H
A class representing a box in N-dimensional space.
Definition box.h:46
Utility class that represents a edge in a Mesh having Vertices and Faces.
Definition mesh_edge_util.h:51