This example shows how to access the adjacency information of a surface mesh, i.e.,
27#include <easy3d/core/surface_mesh.h>
28#include <easy3d/util/initializer.h>
62 mesh->add_triangle(v0, v1, v3);
63 mesh->add_triangle(v1, v2, v3);
64 mesh->add_triangle(v2, v0, v3);
65 mesh->add_triangle(v0, v2, v1);
71int main(
int argc,
char** argv) {
76 SurfaceMesh* mesh = old_mesh_from_previous_example();
78 std::cout <<
"----------------------------------------\n";
79 std::cout <<
"The incident vertices of each vertex" << std::endl;
80 std::cout <<
"----------------------------------------\n";
83 for (
auto v : mesh->vertices()) {
84 std::cout <<
"incident vertices of vertex " << v <<
": ";
87 for (
auto vv : mesh->vertices(v))
88 std::cout << vv <<
" ";
94 std::cout << vv <<
" ";
98 std::cout << std::endl;
101 std::cout <<
"\n--------------------------------------\n";
102 std::cout <<
"The incident outgoing/ingoing edges of each vertex" << std::endl;
103 std::cout <<
"----------------------------------------\n";
106 for (
auto v : mesh->vertices()) {
107 std::cout <<
"incident outgoing/ingoing edges of vertex " << v <<
": ";
110 for (
auto h : mesh->halfedges(v))
111 std::cout << h <<
"/" << mesh->opposite(h) <<
" ";
117 std::cout << h <<
"/" << mesh->opposite(h) <<
" ";
119 }
while (cir != end);
121 std::cout << std::endl;
124 std::cout <<
"\n--------------------------------------\n";
125 std::cout <<
"The incident faces of each vertex" << std::endl;
126 std::cout <<
"----------------------------------------\n";
129 for (
auto v : mesh->vertices()) {
130 std::cout <<
"incident faces of vertex " << v <<
": ";
133 for (
auto f : mesh->faces(v))
134 std::cout << f <<
" ";
140 std::cout << f <<
" ";
142 }
while (cir != end);
144 std::cout << std::endl;
147 std::cout <<
"\n--------------------------------------\n";
148 std::cout <<
"The incident vertices of each face" << std::endl;
149 std::cout <<
"----------------------------------------\n";
152 for (
auto f : mesh->faces()) {
153 std::cout <<
"incident vertices of face " << f <<
": ";
156 for (
auto v : mesh->vertices(f))
157 std::cout << v <<
" ";
163 std::cout << v <<
" ";
165 }
while (cir != end);
167 std::cout << std::endl;
170 std::cout <<
"\n--------------------------------------\n";
171 std::cout <<
"The incident half-edges of each face" << std::endl;
172 std::cout <<
"----------------------------------------\n";
175 for (
auto f : mesh->faces()) {
176 std::cout <<
"half-edges around face " << f <<
": ";
179 for (
auto h : mesh->halfedges(f))
180 std::cout << h <<
" ";
186 std::cout << h <<
" ";
188 }
while (cir != end);
190 std::cout << std::endl;
193 std::cout <<
"\n--------------------------------------\n";
194 std::cout <<
"The two end points of each edge" << std::endl;
195 std::cout <<
"----------------------------------------\n";
198 for (
auto e : mesh->edges()) {
199 std::cout <<
"the two end points of edge " << e <<
": ";
201 std::cout << vs <<
" ";
203 std::cout << vt <<
" " << std::endl;
206 std::cout <<
"\n--------------------------------------\n";
207 std::cout <<
"The two faces connected by each edge" << std::endl;
208 std::cout <<
"----------------------------------------\n";
211 for (
auto e : mesh->edges()) {
212 std::cout <<
"the two faces connected by edge " << e <<
": ";
214 if (mesh->is_border(h0))
215 std::cout <<
"NULL" <<
" ";
217 std::cout << mesh->face(h0) <<
" ";
220 if (mesh->is_border(h1))
221 std::cout <<
"NULL" <<
" ";
223 std::cout << mesh->face(h1) <<
" ";
225 std::cout << std::endl;
Definition surface_mesh.h:1055
Definition surface_mesh.h:1265
Definition surface_mesh.h:954
Definition surface_mesh.h:1167
Definition surface_mesh.h:844
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
Definition collider.cpp:182
Definition surface_mesh.h:191
This type represents a halfedge (internally it is basically an index).
Definition surface_mesh.h:155
This type represents a vertex (internally it is basically an index).
Definition surface_mesh.h:135