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-2017, 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 #ifndef PLY_IMPORT_EXPORT_H
10 #define PLY_IMPORT_EXPORT_H
11 
12 #include <mrpt/utils/core_defs.h>
13 #include <mrpt/utils/CStringList.h>
14 #include <mrpt/utils/TColor.h>
16 
17 namespace mrpt
18 {
19 namespace utils
20 {
21 /** A virtual base class that implements the capability of importing 3D point
22  * clouds and faces from a file in the Stanford PLY format.
23  * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY
24  * \sa PLY_Exporter
25  * \ingroup mrpt_base_grp
26  */
28 {
29  public:
30  /** Loads from a PLY file.
31  * \param[in] filename The filename to open. It can be either in binary or
32  * text format.
33  * \param[out] file_comments If provided (!=nullptr) the list of comment
34  * strings stored in the file will be returned.
35  * \param[out] file_obj_info If provided (!=nullptr) the list of "object
36  * info" strings stored in the file will be returned.
37  * \return false on any error in the file format or reading it. To obtain
38  * more details on the error you can call getLoadPLYErrorString()
39  */
40  bool loadFromPlyFile(
41  const std::string& filename, CStringList* file_comments = nullptr,
42  CStringList* 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::utils::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 CStringList& file_comments = CStringList(),
100  const CStringList& file_obj_info = CStringList()) const;
101 
102  /** Return a description of the error if loadFromPlyFile() returned false,
103  * or an empty string if the file was loaded without problems. */
105  {
107  }
108 
109  protected:
110  /** @name PLY Export virtual methods to implement in base classes
111  @{ */
112 
113  /** In a base class, return the number of vertices */
114  virtual size_t PLY_export_get_vertex_count() const = 0;
115 
116  /** In a base class, return the number of faces */
117  virtual size_t PLY_export_get_face_count() const = 0;
118 
119  /** In a base class, will be called after PLY_export_get_vertex_count() once
120  * for each exported point.
121  * \param pt_color Will be nullptr if the loaded file does not provide
122  * color info.
123  */
124  virtual void PLY_export_get_vertex(
125  const size_t idx, mrpt::math::TPoint3Df& pt, bool& pt_has_color,
126  mrpt::utils::TColorf& pt_color) const = 0;
127 
128  /** @} */
129 
130  private:
132 
133 }; // End of class def.
134 
135 } // End of namespace
136 } // end of namespace
137 #endif
virtual size_t PLY_export_get_face_count() const =0
In a base class, return the number of faces.
bool saveToPlyFile(const std::string &filename, bool save_in_binary=false, const CStringList &file_comments=CStringList(), const CStringList &file_obj_info=CStringList()) const
Saves to a PLY file.
A class for storing a list of text lines.
Definition: CStringList.h:32
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.
Lightweight 3D point (float version).
std::string getSavePLYErrorString() const
Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file...
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.
A virtual base class that implements the capability of importing 3D point clouds and faces from a fil...
GLsizei const GLchar ** string
Definition: glext.h:4101
std::string getLoadPLYErrorString() const
Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual size_t PLY_export_get_vertex_count() const =0
In a base class, return the number of vertices.
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color=nullptr)=0
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point...
A RGB color - floats in the range [0,1].
Definition: TColor.h:78
bool loadFromPlyFile(const std::string &filename, CStringList *file_comments=nullptr, CStringList *file_obj_info=nullptr)
Loads from a PLY file.
virtual void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::utils::TColorf &pt_color) const =0
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point...
A virtual base class that implements the capability of exporting 3D point clouds and faces to a file ...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019