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

Method process

source/MRMesh/MRSceneLoad.cpp:41–86  ·  view source on GitHub ↗

gather objects and error and warning messages

Source from the content-addressed store, hash-verified

39
40 // gather objects and error and warning messages
41 void process( const std::filesystem::path& path, Expected<LoadedObjects> res )
42 {
43 const auto fileName = utf8string( path );
44 if ( !res.has_value() || !res->objs.empty() ) // if not skipped folder
45 spdlog::info( "Load {} - {}", fileName, res.has_value() ? "success" : res.error().c_str() );
46 if ( !res.has_value() )
47 {
48 // TODO: user-defined error format
49 if ( !isEmpty( errorSummary_ ) )
50 errorSummary_ << "\n\n";
51 if ( res.error().find( fileName ) == std::string::npos )
52 errorSummary_ << fileName << ":\n" << res.error() << "\n";
53 else
54 errorSummary_ << res.error() << "\n";
55 return;
56 }
57 if ( res.has_value() && !res->warnings.empty() )
58 {
59 // TODO: user-defined warning format
60 if ( !isEmpty( warningSummary_ ) )
61 warningSummary_ << "\n\n";
62 if ( res->warnings.find( fileName ) == std::string::npos )
63 warningSummary_ << fileName << ":\n" << res->warnings;
64 else
65 warningSummary_ << res->warnings;
66 }
67
68 const auto prevObjectCount = loadedObjects_.size();
69 for ( auto& obj : res->objs )
70 if ( obj )
71 {
72 if ( targetUnit_ && res->lengthUnit && *targetUnit_ != *res->lengthUnit )
73 {
74 const auto s = getUnitInfo( *res->lengthUnit ).conversionFactor / getUnitInfo( *targetUnit_ ).conversionFactor;
75 auto xf = obj->xf();
76 xf.A *= s;
77 xf.b *= s;
78 obj->setXf( xf );
79 }
80 loadedObjects_.emplace_back( std::move( obj ) );
81 }
82 if ( prevObjectCount != loadedObjects_.size() )
83 loadedFiles_.emplace_back( path );
84 else
85 errorSummary_ << ( !isEmpty( errorSummary_ ) ? "\n" : "" ) << "\n" << fileName << ":\n" << "No objects found" << "\n";
86 }
87
88 // construct a scene object
89 SceneLoad::Result construct() const

Callers 2

fromAnySupportedFormatFunction · 0.45

Calls 8

utf8stringFunction · 0.85
isEmptyFunction · 0.85
errorMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
xfMethod · 0.45
setXfMethod · 0.45

Tested by

no test coverage detected