Point Cloud Library (PCL)
1.7.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2012, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id: outofcore_node_data.h 6915 2012-08-22 10:54:21Z stfox88 $ 00037 */ 00038 00039 #ifndef PCL_OUTOFCORE_OCTREE_NODE_METADATA_H_ 00040 #define PCL_OUTOFCORE_OCTREE_NODE_METADATA_H_ 00041 00042 #include <pcl/pcl_macros.h> 00043 #include <pcl/outofcore/boost.h> 00044 #include <pcl/outofcore/cJSON.h> 00045 00046 #include <pcl/common/eigen.h> 00047 00048 #include <ostream> 00049 00050 namespace pcl 00051 { 00052 namespace outofcore 00053 { 00054 /** \class OutofcoreOctreeNodeMetadata 00055 * 00056 * \brief Encapsulated class to read JSON metadata into memory, and write the JSON metadata for each 00057 * node. 00058 * 00059 * This class encapsulates the outofcore node metadata 00060 * serialization/deserialization. At the time it was written, 00061 * this depended on cJSON to write JSON objects to disk. This 00062 * class can be extended to have arbitrary ascii metadata fields 00063 * saved to the metadata object file on disk. 00064 * 00065 * The JSON file is formatted in the following way: 00066 * \verbatim 00067 { 00068 "version": 3, 00069 "bb_min": [xxx,yyy,zzz], 00070 "bb_max": [xxx,yyy,zzz], 00071 "bin": "path_to_data.pcd" 00072 } 00073 \endverbatim 00074 * 00075 * Any properties not stored in the metadata file are computed 00076 * when the file is loaded (e.g. \ref midpoint_xyz_). By 00077 * convention, the JSON files are stored on disk with .oct_idx 00078 * extension. 00079 * 00080 * \ingroup outofcore 00081 * \author Stephen Fox (foxstephend@gmail.com) 00082 */ 00083 class PCL_EXPORTS OutofcoreOctreeNodeMetadata 00084 { 00085 00086 public: 00087 //public typedefs 00088 typedef boost::shared_ptr<OutofcoreOctreeNodeMetadata> Ptr; 00089 typedef boost::shared_ptr<const OutofcoreOctreeNodeMetadata> ConstPtr; 00090 00091 /** \brief Empty constructor */ 00092 OutofcoreOctreeNodeMetadata (); 00093 ~OutofcoreOctreeNodeMetadata (); 00094 00095 /** \brief Copy constructor */ 00096 OutofcoreOctreeNodeMetadata (const OutofcoreOctreeNodeMetadata& orig); 00097 00098 /** \brief Get the lower bounding box corner */ 00099 const Eigen::Vector3d& 00100 getBoundingBoxMin () const; 00101 /** \brief Set the lower bounding box corner */ 00102 void 00103 setBoundingBoxMin (const Eigen::Vector3d& min_bb); 00104 /** \brief Get the upper bounding box corner */ 00105 const Eigen::Vector3d& 00106 getBoundingBoxMax () const; 00107 /** \brief Set the upper bounding box corner */ 00108 void 00109 setBoundingBoxMax (const Eigen::Vector3d& max_bb); 00110 00111 /** \brief Get the lower and upper corners of the bounding box enclosing this node */ 00112 void 00113 getBoundingBox (Eigen::Vector3d &min_bb, Eigen::Vector3d &max_bb) const; 00114 /** \brief Set the lower and upper corners of the bounding box */ 00115 void 00116 setBoundingBox (const Eigen::Vector3d& min_bb, const Eigen::Vector3d& max_bb); 00117 00118 /** \brief Get the directory path name; this is the parent_path of */ 00119 const boost::filesystem::path& 00120 getDirectoryPathname () const; 00121 /** \brief Set the directory path name */ 00122 void 00123 setDirectoryPathname (const boost::filesystem::path& directory_pathname); 00124 00125 /** \brief Get the path to the PCD file */ 00126 const boost::filesystem::path& 00127 getPCDFilename () const; 00128 /** \brief Set the point filename; extension .pcd */ 00129 void 00130 setPCDFilename (const boost::filesystem::path& point_filename); 00131 00132 /** \brief et the outofcore version read from the "version" field of the JSON object */ 00133 int 00134 getOutofcoreVersion () const; 00135 /** \brief Set the outofcore version stored in the "version" field of the JSON object */ 00136 void 00137 setOutofcoreVersion (const int version); 00138 00139 /** \brief Sets the name of the JSON file */ 00140 const boost::filesystem::path& 00141 getMetadataFilename () const; 00142 /** \brief Gets the name of the JSON file */ 00143 void 00144 setMetadataFilename (const boost::filesystem::path& path_to_metadata); 00145 00146 /** \brief Get the midpoint of this node's bounding box */ 00147 const Eigen::Vector3d& 00148 getVoxelCenter () const; 00149 00150 /** \brief Writes the data to a JSON file located at \ref metadata_filename_ */ 00151 void 00152 serializeMetadataToDisk (); 00153 00154 /** \brief Loads the data from a JSON file located at \ref metadata_filename_ */ 00155 int 00156 loadMetadataFromDisk (); 00157 /** \brief Loads the data from a JSON file located at \ref metadata_filename_ */ 00158 int 00159 loadMetadataFromDisk (const boost::filesystem::path& path_to_metadata); 00160 00161 friend 00162 std::ostream& operator<<(std::ostream& os, const OutofcoreOctreeNodeMetadata& metadata_arg); 00163 00164 protected: 00165 /** \brief The X,Y,Z axes-aligned minimum corner for the bounding box */ 00166 Eigen::Vector3d min_bb_; 00167 /** \brief The X,Y,Z axes-aligned maximum corner for the bounding box */ 00168 Eigen::Vector3d max_bb_; 00169 /** \brief Path to PCD file (i.e. "bin"ary point data) */ 00170 boost::filesystem::path binary_point_filename_; 00171 /** \brief Voxel center; not stored on disk */ 00172 Eigen::Vector3d midpoint_xyz_; 00173 /** \brief Directory this metadata belongs in */ 00174 boost::filesystem::path directory_; 00175 /** \brief Metadata (JSON) file pathname (oct_idx extension JSON file) */ 00176 boost::filesystem::path metadata_filename_; 00177 /** \brief Outofcore library version identifier */ 00178 int outofcore_version_; 00179 00180 /** \brief Computes the midpoint; used when bounding box is changed */ 00181 inline void 00182 updateVoxelCenter () 00183 { 00184 midpoint_xyz_ = (this->max_bb_ + this->min_bb_)/static_cast<double>(2.0); 00185 } 00186 }; 00187 }//namespace outofcore 00188 }//namespace pcl 00189 00190 #endif // PCL_OUTOFCORE_OCTREE_NODE_METADATA_H_