MCPcopy Create free account
hub / github.com/RenderKit/embree / PlyParser

Method PlyParser

tutorials/common/scenegraph/ply_loader.cpp:104–133  ·  view source on GitHub ↗

constructor parses the input stream */

Source from the content-addressed store, hash-verified

102
103 /* constructor parses the input stream */
104 PlyParser(const FileName& fileName) : format(ASCII)
105 {
106 /* open file */
107 fs.open (fileName.c_str(), std::fstream::in | std::fstream::binary);
108 if (!fs.is_open()) throw std::runtime_error("cannot open file : " + fileName.str());
109
110 /* check for file signature */
111 std::string signature; getline(fs,signature);
112 if (signature != "ply") throw std::runtime_error("invalid PLY file signature: " + signature);
113
114 /* read header */
115 std::list<std::string> header;
116 while (true) {
117 std::string line; getline(fs,line);
118 if (line == "end_header") break;
119 if (line.find_first_of('#') == 0) continue;
120 if (line == "") continue;
121 header.emplace_back(line);
122 }
123
124 /* parse header */
125 parseHeader(header);
126
127 /* now parse all elements */
128 for (std::vector<std::string>::iterator i = mesh.order.begin(); i!=mesh.order.end(); i++)
129 parseElementData(mesh.elements[*i]);
130
131 /* create triangle mesh */
132 scene = import();
133 }
134
135 /* parse the PLY header */
136 void parseHeader(std::list<std::string>& header)

Callers

nothing calls this directly

Calls 6

parseHeaderFunction · 0.85
openMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected