Repository navigation
Expand file tree
/
Copy pathMesh.cpp
More file actions
183 lines (140 loc) · 4.56 KB
/
Copy pathMesh.cpp
File metadata and controls
183 lines (140 loc) · 4.56 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* This file is part of PyMesh. Copyright (c) 2015 by Qingnan Zhou */
#include "Mesh.h"
#include <Attributes/MeshAttributes.h>
#include <Connectivity/MeshConnectivity.h>
#include <Core/EigenTypedef.h>
#include <Geometry/MeshGeometry.h>
using namespace PyMesh;
Mesh::Mesh() {
m_geometry = std::make_shared<MeshGeometry>();
m_connectivity = std::make_shared<MeshConnectivity>();
m_attributes = std::make_shared<MeshAttributes>();
}
size_t Mesh::get_dim() const {
return m_geometry->get_dim();
}
size_t Mesh::get_num_vertices() const {
return m_geometry->get_num_vertices();
}
size_t Mesh::get_num_faces() const {
return m_geometry->get_num_faces();
}
size_t Mesh::get_num_voxels() const {
return m_geometry->get_num_voxels();
}
VectorF Mesh::get_vertex(size_t i) {
const size_t dim = get_dim();
return get_vertices().segment(i*dim, dim);
}
VectorI Mesh::get_face(size_t i) {
size_t stride = get_vertex_per_face();
return get_faces().segment(i*stride, stride);
}
VectorI Mesh::get_voxel(size_t i) {
size_t stride = get_vertex_per_voxel();
return get_voxels().segment(i*stride, stride);
}
VectorF Mesh::get_vertex(size_t i) const {
const size_t dim = get_dim();
return get_vertices().segment(i*dim, dim);
}
VectorI Mesh::get_face(size_t i) const {
size_t stride = get_vertex_per_face();
return get_faces().segment(i*stride, stride);
}
VectorI Mesh::get_voxel(size_t i) const {
size_t stride = get_vertex_per_voxel();
return get_voxels().segment(i*stride, stride);
}
VectorF& Mesh::get_vertices() {
return m_geometry->get_vertices();
}
VectorI& Mesh::get_faces() {
return m_geometry->get_faces();
}
VectorI& Mesh::get_voxels() {
return m_geometry->get_voxels();
}
const VectorF& Mesh::get_vertices() const {
return m_geometry->get_vertices();
}
const VectorI& Mesh::get_faces() const {
return m_geometry->get_faces();
}
const VectorI& Mesh::get_voxels() const {
return m_geometry->get_voxels();
}
int Mesh::get_vertex_per_face() const {
return m_geometry->get_vertex_per_face();
}
int Mesh::get_vertex_per_voxel() const {
return m_geometry->get_vertex_per_voxel();
}
void Mesh::enable_connectivity() {
enable_vertex_connectivity();
enable_face_connectivity();
enable_voxel_connectivity();
}
void Mesh::enable_vertex_connectivity() {
m_connectivity->init_vertex_adjacencies(this);
}
void Mesh::enable_face_connectivity() {
m_connectivity->init_face_adjacencies(this);
}
void Mesh::enable_voxel_connectivity() {
m_connectivity->init_voxel_adjacencies(this);
}
VectorI Mesh::get_vertex_adjacent_vertices(size_t vi) const {
return m_connectivity->get_vertex_adjacent_vertices(vi);
}
VectorI Mesh::get_vertex_adjacent_faces(size_t vi) const {
return m_connectivity->get_vertex_adjacent_faces(vi);
}
VectorI Mesh::get_vertex_adjacent_voxels(size_t vi) const {
return m_connectivity->get_vertex_adjacent_voxels(vi);
}
VectorI Mesh::get_face_adjacent_faces(size_t fi) const {
return m_connectivity->get_face_adjacent_faces(fi);
}
VectorI Mesh::get_face_adjacent_voxels(size_t fi) const {
return m_connectivity->get_face_adjacent_voxels(fi);
}
VectorI Mesh::get_voxel_adjacent_faces(size_t Vi) const {
return m_connectivity->get_voxel_adjacent_faces(Vi);
}
VectorI Mesh::get_voxel_adjacent_voxels(size_t Vi) const {
return m_connectivity->get_voxel_adjacent_voxels(Vi);
}
bool Mesh::has_attribute(const std::string& attr_name) const {
return m_attributes->has_attribute(attr_name);
}
void Mesh::add_attribute(const std::string& attr_name) {
m_attributes->add_attribute(attr_name, *this);
}
void Mesh::add_empty_attribute(const std::string& attr_name) {
m_attributes->add_empty_attribute(attr_name);
}
void Mesh::remove_attribute(const std::string& attr_name) {
m_attributes->remove_attribute(attr_name);
}
VectorF& Mesh::get_attribute(const std::string& attr_name) {
return m_attributes->get_attribute(attr_name);
}
const VectorF& Mesh::get_attribute(const std::string& attr_name) const {
return m_attributes->get_attribute(attr_name);
}
void Mesh::set_attribute(const std::string& attr_name, VectorF& attr_value) {
return m_attributes->set_attribute(attr_name, attr_value);
}
std::vector<std::string> Mesh::get_attribute_names() const {
return m_attributes->get_attribute_names();
}
void Mesh::set_geometry(GeometryPtr geometry) {
m_geometry = geometry;
}
void Mesh::set_connectivity(ConnectivityPtr connectivity) {
m_connectivity = connectivity;
}
void Mesh::set_attributes(AttributesPtr attributes) {
m_attributes = attributes;
}