Main MRPT website > C++ reference
MRPT logo
PLY_import_export.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef PLY_IMPORT_EXPORT_H
29 #define PLY_IMPORT_EXPORT_H
30 
31 #include <mrpt/utils/utils_defs.h>
32 #include <mrpt/utils/CStringList.h>
33 #include <mrpt/utils/TColor.h>
35 
36 namespace mrpt
37 {
38  namespace utils
39  {
40  /** A virtual base class that implements the capability of importing 3D point clouds and faces from a file in the Stanford PLY format.
41  * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY
42  * \sa PLY_Exporter
43  * \ingroup mrpt_base_grp
44  */
46  {
47  public:
48  /** Loads from a PLY file.
49  * \param[in] filename The filename to open. It can be either in binary or text format.
50  * \param[out] file_comments If provided (!=NULL) the list of comment strings stored in the file will be returned.
51  * \param[out] file_obj_info If provided (!=NULL) the list of "object info" strings stored in the file will be returned.
52  * \return false on any error in the file format or reading it. To obtain more details on the error you can call getLoadPLYErrorString()
53  */
54  bool loadFromPlyFile(
55  const std::string &filename,
56  CStringList *file_comments = NULL,
57  CStringList *file_obj_info = NULL );
58 
59  /** Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file was loaded without problems. */
60  std::string getLoadPLYErrorString() const { return m_ply_import_last_error; }
61 
62  protected:
63  /** @name PLY Import virtual methods to implement in base classes
64  @{ */
65 
66  /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex */
67  virtual void PLY_import_set_vertex_count(const size_t N) = 0;
68 
69  /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_face */
70  virtual void PLY_import_set_face_count(const size_t N) = 0;
71 
72  /** In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
73  * \param pt_color Will be NULL if the loaded file does not provide color info.
74  */
75  virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color = NULL) = 0;
76 
77  /** @} */
78 
79  private:
81 
82  }; // End of class def.
83 
84 
85  /** A virtual base class that implements the capability of exporting 3D point clouds and faces to a file in the Stanford PLY format.
86  * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY
87  * \sa PLY_Importer
88  * \ingroup mrpt_base_grp
89  */
91  {
92  public:
93  /** Saves to a PLY file.
94  * \param[in] filename The filename to be saved.
95  * \param[in] file_comments If provided (!=NULL) the list of comment strings stored in the file will be returned.
96  * \param[in] file_obj_info If provided (!=NULL) the list of "object info" strings stored in the file will be returned.
97  * \return false on any error writing the file. To obtain more details on the error you can call getSavePLYErrorString()
98  */
99  bool saveToPlyFile(
100  const std::string & filename,
101  bool save_in_binary = false,
102  const CStringList & file_comments = CStringList(),
103  const CStringList & file_obj_info = CStringList() ) const;
104 
105  /** Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file was loaded without problems. */
106  std::string getSavePLYErrorString() const { return m_ply_export_last_error; }
107 
108  protected:
109  /** @name PLY Export virtual methods to implement in base classes
110  @{ */
111 
112  /** In a base class, return the number of vertices */
113  virtual size_t PLY_export_get_vertex_count() const = 0;
114 
115  /** In a base class, return the number of faces */
116  virtual size_t PLY_export_get_face_count() const = 0;
117 
118  /** In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
119  * \param pt_color Will be NULL if the loaded file does not provide color info.
120  */
121  virtual void PLY_export_get_vertex(
122  const size_t idx,
124  bool &pt_has_color,
125  mrpt::utils::TColorf &pt_color) const = 0;
126 
127  /** @} */
128 
129  private:
130  mutable std::string m_ply_export_last_error;
131 
132  }; // End of class def.
133 
134  } // End of namespace
135 } // end of namespace
136 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013