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

Method parse

src/IO/VEGAParser.cpp:27–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27bool VEGAParser::parse(const std::string& filename) {
28 std::ifstream fin(filename.c_str());
29 if (!fin.is_open()) {
30 std::stringstream err_msg;
31 err_msg << "failed to open file \"" << filename << "\"";
32 throw IOError(err_msg.str());
33 }
34
35 while(!fin.eof()) {
36 const std::string line = IOUtils::next_line(fin);
37 assert(line.size() > 0);
38
39 if (line[0] == '*') {
40 if (IOUtils::is_prefix("*VERTICES", line.c_str())) {
41 parse_vertices(fin);
42 } else if (IOUtils::is_prefix("*ELEMENTS", line.c_str())) {
43 parse_elements(fin);
44 } else if (IOUtils::is_prefix("*MATERIAL", line.c_str())) {
45 parse_material(fin);
46 } else if (IOUtils::is_prefix("*REGION", line.c_str())) {
47 parse_region(fin);
48 } else if (IOUtils::is_prefix("*SET", line.c_str())) {
49 parse_set(fin);
50 } else {
51 std::stringstream err_msg;
52 err_msg << "Unknown VEGA command: " << line;
53 throw IOError(err_msg.str());
54 }
55 } else {
56 std::cerr << "Warning: unknown line skipped: " << line << std::endl;
57 }
58 }
59 extract_faces_from_voxels();
60 return true;
61}
62
63void VEGAParser::parse_vertices(std::ifstream& fin) {
64 const std::string header = IOUtils::next_line(fin);

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