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

Function parseMtlColor

source/MRMesh/MRMeshLoadObj.cpp:348–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348Expected<void> parseMtlColor( const std::string_view& str, Vector3f& color )
349{
350 using namespace boost::spirit::x3;
351
352 auto r = [&] ( auto& ctx )
353 {
354 color.x = _attr( ctx );
355 };
356 auto g = [&] ( auto& ctx )
357 {
358 color.y = _attr( ctx );
359 };
360 auto b = [&] ( auto& ctx )
361 {
362 color.z = _attr( ctx );
363 };
364
365 bool res = phrase_parse(
366 str.begin(),
367 str.end(),
368 (
369 char_( 'K' ) >> ( char_( 'a' ) | char_( 'd' ) | char_( 's' ) )
370 >> (
371 ( float_[r] >> float_[g] >> float_[b] ) |
372 ( lit( "spectral" ) >> no_skip[+char_] ) |
373 ( lit( "xyz" ) >> float_ >> float_ >> float_ )
374 )
375 ),
376 space
377 );
378 if ( !res )
379 return unexpected( "Failed to parse color in MTL-file" );
380
381 return {};
382}
383
384Expected<void> parseMtlTexture( const std::string_view& str, std::string& textureFile )
385{

Callers 1

loadMtlLibraryFunction · 0.85

Calls 3

unexpectedFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected