MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / parseObjFaceInfo

Function parseObjFaceInfo

source/MRMesh/MRMeshLoadObj.cpp:234–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232};
233
234Expected<ObjFaceInfo> parseObjFaceInfo( const std::string_view& str )
235{
236 using namespace boost::spirit::x3;
237
238 ObjFaceInfo res;
239 auto v = [&] ( auto& )
240 {
241 ++res.numVerts;
242 };
243 auto vt = [&] ( auto& )
244 {
245 ++res.numTexVerts;
246 };
247 auto vn = [&] ( auto& )
248 {
249 // normals are not used currently
250 };
251
252 bool r = phrase_parse(
253 str.begin(),
254 str.end(),
255 // NOTE: actions are not being reverted after backtracking
256 // https://github.com/boostorg/spirit/issues/378
257 ( 'f' >> *( int_[v] >> -( '/' >> ( ( int_[vt] >> -( '/' >> int_[vn] ) ) | ( '/' >> int_[vn] ) ) ) ) ),
258 ascii::space
259 );
260 if ( !r )
261 return unexpected( "Failed to parse face in OBJ-file" );
262
263 if ( !res.numVerts )
264 return unexpected( "Invalid face vertex count in OBJ-file" );
265 if ( res.numTexVerts && res.numVerts != res.numTexVerts )
266 return unexpected( "Invalid face texture count in OBJ-file" );
267 return res;
268}
269
270struct ObjFaces
271{

Callers 1

loadModelsFromObjFunction · 0.85

Calls 3

unexpectedFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected