supereight
mesh_io.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016-2019 Emanuele Vespa
3  * SPDX-FileCopyrightText: 2018-2021 Smart Robotics Lab, Imperial College London, Technical University of Munich
4  * SPDX-FileCopyrightText: 2019-2021 Nils Funk
5  * SPDX-FileCopyrightText: 2020-2021 Sotiris Papatheodorou
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef SE_MESHING_IO_HPP
10 #define SE_MESHING_IO_HPP
11 
12 #include <algorithm>
13 #include <array>
14 #include <fstream>
15 #include <iostream>
16 
18 #include "se/common/str_utils.hpp"
20 
21 namespace se {
22 namespace io {
23 
26 static const std::array<std::string, 3> mesh_extensions = {".obj", ".ply", ".vtk"};
27 
31 bool has_supported_mesh_extension(const std::string& filename);
32 
45 template<typename FaceT>
46 int save_mesh(const Mesh<FaceT>& mesh_M,
47  const std::string& filename,
48  const Eigen::Matrix4f& T_OM = Eigen::Matrix4f::Identity());
49 
60 template<typename FaceT>
61 int save_mesh_vtk(const Mesh<FaceT>& mesh_M,
62  const std::string& filename,
63  const Eigen::Matrix4f& T_OM = Eigen::Matrix4f::Identity());
64 
75 template<typename FaceT>
76 int save_mesh_ply(const Mesh<FaceT>& mesh_M,
77  const std::string& filename,
78  const Eigen::Matrix4f& T_OM = Eigen::Matrix4f::Identity());
79 
90 template<typename FaceT>
91 int save_mesh_obj(const Mesh<FaceT>& mesh_M,
92  const std::string& filename,
93  const Eigen::Matrix4f& T_OM = Eigen::Matrix4f::Identity());
94 
95 } // namespace io
96 } // namespace se
97 
98 #include "impl/mesh_io_impl.hpp"
99 
100 #endif // SE_MESHING_IO_HPP
int save_mesh_obj(const Mesh< FaceT > &mesh_M, const std::string &filename, const Eigen::Matrix4f &T_OM=Eigen::Matrix4f::Identity())
Save a mesh as an Wavefront OBJ file.
int save_mesh(const Mesh< FaceT > &mesh_M, const std::string &filename, const Eigen::Matrix4f &T_OM=Eigen::Matrix4f::Identity())
Save a mesh to a file whose type is determined by the extension of filename.
std::vector< FaceT > Mesh
Meshes are represented as lists of faces.
Definition: mesh.hpp:38
int save_mesh_vtk(const Mesh< FaceT > &mesh_M, const std::string &filename, const Eigen::Matrix4f &T_OM=Eigen::Matrix4f::Identity())
Save a mesh as a VTK file.
int save_mesh_ply(const Mesh< FaceT > &mesh_M, const std::string &filename, const Eigen::Matrix4f &T_OM=Eigen::Matrix4f::Identity())
Save a mesh as a PLY file.
static const std::array< std::string, 3 > mesh_extensions
The supported file extensions for mesh files.
Definition: mesh_io.hpp:26
bool has_supported_mesh_extension(const std::string &filename)
Test whether the suffix of filename is one of the file extensions in se::io::mesh_extensions.
Helper wrapper to allocate and de-allocate octants in the octree.
Definition: colour_utils.hpp:17