MeshLib C++ Docs
Loading...
Searching...
No Matches
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
22MRMESH_API Expected<void> toMrmesh( const Mesh & mesh, const std::filesystem::path & file,
23 const SaveSettings & settings = {} );
24MRMESH_API Expected<void> toMrmesh( const Mesh & mesh, std::ostream & out,
25 const SaveSettings & settings = {} );
26
28MRMESH_API Expected<void> toOff( const Mesh & mesh, const std::filesystem::path & file,
29 const SaveSettings & settings = {} );
30MRMESH_API Expected<void> toOff( const Mesh & mesh, std::ostream & out,
31 const SaveSettings & settings = {} );
32
35MRMESH_API Expected<void> toObj( const Mesh & mesh, const std::filesystem::path & file,
36 const SaveSettings & settings, int firstVertId );
37MRMESH_API Expected<void> toObj( const Mesh & mesh, std::ostream & out,
38 const SaveSettings & settings, int firstVertId );
39MRMESH_API Expected<void> toObj( const Mesh & mesh, const std::filesystem::path & file, const SaveSettings & settings = {} );
40MRMESH_API Expected<void> toObj( const Mesh & mesh, std::ostream & out, const SaveSettings & settings = {} );
41
44MRMESH_API Expected<void> toBinaryStl( const Mesh & mesh, const std::filesystem::path & file, const SaveSettings & settings = {} );
45MRMESH_API Expected<void> toBinaryStl( const Mesh & mesh, std::ostream & out, const SaveSettings & settings = {} );
46
48class BinaryStlSaver
49{
50public:
52 MRMESH_API explicit BinaryStlSaver( std::ostream & out, const SaveSettings & settings = {}, std::uint32_t expectedNumTris = 0 );
53
55 MRMESH_API bool writeTri( const Triangle3f& tri );
56
60
62 MRMESH_API ~BinaryStlSaver();
63
64private:
65 std::ostream & out_;
66 SaveSettings settings_;
67 std::ostream::pos_type numTrisPos_ = 0;
68 std::uint32_t headNumTris_ = 0;
69 std::uint32_t savedNumTris_ = 0;
70};
71
74MRMESH_API Expected<void> toAsciiStl( const Mesh & mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
75MRMESH_API Expected<void> toAsciiStl( const Mesh & mesh, std::ostream& out, const SaveSettings & settings = {} );
76
78MRMESH_API Expected<void> toPly( const Mesh & mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
79MRMESH_API Expected<void> toPly( const Mesh & mesh, std::ostream & out, const SaveSettings & settings = {} );
80
82MRMESH_API Expected<void> toModel3mf( const Mesh & mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
83MRMESH_API Expected<void> toModel3mf( const Mesh & mesh, std::ostream & out, const SaveSettings & settings = {} );
84
86MRMESH_API Expected<void> to3mf( const Mesh & mesh, const std::filesystem::path& file, const SaveSettings & settings = {} );
87
89MRMESH_API Expected<void> toAnySupportedFormat( const Mesh & mesh, const std::filesystem::path & file, const SaveSettings & settings = {} );
91MRMESH_API Expected<void> toAnySupportedFormat( const Mesh & mesh, const std::string& extension, std::ostream& out, const SaveSettings & settings = {} );
92
94
95} // namespace MeshSave
96
97} // namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
unsafe bool writeTri(in MR.Std.Array_MRVector3f_3 tri)
unsafe BinaryStlSaver(MR.MeshSave._ByValue_BinaryStlSaver _other)
Definition MRMesh/MRMesh.h:23
Definition MRSaveSettings.h:17
MRMESH_API Expected< void > to3mf(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
saves in .3mf file
MRMESH_API Expected< void > toAsciiStl(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
MRMESH_API Expected< void > toModel3mf(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
saves in 3mf .model file
MRMESH_API Expected< void > toOff(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
saves in .off file
MRMESH_API Expected< void > toBinaryStl(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
MRMESH_API Expected< void > toMrmesh(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
MRMESH_API Expected< void > 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 Expected< void > toPly(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings={})
saves in .ply file
MRMESH_API Expected< void > toObj(const Mesh &mesh, const std::filesystem::path &file, const SaveSettings &settings, int firstVertId)
Definition MRCameraOrientationPlugin.h:8