MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / parse

Method parse

src/IO/OFFParser.cpp:41–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41bool OFFParser::parse(const std::string& filename) {
42 const size_t LINE_SIZE = 256;
43 char line[LINE_SIZE];
44
45 std::ifstream fin(filename.c_str());
46 if (!fin.is_open()) {
47 std::stringstream err_msg;
48 err_msg << "failed to open file \"" << filename << "\"";
49 throw IOError(err_msg.str());
50 }
51
52 next_line(fin, line, LINE_SIZE);
53 check_header(line);
54 next_line(fin, line, LINE_SIZE);
55 parse_geometry_counts(line);
56
57 for (size_t i=0; i<m_num_vertices; i++) {
58 if (fin.eof()) {
59 throw IOError("Error in parsing vertices");
60 }
61 next_line(fin, line, LINE_SIZE);
62 parse_vertex_line(line);
63 }
64
65 for (size_t i=0; i<m_num_faces; i++) {
66 if (fin.eof()) {
67 throw IOError("Error in parsing faces");
68 }
69 next_line(fin, line, LINE_SIZE);
70 parse_face_line(line);
71 }
72
73 fin.close();
74 unify_faces();
75 finalize_colors();
76
77 if (m_vertices.size() == 0) {
78 m_dim = 3; // default: 3D
79 }
80 if (m_faces.size() == 0) {
81 m_vertex_per_face = 3; // default: triangle
82 }
83 return true;
84}
85
86size_t OFFParser::num_attributes() const {
87 size_t result = 0;

Callers

nothing calls this directly

Calls 4

IOErrorClass · 0.85
next_lineFunction · 0.70
strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected