MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
mesh_info.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef MVE_VERTEX_INFO_HEADER
11#define MVE_VERTEX_INFO_HEADER
12
13#include <algorithm>
14#include <vector>
15#include <memory>
16
17#include "mve/defines.h"
18#include "mve/mesh.h"
19
21
23{
24public:
37
38 typedef std::vector<std::size_t> AdjacentVertices;
39 typedef std::vector<std::size_t> AdjacentFaces;
40
43 {
47
48 void remove_adjacent_face (std::size_t face_id);
49 void remove_adjacent_vertex (std::size_t vertex_id);
50 void replace_adjacent_face (std::size_t old_id, std::size_t new_id);
51 void replace_adjacent_vertex (std::size_t old_id, std::size_t new_id);
52 };
53
54public:
56 MeshInfo (void);
57
60
62 void initialize (TriangleMesh::ConstPtr mesh);
63
69 void update_vertex (TriangleMesh const& mesh, std::size_t vertex_id);
70
72 bool is_mesh_edge (std::size_t v1, std::size_t v2) const;
73
75 void get_faces_for_edge (std::size_t v1, std::size_t v2,
76 std::vector<std::size_t>* adjacent_faces) const;
77
78public:
79 VertexInfo& operator[] (std::size_t id);
80 VertexInfo const& operator[] (std::size_t id) const;
81 VertexInfo& at (std::size_t id);
82 VertexInfo const& at (std::size_t id) const;
83 std::size_t size (void) const;
84 void clear (void);
85
86private:
87 std::vector<VertexInfo> vertex_info;
88};
89
90/* ------------------------- Implementation ----------------------- */
91
92inline
93MeshInfo::MeshInfo (void)
94{
95}
96
97inline
98MeshInfo::MeshInfo (TriangleMesh::ConstPtr mesh)
99{
100 this->initialize(mesh);
101}
102
104MeshInfo::operator[] (std::size_t id)
105{
106 return this->vertex_info[id];
107}
108
109inline MeshInfo::VertexInfo const&
110MeshInfo::operator[] (std::size_t id) const
111{
112 return this->vertex_info[id];
113}
114
116MeshInfo::at (std::size_t id)
117{
118 return this->vertex_info[id];
119}
120
121inline MeshInfo::VertexInfo const&
122MeshInfo::at (std::size_t id) const
123{
124 return this->vertex_info[id];
125}
126
127inline std::size_t
128MeshInfo::size (void) const
129{
130 return this->vertex_info.size();
131}
132
133inline void
134MeshInfo::clear (void)
135{
136 std::vector<VertexInfo>().swap(this->vertex_info);
137}
138
139inline void
140MeshInfo::VertexInfo::remove_adjacent_face (std::size_t face_id)
141{
142 this->faces.erase(std::remove(this->faces.begin(), this->faces.end(),
143 face_id), this->faces.end());
144}
145
146inline void
147MeshInfo::VertexInfo::remove_adjacent_vertex (std::size_t vertex_id)
148{
149 this->verts.erase(std::remove(this->verts.begin(), this->verts.end(),
150 vertex_id), this->verts.end());
151}
152
153inline void
154MeshInfo::VertexInfo::replace_adjacent_face (std::size_t old_id,
155 std::size_t new_id)
156{
157 std::replace(this->faces.begin(), this->faces.end(), old_id, new_id);
158}
159
160inline void
161MeshInfo::VertexInfo::replace_adjacent_vertex (std::size_t old_id,
162 std::size_t new_id)
163{
164 std::replace(this->verts.begin(), this->verts.end(), old_id, new_id);
165}
166
168
169#endif /* MVE_VERTEX_INFO_HEADER */
std::vector< std::size_t > AdjacentVertices
Definition mesh_info.h:38
std::vector< std::size_t > AdjacentFaces
Definition mesh_info.h:39
VertexClass
Vertex classification according to adjacent triangles.
Definition mesh_info.h:27
@ VERTEX_CLASS_COMPLEX
Vertex with more than one triangle fan.
Definition mesh_info.h:33
@ VERTEX_CLASS_BORDER
Vertex with a single but open fan of triangles.
Definition mesh_info.h:31
@ VERTEX_CLASS_SIMPLE
Vertex with a single closed fan of adjacent triangles.
Definition mesh_info.h:29
Triangle mesh representation.
Definition mesh.h:90
std::shared_ptr< TriangleMesh const > ConstPtr
Definition mesh.h:93
std::size_t face_id
Definition mesh_info.cc:45
unsigned int vertex_id
#define MVE_NAMESPACE_BEGIN
Definition defines.h:13
#define MVE_NAMESPACE_END
Definition defines.h:14
Per-vertex classification and adjacency information.
Definition mesh_info.h:43
AdjacentVertices verts
Definition mesh_info.h:45