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

Function fromAnySupportedFormat

source/MRMesh/MRMeshLoad.cpp:831–859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829}
830
831Expected<Mesh> fromAnySupportedFormat( const std::filesystem::path& file, const MeshLoadSettings& settings /*= {}*/ )
832{
833 auto ext = utf8string( file.extension() );
834 for ( auto & c : ext )
835 c = (char)tolower( c );
836 ext = "*" + ext;
837
838 auto loader = getMeshLoader( ext );
839 if ( !loader.fileLoad )
840 {
841 if ( loader.streamLoad )
842 {
843 std::ifstream in( file, std::ifstream::binary );
844 if ( !in )
845 return unexpected( std::string( "Cannot open file for reading " ) + utf8string( file ) );
846 return addFileNameInError( loader.streamLoad( in, settings ), file );
847 }
848 // the error string must start with stringUnsupportedFileExtension()
849 std::string err = fmt::format( "{} {} for mesh loading.", stringUnsupportedFileExtension(), ext );
850 if ( SceneLoad::getSceneLoader( ext ) )
851 return unexpected( err + "\nPlease open this format using scene loading function." );
852 return unexpected( err );
853 }
854
855 auto res = loader.fileLoad( file, settings );
856 if ( res )
857 telemetryOpenMesh( ext, *res, settings );
858 return res;
859}
860
861Expected<Mesh> fromAnySupportedFormat( std::istream& in, const std::string& extension, const MeshLoadSettings& settings /*= {}*/ )
862{

Callers 15

deserializeModel_Method · 0.70
loadMeshFunction · 0.70
fromObjFunction · 0.70
deserializeModel_Method · 0.70
deserializeModel_Method · 0.70
loadObjectFromObjFunction · 0.70
makeObjectFromMeshFileFunction · 0.70
makeObjectLinesFromFileFunction · 0.70
makeObjectPointsFromFileFunction · 0.70
makeObjectGcodeFromFileFunction · 0.70

Calls 4

utf8stringFunction · 0.85
addFileNameInErrorFunction · 0.85
telemetryOpenMeshFunction · 0.85
unexpectedFunction · 0.70

Tested by

no test coverage detected