00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef PLY_IMPORT_EXPORT_H 00029 #define PLY_IMPORT_EXPORT_H 00030 00031 #include <mrpt/utils/utils_defs.h> 00032 #include <mrpt/utils/CStringList.h> 00033 #include <mrpt/utils/TColor.h> 00034 #include <mrpt/math/lightweight_geom_data.h> 00035 00036 namespace mrpt 00037 { 00038 namespace utils 00039 { 00040 /** A virtual base class that implements the capability of importing 3D point clouds and faces from a file in the Stanford PLY format. 00041 * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY 00042 * \sa PLY_Exporter 00043 * \ingroup mrpt_base_grp 00044 */ 00045 class BASE_IMPEXP PLY_Importer 00046 { 00047 public: 00048 /** Loads from a PLY file. 00049 * \param[in] filename The filename to open. It can be either in binary or text format. 00050 * \param[out] file_comments If provided (!=NULL) the list of comment strings stored in the file will be returned. 00051 * \param[out] file_obj_info If provided (!=NULL) the list of "object info" strings stored in the file will be returned. 00052 * \return false on any error in the file format or reading it. To obtain more details on the error you can call getLoadPLYErrorString() 00053 */ 00054 bool loadFromPlyFile( 00055 const std::string &filename, 00056 CStringList *file_comments = NULL, 00057 CStringList *file_obj_info = NULL ); 00058 00059 /** Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file was loaded without problems. */ 00060 std::string getLoadPLYErrorString() const { return m_ply_import_last_error; } 00061 00062 protected: 00063 /** @name PLY Import virtual methods to implement in base classes 00064 @{ */ 00065 00066 /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex */ 00067 virtual void PLY_import_set_vertex_count(const size_t N) = 0; 00068 00069 /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_face */ 00070 virtual void PLY_import_set_face_count(const size_t N) = 0; 00071 00072 /** In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point. 00073 * \param pt_color Will be NULL if the loaded file does not provide color info. 00074 */ 00075 virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color = NULL) = 0; 00076 00077 /** @} */ 00078 00079 private: 00080 std::string m_ply_import_last_error; 00081 00082 }; // End of class def. 00083 00084 00085 /** A virtual base class that implements the capability of exporting 3D point clouds and faces to a file in the Stanford PLY format. 00086 * \sa http://www.mrpt.org/Support_for_the_Stanford_3D_models_file_format_PLY 00087 * \sa PLY_Importer 00088 * \ingroup mrpt_base_grp 00089 */ 00090 class BASE_IMPEXP PLY_Exporter 00091 { 00092 public: 00093 /** Saves to a PLY file. 00094 * \param[in] filename The filename to be saved. 00095 * \param[in] file_comments If provided (!=NULL) the list of comment strings stored in the file will be returned. 00096 * \param[in] file_obj_info If provided (!=NULL) the list of "object info" strings stored in the file will be returned. 00097 * \return false on any error writing the file. To obtain more details on the error you can call getSavePLYErrorString() 00098 */ 00099 bool saveToPlyFile( 00100 const std::string & filename, 00101 bool save_in_binary = false, 00102 const CStringList & file_comments = CStringList(), 00103 const CStringList & file_obj_info = CStringList() ) const; 00104 00105 /** Return a description of the error if loadFromPlyFile() returned false, or an empty string if the file was loaded without problems. */ 00106 std::string getSavePLYErrorString() const { return m_ply_export_last_error; } 00107 00108 protected: 00109 /** @name PLY Export virtual methods to implement in base classes 00110 @{ */ 00111 00112 /** In a base class, return the number of vertices */ 00113 virtual size_t PLY_export_get_vertex_count() const = 0; 00114 00115 /** In a base class, return the number of faces */ 00116 virtual size_t PLY_export_get_face_count() const = 0; 00117 00118 /** In a base class, will be called after PLY_export_get_vertex_count() once for each exported point. 00119 * \param pt_color Will be NULL if the loaded file does not provide color info. 00120 */ 00121 virtual void PLY_export_get_vertex( 00122 const size_t idx, 00123 mrpt::math::TPoint3Df &pt, 00124 bool &pt_has_color, 00125 mrpt::utils::TColorf &pt_color) const = 0; 00126 00127 /** @} */ 00128 00129 private: 00130 mutable std::string m_ply_export_last_error; 00131 00132 }; // End of class def. 00133 00134 } // End of namespace 00135 } // end of namespace 00136 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |