38 #ifndef POINT_COMPRESSION_H
39 #define POINT_COMPRESSION_H
58 template<
typename Po
intT>
63 typedef boost::shared_ptr<PointCloud> PointCloudPtr;
64 typedef boost::shared_ptr<const PointCloud> PointCloudConstPtr;
69 output_ (), pointDiffDataVector_ (), pointDiffDataVectorIterator_ (),
70 pointCompressionResolution_ (0.001f)
86 pointCompressionResolution_ = precision_arg;
95 return (pointCompressionResolution_);
104 pointDiffDataVector_.reserve (pointCount_arg * 3);
111 pointDiffDataVector_.clear ();
118 pointDiffDataVectorIterator_ = pointDiffDataVector_.begin ();
125 return (pointDiffDataVector_);
134 encodePoints (
const typename std::vector<int>& indexVector_arg,
const double* referencePoint_arg,
135 PointCloudConstPtr inputCloud_arg)
139 len = indexVector_arg.size ();
142 for (i = 0; i < len; i++)
144 unsigned char diffX, diffY, diffZ;
147 const int& idx = indexVector_arg[i];
148 const PointT& idxPoint = inputCloud_arg->points[idx];
151 diffX =
static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.x - referencePoint_arg[0]) / pointCompressionResolution_))));
152 diffY =
static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.y - referencePoint_arg[1]) / pointCompressionResolution_))));
153 diffZ =
static_cast<unsigned char> (max (-127, min<int>(127, static_cast<int> ((idxPoint.z - referencePoint_arg[2]) / pointCompressionResolution_))));
156 pointDiffDataVector_.push_back (diffX);
157 pointDiffDataVector_.push_back (diffY);
158 pointDiffDataVector_.push_back (diffZ);
169 decodePoints (PointCloudPtr outputCloud_arg,
const double* referencePoint_arg, std::size_t beginIdx_arg,
170 std::size_t endIdx_arg)
173 unsigned int pointCount;
175 assert (beginIdx_arg <= endIdx_arg);
177 pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
180 for (i = 0; i < pointCount; i++)
183 const unsigned char& diffX =
static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
184 const unsigned char& diffY =
static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
185 const unsigned char& diffZ =
static_cast<unsigned char> (*(pointDiffDataVectorIterator_++));
188 PointT& point = outputCloud_arg->points[beginIdx_arg + i];
191 point.x =
static_cast<float> (referencePoint_arg[0] + diffX * pointCompressionResolution_);
192 point.y =
static_cast<float> (referencePoint_arg[1] + diffY * pointCompressionResolution_);
193 point.z =
static_cast<float> (referencePoint_arg[2] + diffZ * pointCompressionResolution_);
202 std::vector<char> pointDiffDataVector_;
205 std::vector<char>::const_iterator pointDiffDataVectorIterator_;
208 float pointCompressionResolution_;
213 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;