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

Method extractVertex

io/ObjReader.cpp:334–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334ObjReader::VTN ObjReader::extractVertex(const std::string& vstring)
335{
336 VTN vtn{ -1, -1, -1 };
337 std::string s(vstring);
338 Utils::trim(s);
339 StringList parts = Utils::split(s, '/');
340 for(auto& part : parts)
341 Utils::trim(part);
342
343 if (parts.size() > 3)
344 throwError("Too many items in vertex specification.");
345
346 char* p;
347 long index = std::strtol(parts[0].c_str(), &p, 10);
348 if (index == 0 || p != parts[0].c_str() + parts[0].size())
349 throwError("Invalid index in face specification.");
350 else if (index < 0)
351 std::get<0>(vtn) = m_vertices.size() - index;
352 else
353 std::get<0>(vtn) = index;
354
355 if (parts.size() > 1)
356 {
357 if (parts[1].length() > 0)
358 {
359 index = std::strtol(parts[1].c_str(), &p, 10);
360 if (index == 0 || p != parts[1].c_str() + parts[1].size())
361 throwError("Invalid index in face specification.");
362 else if(index < 0)
363 std::get<1>(vtn) = m_vertices.size() - index;
364 else
365 std::get<1>(vtn) = index;
366 }
367 }
368
369 if (parts.size() > 2)
370 {
371 if (parts[2].length() > 0)
372 {
373 index = std::strtol(parts[2].c_str(), &p, 10);
374 if (index == 0 || p != parts[2].c_str() + parts[2].size())
375 throwError("Invalid index in face specification.");
376 else if(index < 0)
377 std::get<2>(vtn) = m_vertices.size() - index;
378 else
379 std::get<2>(vtn) = index;
380 }
381 }
382 return vtn;
383}
384
385} // namespace pdal
386

Callers

nothing calls this directly

Calls 4

trimFunction · 0.85
splitFunction · 0.85
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected