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
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
59 MRMESH_API bool updateHeadCounter();
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}
96
97}
saver in binary .stl format that can write triangles one by one not knowing their number beforehand
Definition MRMeshSave.h:49
MRMESH_API bool updateHeadCounter()
MRMESH_API BinaryStlSaver(std::ostream &out, const SaveSettings &settings={}, std::uint32_t expectedNumTris=0)
writes STL header in the stream
MRMESH_API ~BinaryStlSaver()
calls updateHeadCounter();
MRMESH_API bool writeTri(const Triangle3f &tri)
writes one more triangle in the stream
tl::expected< T, E > Expected
Definition MRExpected.h:31
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)
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh.h:23
determines how to save points/lines/mesh
Definition MRSaveSettings.h:20