-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpen.cpp
More file actions
50 lines (40 loc) · 1.27 KB
/
Copy pathOpen.cpp
File metadata and controls
50 lines (40 loc) · 1.27 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
#include "MyViewer.h"
bool MyViewer::openBezier(const std::string& filename, bool update_view) {
size_t n, m;
try {
std::ifstream f(filename.c_str());
f.exceptions(std::ios::failbit | std::ios::badbit);
f >> n >> m;
degree[0] = n++; degree[1] = m++;
control_points.resize(n * m);
for (size_t i = 0, index = 0; i < n; ++i)
for (size_t j = 0; j < m; ++j, ++index)
f >> control_points[index][0] >> control_points[index][1] >> control_points[index][2];
}
catch (std::ifstream::failure&) {
return false;
}
model_type = ModelType::BEZIER_SURFACE;
last_filename = filename;
updateMesh(update_view);
if (update_view)
setupCamera();
return true;
}
bool MyViewer::openMesh(const std::string& filename, bool update_view) {
if (!OpenMesh::IO::read_mesh(mesh, filename) || mesh.n_vertices() == 0)
return false;
model_type = ModelType::MESH;
last_filename = filename;
updateMesh(update_view);
if (update_view)
setupCamera();
for (auto v : mesh.vertices())
{
mesh.data(v).original = mesh.point(v);
}
mesh.request_vertex_status();
mesh.request_edge_status();
mesh.request_face_status();
return true;
}