Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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 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 text format.
31  * \param[out] file_comments If provided (!=NULL) the list of comment strings stored in the file will be returned.
32  * \param[out] file_obj_info If provided (!=NULL) the list of "object info" strings stored in the file will be returned.
33  * \return false on any error in the file format or reading it. To obtain more details on the error you can call getLoadPLYErrorString()
34  */
36  const std::string &filename,
37  CStringList *file_comments = NULL,
38  CStringList *file_obj_info = NULL );
39 
40  /** Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file was loaded without problems. */
41  std::string getLoadPLYErrorString() const { return m_ply_import_last_error; }
42 
43  protected:
44  /** @name PLY Import virtual methods to implement in base classes
45  @{ */
46 
47  /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex */
48  virtual void PLY_import_set_vertex_count(const size_t N) = 0;
49 
50  /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_face */
51  virtual void PLY_import_set_face_count(const size_t N) = 0;
52 
53  /** In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
54  * \param pt_color Will be NULL if the loaded file does not provide color info.
55  */
56  virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color = NULL) = 0;
57 
58  /** @} */
59 
60  private:
62 
63  }; // End of class def.
64 
65 
66  /** A virtual base class that implements the capability of exporting 3D point clouds and faces to a file in the Stanford PLY format.
67  * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY
68  * \sa PLY_Importer
69  * \ingroup mrpt_base_grp
70  */
72  {
73  public:
74  /** Saves to a PLY file.
75  * \param[in] filename The filename to be saved.
76  * \param[in] file_comments If provided (!=NULL) the list of comment strings stored in the file will be returned.
77  * \param[in] file_obj_info If provided (!=NULL) the list of "object info" strings stored in the file will be returned.
78  * \return false on any error writing the file. To obtain more details on the error you can call getSavePLYErrorString()
79  */
81  const std::string & filename,
82  bool save_in_binary = false,
83  const CStringList & file_comments = CStringList(),
84  const CStringList & file_obj_info = CStringList() ) const;
85 
86  /** Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file was loaded without problems. */
87  std::string getSavePLYErrorString() const { return m_ply_export_last_error; }
88 
89  protected:
90  /** @name PLY Export virtual methods to implement in base classes
91  @{ */
92 
93  /** In a base class, return the number of vertices */
94  virtual size_t PLY_export_get_vertex_count() const = 0;
95 
96  /** In a base class, return the number of faces */
97  virtual size_t PLY_export_get_face_count() const = 0;
98 
99  /** In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
100  * \param pt_color Will be NULL if the loaded file does not provide color info.
101  */
102  virtual void PLY_export_get_vertex(
103  const size_t idx,
105  bool &pt_has_color,
106  mrpt::utils::TColorf &pt_color) const = 0;
107 
108  /** @} */
109 
110  private:
111  mutable std::string m_ply_export_last_error;
112 
113  }; // End of class def.
114 
115  } // End of namespace
116 } // end of namespace
117 #endif
A class for storing a list of text lines.
Definition: CStringList.h:33
A virtual base class that implements the capability of exporting 3D point clouds and faces to a file ...
std::string getSavePLYErrorString() const
Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file...
virtual size_t PLY_export_get_face_count() const =0
In a base class, return the number of faces.
virtual size_t PLY_export_get_vertex_count() const =0
In a base class, return the number of vertices.
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.
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 virtual base class that implements the capability of importing 3D point clouds and faces from a fil...
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.
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.
bool loadFromPlyFile(const std::string &filename, CStringList *file_comments=NULL, CStringList *file_obj_info=NULL)
Loads from a PLY file.
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color=NULL)=0
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
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.
Lightweight 3D point (float version).
A RGB color - floats in the range [0,1].
Definition: TColor.h:53



Page generated by Doxygen 1.9.1 for MRPT 1.4.0 SVN: at Mon Apr 18 04:08:57 UTC 2022