Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_FEATURES_QUANTIZED_MAP
00039 #define PCL_FEATURES_QUANTIZED_MAP
00040
00041 #include <vector>
00042 #include <pcl/pcl_macros.h>
00043
00044 namespace pcl
00045 {
00046 class PCL_EXPORTS QuantizedMap
00047 {
00048 public:
00049
00050 QuantizedMap ();
00051 QuantizedMap (size_t width, size_t height);
00052 QuantizedMap (const QuantizedMap & copy_me);
00053
00054 virtual ~QuantizedMap ();
00055
00056 inline size_t
00057 getWidth () const { return (width_); }
00058
00059 inline size_t
00060 getHeight () const { return (height_); }
00061
00062 inline unsigned char*
00063 getData () { return (&data_[0]); }
00064
00065 inline const unsigned char*
00066 getData () const { return (&data_[0]); }
00067
00068 inline QuantizedMap
00069 getSubMap (size_t x,
00070 size_t y,
00071 size_t width,
00072 size_t height)
00073 {
00074 QuantizedMap subMap(width, height);
00075
00076 for (size_t row_index = 0; row_index < height; ++row_index)
00077 {
00078 for (size_t col_index = 0; col_index < width; ++col_index)
00079 {
00080
00081
00082
00083 subMap (col_index, row_index) = (*this) (col_index + x, row_index + y);
00084 }
00085 }
00086
00087 return subMap;
00088 }
00089
00090 void
00091 resize (size_t width, size_t height);
00092
00093 inline unsigned char &
00094 operator() (const size_t x, const size_t y)
00095 {
00096 return (data_[y*width_+x]);
00097 }
00098
00099 inline const unsigned char &
00100 operator() (const size_t x, const size_t y) const
00101 {
00102 return (data_[y*width_+x]);
00103 }
00104
00105 static void
00106 spreadQuantizedMap (const QuantizedMap & input_map, QuantizedMap & output_map, size_t spreading_size);
00107
00108 void
00109 serialize (std::ostream & stream) const
00110 {
00111 const int width = static_cast<int> (width_);
00112 const int height = static_cast<int> (height_);
00113
00114 stream.write (reinterpret_cast<const char*> (&width), sizeof (width));
00115 stream.write (reinterpret_cast<const char*> (&height), sizeof (height));
00116
00117 const int num_of_elements = static_cast<int> (data_.size ());
00118 stream.write (reinterpret_cast<const char*> (&num_of_elements), sizeof (num_of_elements));
00119 for (int element_index = 0; element_index < num_of_elements; ++element_index)
00120 {
00121 stream.write (reinterpret_cast<const char*> (&(data_[element_index])), sizeof (data_[element_index]));
00122 }
00123 }
00124
00125 void
00126 deserialize (std::istream & stream)
00127 {
00128 int width;
00129 int height;
00130
00131 stream.read (reinterpret_cast<char*> (&width), sizeof (width));
00132 stream.read (reinterpret_cast<char*> (&height), sizeof (height));
00133
00134 width_ = static_cast<size_t> (width);
00135 height_ = static_cast<size_t> (height);
00136
00137 int num_of_elements;
00138 stream.read (reinterpret_cast<char*> (&num_of_elements), sizeof (num_of_elements));
00139 data_.resize (num_of_elements);
00140 for (int element_index = 0; element_index < num_of_elements; ++element_index)
00141 {
00142 stream.read (reinterpret_cast<char*> (&(data_[element_index])), sizeof (data_[element_index]));
00143 }
00144 }
00145
00146
00147
00148 std::vector<unsigned char> data_;
00149 size_t width_;
00150 size_t height_;
00151
00152 };
00153 }
00154
00155 #endif