This example shows how to create and access properties defined on a surface mesh. We use per-face properties as example, you should be able to do similarly for per-edge/vertex properties.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <easy3d/core/surface_mesh.h>
28#include <easy3d/util/initializer.h>
29
35
37
38
40
42
43
48
49
50 mesh->add_triangle(v0, v1, v3);
51 mesh->add_triangle(v1, v2, v3);
52 mesh->add_triangle(v2, v0, v3);
53 mesh->add_triangle(v0, v2, v1);
54
55 return mesh;
56}
57
58int main(int argc, char** argv) {
59
61
62
63 SurfaceMesh* mesh = old_mesh_from_previous_example();
64
65
67
68
69 for (auto f : mesh->faces()) {
70
71
72
73 normals[f] = mesh->compute_face_normal(f);
74 std::cout << "normal of face " << f << ": " << normals[f] << std::endl;
75 }
76
77 delete mesh;
78
79 return EXIT_SUCCESS;
80}
81
Face property of type T.
Definition surface_mesh.h:363
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
void initialize(bool info_to_stdout, bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition initializer.cpp:39
This type represents a vertex (internally it is basically an index).
Definition surface_mesh.h:135