Open3D (C++ API)  0.13.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TriangleMeshIO.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <string>
30 
32 
33 namespace open3d {
34 namespace io {
35 
38 std::shared_ptr<geometry::TriangleMesh> CreateMeshFromFile(
39  const std::string &filename, bool print_progress = false);
40 
43  bool enable_post_processing = false;
47  bool print_progress = false;
51  std::function<bool(double)> update_progress;
52 };
53 
57 bool ReadTriangleMesh(const std::string &filename,
59  ReadTriangleMeshOptions params = {});
60 
68 bool WriteTriangleMesh(const std::string &filename,
69  const geometry::TriangleMesh &mesh,
70  bool write_ascii = false,
71  bool compressed = false,
72  bool write_vertex_normals = true,
73  bool write_vertex_colors = true,
74  bool write_triangle_uvs = true,
75  bool print_progress = false);
76 
77 // Currently enable_post_processing not used in ReadTriangleMeshFromPLY.
78 bool ReadTriangleMeshFromPLY(const std::string &filename,
80  const ReadTriangleMeshOptions &params);
81 
82 bool WriteTriangleMeshToPLY(const std::string &filename,
83  const geometry::TriangleMesh &mesh,
84  bool write_ascii,
85  bool compressed,
86  bool write_vertex_normals,
87  bool write_vertex_colors,
88  bool write_triangle_uvs,
89  bool print_progress);
90 
91 bool WriteTriangleMeshToSTL(const std::string &filename,
92  const geometry::TriangleMesh &mesh,
93  bool write_ascii,
94  bool compressed,
95  bool write_vertex_normals,
96  bool write_vertex_colors,
97  bool write_triangle_uvs,
98  bool print_progress);
99 
100 // Currently enable_post_processing not used in ReadTriangleMeshFromOBJ.
101 bool ReadTriangleMeshFromOBJ(const std::string &filename,
103  const ReadTriangleMeshOptions &params);
104 
105 bool WriteTriangleMeshToOBJ(const std::string &filename,
106  const geometry::TriangleMesh &mesh,
107  bool write_ascii,
108  bool compressed,
109  bool write_vertex_normals,
110  bool write_vertex_colors,
111  bool write_triangle_uvs,
112  bool print_progress);
113 
114 bool ReadTriangleMeshUsingASSIMP(const std::string &filename,
116  const ReadTriangleMeshOptions &params);
117 
118 // Currently enable_post_processing not used in ReadTriangleMeshFromOFF.
119 bool ReadTriangleMeshFromOFF(const std::string &filename,
121  const ReadTriangleMeshOptions &params);
122 
123 bool WriteTriangleMeshToOFF(const std::string &filename,
124  const geometry::TriangleMesh &mesh,
125  bool write_ascii,
126  bool compressed,
127  bool write_vertex_normals,
128  bool write_vertex_colors,
129  bool write_triangle_uvs,
130  bool print_progress);
131 
132 // Currently enable_post_processing not used in ReadTriangleMeshFromGLTF.
133 bool ReadTriangleMeshFromGLTF(const std::string &filename,
135  const ReadTriangleMeshOptions &params);
136 
137 bool WriteTriangleMeshToGLTF(const std::string &filename,
138  const geometry::TriangleMesh &mesh,
139  bool write_ascii,
140  bool compressed,
141  bool write_vertex_normals,
142  bool write_vertex_colors,
143  bool write_triangle_uvs,
144  bool print_progress);
145 
154  std::vector<unsigned int> &indices);
155 
156 } // namespace io
157 } // namespace open3d
std::function< bool(double)> update_progress
Definition: TriangleMeshIO.h:51
bool ReadTriangleMeshFromOFF(const std::string &filename, geometry::TriangleMesh &mesh, const ReadTriangleMeshOptions &params)
Definition: FileOFF.cpp:42
bool ReadTriangleMesh(const std::string &filename, geometry::TriangleMesh &mesh, ReadTriangleMeshOptions params)
Definition: TriangleMeshIO.cpp:86
bool WriteTriangleMesh(const std::string &filename, const geometry::TriangleMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
Definition: TriangleMeshIO.cpp:129
bool ReadTriangleMeshFromGLTF(const std::string &filename, geometry::TriangleMesh &mesh, const ReadTriangleMeshOptions &params)
Definition: FileGLTF.cpp:94
bool print_progress
Definition: TriangleMeshIO.h:47
bool WriteTriangleMeshToGLTF(const std::string &filename, const geometry::TriangleMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
Definition: FileGLTF.cpp:391
std::shared_ptr< geometry::TriangleMesh > CreateMeshFromFile(const std::string &filename, bool print_progress)
Definition: TriangleMeshIO.cpp:77
bool enable_post_processing
Enables post-processing on the mesh.
Definition: TriangleMeshIO.h:43
bool WriteTriangleMeshToOFF(const std::string &filename, const geometry::TriangleMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
Definition: FileOFF.cpp:167
bool ReadTriangleMeshUsingASSIMP(const std::string &filename, geometry::TriangleMesh &mesh, const ReadTriangleMeshOptions &params)
Definition: FileASSIMP.cpp:142
Definition: TriangleMeshIO.h:41
Definition: PinholeCameraIntrinsic.cpp:35
bool ReadTriangleMeshFromPLY(const std::string &filename, geometry::TriangleMesh &mesh, const ReadTriangleMeshOptions &params)
Definition: FilePLY.cpp:539
bool AddTrianglesByEarClipping(geometry::TriangleMesh &mesh, std::vector< unsigned int > &indices)
Definition: TriangleMeshIO.cpp:189
bool WriteTriangleMeshToSTL(const std::string &filename, const geometry::TriangleMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
Definition: FileSTL.cpp:42
Triangle mesh contains vertices and triangles represented by the indices to the vertices.
Definition: TriangleMesh.h:54
bool WriteTriangleMeshToPLY(const std::string &filename, const geometry::TriangleMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
Definition: FilePLY.cpp:612
bool WriteTriangleMeshToOBJ(const std::string &filename, const geometry::TriangleMesh &mesh, bool write_ascii, bool compressed, bool write_vertex_normals, bool write_vertex_colors, bool write_triangle_uvs, bool print_progress)
Definition: FileOBJ.cpp:225
bool ReadTriangleMeshFromOBJ(const std::string &filename, geometry::TriangleMesh &mesh, const ReadTriangleMeshOptions &)
Definition: FileOBJ.cpp:46