MCPcopy Create free account
hub / github.com/PDAL/PDAL / readFace

Method readFace

io/ObjReader.cpp:198–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198bool ObjReader::readFace(FACE& face, PointViewPtr view)
199{
200 long long lineOfFile = 0;
201 while(true) {
202 if(m_istream->peek() == EOF)
203 return false;
204
205 std::string line;
206 std::getline(*m_istream, line);
207 lineOfFile++;
208 Utils::trim(line);
209 if (line.length() == 0)
210 continue;
211
212 StringList fields = Utils::split2(line, ' ');
213 std::string key = fields[0];
214 if (key == "#")
215 {
216 // Comment: Do nothing
217 }
218 else if (key == "v")
219 {
220 // Vertex
221 size_t numDims = fields.size() - 1;
222
223 auto throwVertexError = [this, line, lineOfFile]()
224 {
225 std::stringstream errorMessage;
226 errorMessage << "Could not convert vertex specification to double on line #"
227 << lineOfFile << ": '" << line << "'" << std::endl;
228 throwError(errorMessage.str());
229 };
230
231 if(numDims < 3) {
232 throwVertexError();
233 }
234 else if(numDims == 3) {
235 double x, y, z;
236 if (Utils::fromString(fields[1], x) && Utils::fromString(fields[2], y) &&
237 Utils::fromString(fields[3], z))
238 newVertex(x, y, z);
239 else
240 throwVertexError();
241 }
242 else if(numDims > 3) {
243 double x, y, z, w;
244 if (Utils::fromString(fields[1], x) && Utils::fromString(fields[2], y) &&
245 Utils::fromString(fields[3], z) && Utils::fromString(fields[4], w))
246 newVertex(x, y, z, w);
247 else
248 throwVertexError();
249 }
250 }
251 else if (key == "vt")
252 {
253 auto throwTextureError = [this, line, lineOfFile]()
254 {
255 std::stringstream ss;

Callers

nothing calls this directly

Calls 7

trimFunction · 0.85
strMethod · 0.80
fromStringFunction · 0.70
lengthMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected