Point Cloud Library (PCL) 1.13.1
Loading...
Searching...
No Matches
outofcore_node_data.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010-2012, Willow Garage, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of Willow Garage, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 * $Id: outofcore_node_data.h 6915 2012-08-22 10:54:21Z stfox88 $
37 */
38
39#pragma once
40
41#include <pcl/memory.h>
42#include <pcl/pcl_macros.h>
43#include <pcl/outofcore/cJSON.h>
44
45#include <pcl/common/eigen.h>
46
47#include <boost/filesystem.hpp>
48
49#include <ostream>
50
51namespace pcl
52{
53 namespace outofcore
54 {
55 /** \class OutofcoreOctreeNodeMetadata
56 *
57 * \brief Encapsulated class to read JSON metadata into memory, and write the JSON metadata for each
58 * node.
59 *
60 * This class encapsulates the outofcore node metadata
61 * serialization/deserialization. At the time it was written,
62 * this depended on cJSON to write JSON objects to disk. This
63 * class can be extended to have arbitrary ascii metadata fields
64 * saved to the metadata object file on disk.
65 *
66 * The JSON file is formatted in the following way:
67 * \verbatim
68 {
69 "version": 3,
70 "bb_min": [xxx,yyy,zzz],
71 "bb_max": [xxx,yyy,zzz],
72 "bin": "path_to_data.pcd"
73 }
74 \endverbatim
75 *
76 * Any properties not stored in the metadata file are computed
77 * when the file is loaded (e.g. \ref midpoint_xyz_). By
78 * convention, the JSON files are stored on disk with .oct_idx
79 * extension.
80 *
81 * \ingroup outofcore
82 * \author Stephen Fox (foxstephend@gmail.com)
83 */
85 {
86
87 public:
88 //public typedefs
89 using Ptr = shared_ptr<OutofcoreOctreeNodeMetadata>;
90 using ConstPtr = shared_ptr<const OutofcoreOctreeNodeMetadata>;
91
92 /** \brief Empty constructor */
95
96 /** \brief Copy constructor */
98
99 /** \brief Get the lower bounding box corner */
100 const Eigen::Vector3d&
102 /** \brief Set the lower bounding box corner */
103 void
104 setBoundingBoxMin (const Eigen::Vector3d& min_bb);
105 /** \brief Get the upper bounding box corner */
106 const Eigen::Vector3d&
108 /** \brief Set the upper bounding box corner */
109 void
110 setBoundingBoxMax (const Eigen::Vector3d& max_bb);
111
112 /** \brief Get the lower and upper corners of the bounding box enclosing this node */
113 void
114 getBoundingBox (Eigen::Vector3d &min_bb, Eigen::Vector3d &max_bb) const;
115 /** \brief Set the lower and upper corners of the bounding box */
116 void
117 setBoundingBox (const Eigen::Vector3d& min_bb, const Eigen::Vector3d& max_bb);
118
119 /** \brief Get the directory path name; this is the parent_path of */
120 const boost::filesystem::path&
122 /** \brief Set the directory path name */
123 void
124 setDirectoryPathname (const boost::filesystem::path& directory_pathname);
125
126 /** \brief Get the path to the PCD file */
127 const boost::filesystem::path&
129 /** \brief Set the point filename; extension .pcd */
130 void
131 setPCDFilename (const boost::filesystem::path& point_filename);
132
133 /** \brief et the outofcore version read from the "version" field of the JSON object */
134 int
136 /** \brief Set the outofcore version stored in the "version" field of the JSON object */
137 void
138 setOutofcoreVersion (const int version);
139
140 /** \brief Sets the name of the JSON file */
141 const boost::filesystem::path&
143 /** \brief Gets the name of the JSON file */
144 void
145 setMetadataFilename (const boost::filesystem::path& path_to_metadata);
146
147 /** \brief Get the midpoint of this node's bounding box */
148 const Eigen::Vector3d&
150
151 /** \brief Writes the data to a JSON file located at \ref metadata_filename_ */
152 void
154
155 /** \brief Loads the data from a JSON file located at \ref metadata_filename_ */
156 int
158 /** \brief Loads the data from a JSON file located at \ref metadata_filename_ */
159 int
160 loadMetadataFromDisk (const boost::filesystem::path& path_to_metadata);
161
162 friend
163 std::ostream& operator<<(std::ostream& os, const OutofcoreOctreeNodeMetadata& metadata_arg);
164
165 protected:
166 /** \brief The X,Y,Z axes-aligned minimum corner for the bounding box */
167 Eigen::Vector3d min_bb_;
168 /** \brief The X,Y,Z axes-aligned maximum corner for the bounding box */
169 Eigen::Vector3d max_bb_;
170 /** \brief Path to PCD file (i.e. "bin"ary point data) */
171 boost::filesystem::path binary_point_filename_;
172 /** \brief Voxel center; not stored on disk */
173 Eigen::Vector3d midpoint_xyz_;
174 /** \brief Directory this metadata belongs in */
175 boost::filesystem::path directory_;
176 /** \brief Metadata (JSON) file pathname (oct_idx extension JSON file) */
177 boost::filesystem::path metadata_filename_;
178 /** \brief Outofcore library version identifier */
180
181 /** \brief Computes the midpoint; used when bounding box is changed */
182 inline void
184 {
185 midpoint_xyz_ = (this->max_bb_ + this->min_bb_)/static_cast<double>(2.0);
186 }
187 };
188 }//namespace outofcore
189}//namespace pcl
Encapsulated class to read JSON metadata into memory, and write the JSON metadata for each node.
const Eigen::Vector3d & getVoxelCenter() const
Get the midpoint of this node's bounding box.
shared_ptr< const OutofcoreOctreeNodeMetadata > ConstPtr
shared_ptr< OutofcoreOctreeNodeMetadata > Ptr
Eigen::Vector3d midpoint_xyz_
Voxel center; not stored on disk.
const Eigen::Vector3d & getBoundingBoxMax() const
Get the upper bounding box corner.
friend std::ostream & operator<<(std::ostream &os, const OutofcoreOctreeNodeMetadata &metadata_arg)
boost::filesystem::path metadata_filename_
Metadata (JSON) file pathname (oct_idx extension JSON file)
const boost::filesystem::path & getMetadataFilename() const
Sets the name of the JSON file.
const boost::filesystem::path & getPCDFilename() const
Get the path to the PCD file.
void setMetadataFilename(const boost::filesystem::path &path_to_metadata)
Gets the name of the JSON file.
void setPCDFilename(const boost::filesystem::path &point_filename)
Set the point filename; extension .pcd.
int loadMetadataFromDisk()
Loads the data from a JSON file located at metadata_filename_.
Eigen::Vector3d max_bb_
The X,Y,Z axes-aligned maximum corner for the bounding box.
void setOutofcoreVersion(const int version)
Set the outofcore version stored in the "version" field of the JSON object.
void updateVoxelCenter()
Computes the midpoint; used when bounding box is changed.
int outofcore_version_
Outofcore library version identifier.
boost::filesystem::path binary_point_filename_
Path to PCD file (i.e.
void setBoundingBox(const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb)
Set the lower and upper corners of the bounding box.
void setBoundingBoxMin(const Eigen::Vector3d &min_bb)
Set the lower bounding box corner.
void getBoundingBox(Eigen::Vector3d &min_bb, Eigen::Vector3d &max_bb) const
Get the lower and upper corners of the bounding box enclosing this node.
void serializeMetadataToDisk()
Writes the data to a JSON file located at metadata_filename_.
OutofcoreOctreeNodeMetadata(const OutofcoreOctreeNodeMetadata &orig)
Copy constructor.
const boost::filesystem::path & getDirectoryPathname() const
Get the directory path name; this is the parent_path of
void setDirectoryPathname(const boost::filesystem::path &directory_pathname)
Set the directory path name.
int loadMetadataFromDisk(const boost::filesystem::path &path_to_metadata)
Loads the data from a JSON file located at metadata_filename_.
boost::filesystem::path directory_
Directory this metadata belongs in.
void setBoundingBoxMax(const Eigen::Vector3d &max_bb)
Set the upper bounding box corner.
Eigen::Vector3d min_bb_
The X,Y,Z axes-aligned minimum corner for the bounding box.
const Eigen::Vector3d & getBoundingBoxMin() const
Get the lower bounding box corner.
int getOutofcoreVersion() const
et the outofcore version read from the "version" field of the JSON object
Defines functions, macros and traits for allocating and using memory.
Defines all the PCL and non-PCL macros used.