Visual Computing Library
Loading...
Searching...
No Matches
save.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_LOAD_SAVE_SAVE_H
24#define VCL_LOAD_SAVE_SAVE_H
25
26#include "obj/save.h"
27#include "off/save.h"
28#include "ply/save.h"
29#include "stl/save.h"
30
38namespace vcl {
39
58template<MeshConcept MeshType, LoggerConcept LogType = NullLogger>
59void save(
60 const MeshType& m,
61 const std::string& filename,
62 LogType& log = nullLogger,
63 const SaveSettings& settings = SaveSettings())
64{
65 std::string ext = FileInfo::extension(filename);
66 ext = toLower(ext);
67 if (ext == ".obj") {
68 saveObj(m, filename, log, settings);
69 }
70 else if (ext == ".off") {
71 saveOff(m, filename, log, settings);
72 }
73 else if (ext == ".ply") {
74 savePly(m, filename, log, settings);
75 }
76 else if (ext == ".stl") {
77 saveStl(m, filename, log, settings);
78 }
79 else {
81 }
82}
83
97template<MeshConcept MeshType, LoggerConcept LogType = NullLogger>
98void save(
99 const MeshType& m,
100 const std::string& filename,
101 const SaveSettings& settings,
102 LogType& log = nullLogger)
103{
104 save(m, filename, log, settings);
105}
106
107} // namespace vcl
108
109#endif // VCL_LOAD_SAVE_SAVE_H
static std::string extension(const std::string &filename)
Get the extension of a file.
Definition file_info.h:257
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Exception thrown when the file format is unknown.
Definition io.h:37
NullLogger nullLogger
The nullLogger object is an object of type NullLogger that is used as default argument in the functio...
Definition null_logger.h:125
void save(const MeshType &m, const std::string &filename, LogType &log=nullLogger, const SaveSettings &settings=SaveSettings())
Saves a mesh to a file with the given filename. Checks automatically the file format to save from the...
Definition save.h:59
The SaveSettings structure contains the settings that can be used to save a mesh to a stream/file.
Definition settings.h:62