MeshLib
 
Loading...
Searching...
No Matches
MRMesh/MRMeshSave.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRExpected.h"
5#include "MRIOFilters.h"
6#include "MRSaveSettings.h"
7#include <filesystem>
8#include <ostream>
9
10namespace MR
11{
12
13namespace MeshSave
14{
15
19
20MRMESH_API extern const IOFilters Filters;
21
24MRMESH_API VoidOrErrStr toMrmesh( const Mesh & mesh, const std::filesystem::path & file,
25 const SaveSettings & settings = {} );
26MRMESH_API VoidOrErrStr toMrmesh( const Mesh & mesh, std::ostream & out,
27 const SaveSettings & settings = {} );
28
30MRMESH_API VoidOrErrStr toOff( const Mesh & mesh, const std::filesystem::path & file,
31 const SaveSettings & settings = {} );
32MRMESH_API VoidOrErrStr toOff( const Mesh & mesh, std::ostream & out,
33 const SaveSettings & settings = {} );
34
37MRMESH_API VoidOrErrStr toObj( const Mesh & mesh, const std::filesystem::path & file,
38 const SaveSettings & settings = {}, int firstVertId = 1 );
39MRMESH_API VoidOrErrStr toObj( const Mesh & mesh, std::ostream & out,
40 const SaveSettings & settings = {}, int firstVertId = 1 );
41
44MRMESH_API VoidOrErrStr toBinaryStl( const Mesh & mesh, const std::filesystem::path & file, const SaveSettings & settings = {} );
45MRMESH_API VoidOrErrStr toBinaryStl( const Mesh & mesh, std::ostream & out, const SaveSettings & settings = {} );
46
49MRMESH_API VoidOrErrStr toAsciiStl( const Mesh& mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
50MRMESH_API VoidOrErrStr toAsciiStl( const Mesh& mesh, std::ostream& out, const SaveSettings & settings = {} );
51
53MRMESH_API VoidOrErrStr toPly( const Mesh& mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
54MRMESH_API VoidOrErrStr toPly( const Mesh & mesh, std::ostream & out, const SaveSettings & settings = {} );
55
57{
58 enum class MeshCompression
59 {
60 None,
61 Lossless,
62 Lossy
63 };
67 float vertexPrecision = 1.0f / 1024.0f; //~= 0.00098
71 const char * comment = "MeshInspector.com";
72};
73
74#ifndef MRMESH_NO_OPENCTM
76MRMESH_API VoidOrErrStr toCtm( const Mesh & mesh, const std::filesystem::path & file, const CtmSaveOptions options = {} );
77MRMESH_API VoidOrErrStr toCtm( const Mesh & mesh, std::ostream & out, const CtmSaveOptions options = {} );
78#endif
79
81MRMESH_API VoidOrErrStr toAnySupportedFormat( const Mesh & mesh, const std::filesystem::path & file, const SaveSettings & settings = {} );
83MRMESH_API VoidOrErrStr toAnySupportedFormat( const Mesh& mesh, std::ostream& out, const std::string& extension, const SaveSettings & settings = {} );
84
86
87} // namespace MeshSave
88
89} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
std::vector< IOFilter > IOFilters
Definition MRIOFilters.h:23
MRMESH_API VoidOrErrStr toObj(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={}, int firstVertId=1)
MRMESH_API VoidOrErrStr toOff(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
saves in .off file
MRMESH_API VoidOrErrStr toPly(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
saves in .ply file
MRMESH_API VoidOrErrStr toBinaryStl(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
MRMESH_API VoidOrErrStr toAsciiStl(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
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
MRMESH_API VoidOrErrStr toCtm(const Mesh &mesh, const std::filesystem::path &file, const CtmSaveOptions options={})
saves in .ctm file
MRMESH_API VoidOrErrStr toMrmesh(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
MRMESH_API const IOFilters Filters
Definition MRCameraOrientationPlugin.h:7
Expected< void > VoidOrErrStr
return type for a void function that can produce an error string
Definition MRExpected.h:60
Definition MRMesh/MRMeshSave.h:57
int compressionLevel
LZMA compression: 0 - minimal compression, but fast; 9 - maximal compression, but slow.
Definition MRMesh/MRMeshSave.h:69
const char * comment
comment saved in the file
Definition MRMesh/MRMeshSave.h:71
float vertexPrecision
Definition MRMesh/MRMeshSave.h:67
MeshCompression meshCompression
Definition MRMesh/MRMeshSave.h:64
MeshCompression
Definition MRMesh/MRMeshSave.h:59
@ None
no compression at all, fast but not effective
@ Lossless
compression without any loss in vertex coordinates
@ Lossy
compression with loss in vertex coordinates
Definition MRMesh/MRMesh.h:23
determines how to save points/lines/mesh
Definition MRSaveSettings.h:14