Following code presents example of loading and saving mesh file
#include <iostream>
int main()
{
std::filesystem::path inFilePath = "mesh.stl";
if ( loadRes.has_value() )
{
std::filesystem::path outFilePath = "mesh.ply";
if ( !saveRes.has_value() )
std::cerr << saveRes.error() << std::endl;
}
else
std::cerr << loadRes.error() << std::endl;
return 0;
}
MRMESH_API Expected< Mesh > fromAnySupportedFormat(const std::filesystem::path &file, const MeshLoadSettings &settings={})
detects the format from file extension and loads mesh from it
MRMESH_API VoidOrErrStr toAnySupportedFormat(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
detects the format from file extension and save mesh to it
Further examples won't check return values for sake of clarity
- See also
- MR::MeshLoad
-
MR::MeshSave