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

Function parseMtlTexture

source/MRMesh/MRMeshLoadObj.cpp:384–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384Expected<void> parseMtlTexture( const std::string_view& str, std::string& textureFile )
385{
386 using namespace boost::spirit::x3;
387
388 auto file = [&] ( auto& ctx )
389 {
390 textureFile = _attr( ctx );
391 };
392
393 bool r = phrase_parse(
394 str.begin(),
395 str.end(),
396 (
397 lit( "map_" ) >> ( lit( "Ka" ) | lit( "Kd" ) | lit( "Ks" ) | lit( "Ns" ) | lit( "d" ) )
398 >> *(
399 ( lit( "-blendu" ) >> ( lit( "on" ) | lit( "off" ) ) ) |
400 ( lit( "-blendv" ) >> ( lit( "on" ) | lit( "off" ) ) ) |
401 ( lit( "-cc" ) >> ( lit( "on" ) | lit( "off" ) ) ) |
402 ( lit( "-clamp" ) >> ( lit( "on" ) | lit( "off" ) ) ) |
403 ( lit( "-imfchan" ) >> ( char_( 'r' ) | char_( 'b' ) | char_( 'g' ) | char_( 'm' ) | char_( 'l' ) | char_( 'z' ) ) ) |
404 ( lit( "-mm" ) >> float_ >> float_ ) |
405 ( lit( "-bm" ) >> float_ ) |
406 ( lit( "-o" ) >> float_ >> float_ >> float_ ) |
407 ( lit( "-s" ) >> float_ >> float_ >> float_ ) |
408 ( lit( "-t" ) >> float_ >> float_ >> float_ ) |
409 ( lit( "-texres" ) >> float_ )
410 )
411 >> no_skip[+char_][file]
412 ),
413 space
414 );
415 if ( !r )
416 return unexpected( "Failed to parse texture in MTL-file" );
417
418 boost::trim( textureFile );
419 return {};
420}
421
422struct MtlMaterial
423{

Callers 1

loadMtlLibraryFunction · 0.85

Calls 4

trimFunction · 0.85
unexpectedFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected