Main MRPT website > C++ reference for MRPT 1.9.9
PLY_import_export.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/img/TColor.h>
13 #include <vector>
14 #include <string>
15 
16 namespace mrpt
17 {
18 namespace opengl
19 {
20 /** A virtual base class that implements the capability of importing 3D point
21  * clouds and faces from a file in the Stanford PLY format.
22  * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY
23  * \sa PLY_Exporter
24  * \ingroup mrpt_base_grp
25  */
27 {
28  public:
29  /** Loads from a PLY file.
30  * \param[in] filename The filename to open. It can be either in binary or
31  * text format.
32  * \param[out] file_comments If provided (!=nullptr) the list of comment
33  * strings stored in the file will be returned.
34  * \param[out] file_obj_info If provided (!=nullptr) the list of "object
35  * info" strings stored in the file will be returned.
36  * \return false on any error in the file format or reading it. To obtain
37  * more details on the error you can call getLoadPLYErrorString()
38  */
39  bool loadFromPlyFile(
40  const std::string& filename,
41  std::vector<std::string>* file_comments = nullptr,
42  std::vector<std::string>* file_obj_info = nullptr);
43 
44  /** Return a description of the error if loadFromPlyFile() returned false,
45  * or an empty string if the file was loaded without problems. */
47  {
49  }
50 
51  protected:
52  /** @name PLY Import virtual methods to implement in base classes
53  @{ */
54 
55  /** In a base class, reserve memory to prepare subsequent calls to
56  * PLY_import_set_vertex */
57  virtual void PLY_import_set_vertex_count(const size_t N) = 0;
58 
59  /** In a base class, reserve memory to prepare subsequent calls to
60  * PLY_import_set_face */
61  virtual void PLY_import_set_face_count(const size_t N) = 0;
62 
63  /** In a base class, will be called after PLY_import_set_vertex_count() once
64  * for each loaded point.
65  * \param pt_color Will be nullptr if the loaded file does not provide
66  * color info.
67  */
68  virtual void PLY_import_set_vertex(
69  const size_t idx, const mrpt::math::TPoint3Df& pt,
70  const mrpt::img::TColorf* pt_color = nullptr) = 0;
71 
72  /** @} */
73 
74  private:
76 
77 }; // End of class def.
78 
79 /** A virtual base class that implements the capability of exporting 3D point
80  * clouds and faces to a file in the Stanford PLY format.
81  * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY
82  * \sa PLY_Importer
83  * \ingroup mrpt_base_grp
84  */
86 {
87  public:
88  /** Saves to a PLY file.
89  * \param[in] filename The filename to be saved.
90  * \param[in] file_comments If provided (!=nullptr) the list of comment
91  * strings stored in the file will be returned.
92  * \param[in] file_obj_info If provided (!=nullptr) the list of "object
93  * info" strings stored in the file will be returned.
94  * \return false on any error writing the file. To obtain more details on
95  * the error you can call getSavePLYErrorString()
96  */
97  bool saveToPlyFile(
98  const std::string& filename, bool save_in_binary = false,
99  const std::vector<std::string>& file_comments =
100  std::vector<std::string>(),
101  const std::vector<std::string>& file_obj_info =
102  std::vector<std::string>()) const;
103 
104  /** Return a description of the error if loadFromPlyFile() returned false,
105  * or an empty string if the file was loaded without problems. */
107  {
109  }
110 
111  protected:
112  /** @name PLY Export virtual methods to implement in base classes
113  @{ */
114 
115  /** In a base class, return the number of vertices */
116  virtual size_t PLY_export_get_vertex_count() const = 0;
117 
118  /** In a base class, return the number of faces */
119  virtual size_t PLY_export_get_face_count() const = 0;
120 
121  /** In a base class, will be called after PLY_export_get_vertex_count() once
122  * for each exported point.
123  * \param pt_color Will be nullptr if the loaded file does not provide
124  * color info.
125  */
126  virtual void PLY_export_get_vertex(
127  const size_t idx, mrpt::math::TPoint3Df& pt, bool& pt_has_color,
128  mrpt::img::TColorf& pt_color) const = 0;
129 
130  /** @} */
131 
132  private:
134 
135 }; // End of class def.
136 
137 } // namespace opengl
138 } // namespace mrpt
mrpt::math::TPoint3Df
Lightweight 3D point (float version).
Definition: lightweight_geom_data.h:315
mrpt::opengl::PLY_Exporter::PLY_export_get_vertex_count
virtual size_t PLY_export_get_vertex_count() const =0
In a base class, return the number of vertices.
mrpt::opengl::PLY_Importer::loadFromPlyFile
bool loadFromPlyFile(const std::string &filename, std::vector< std::string > *file_comments=nullptr, std::vector< std::string > *file_obj_info=nullptr)
Loads from a PLY file.
Definition: PLY_import_export.cpp:1857
mrpt::opengl::PLY_Exporter::PLY_export_get_vertex
virtual void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::img::TColorf &pt_color) const =0
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
mrpt::opengl::PLY_Importer::PLY_import_set_vertex_count
virtual void PLY_import_set_vertex_count(const size_t N)=0
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
mrpt::opengl::PLY_Exporter::PLY_export_get_face_count
virtual size_t PLY_export_get_face_count() const =0
In a base class, return the number of faces.
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
lightweight_geom_data.h
mrpt::opengl::PLY_Importer::PLY_import_set_face_count
virtual void PLY_import_set_face_count(const size_t N)=0
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_face.
mrpt::opengl::PLY_Exporter
A virtual base class that implements the capability of exporting 3D point clouds and faces to a file ...
Definition: PLY_import_export.h:85
mrpt::opengl::PLY_Exporter::getSavePLYErrorString
std::string getSavePLYErrorString() const
Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file...
Definition: PLY_import_export.h:106
mrpt::img::TColorf
A RGB color - floats in the range [0,1].
Definition: TColor.h:79
mrpt::opengl::PLY_Exporter::m_ply_export_last_error
std::string m_ply_export_last_error
Definition: PLY_import_export.h:133
mrpt::opengl::PLY_Importer
A virtual base class that implements the capability of importing 3D point clouds and faces from a fil...
Definition: PLY_import_export.h:26
mrpt::opengl::PLY_Exporter::saveToPlyFile
bool saveToPlyFile(const std::string &filename, bool save_in_binary=false, const std::vector< std::string > &file_comments=std::vector< std::string >(), const std::vector< std::string > &file_obj_info=std::vector< std::string >()) const
Saves to a PLY file.
Definition: PLY_import_export.cpp:1960
mrpt::opengl::PLY_Importer::getLoadPLYErrorString
std::string getLoadPLYErrorString() const
Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file...
Definition: PLY_import_export.h:46
mrpt::opengl::PLY_Importer::m_ply_import_last_error
std::string m_ply_import_last_error
Definition: PLY_import_export.h:75
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::opengl::PLY_Importer::PLY_import_set_vertex
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::img::TColorf *pt_color=nullptr)=0
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
TColor.h



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST