55 template<
typename Po
intT>
158 encodeAverageOfPoints (
const typename std::vector<int>& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
160 unsigned int avgRed = 0;
161 unsigned int avgGreen = 0;
162 unsigned int avgBlue = 0;
165 std::size_t len = indexVector_arg.size ();
166 for (std::size_t i = 0; i < len; i++)
169 const int& idx = indexVector_arg[i];
170 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
171 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
174 avgRed += (colorInt >> 0) & 0xFF;
175 avgGreen += (colorInt >> 8) & 0xFF;
176 avgBlue += (colorInt >> 16) & 0xFF;
183 avgRed /=
static_cast<unsigned int> (len);
184 avgGreen /=
static_cast<unsigned int> (len);
185 avgBlue /=
static_cast<unsigned int> (len);
205 encodePoints (
const typename std::vector<int>& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
208 unsigned int avgGreen;
209 unsigned int avgBlue;
212 avgRed = avgGreen = avgBlue = 0;
215 std::size_t len = indexVector_arg.size ();
216 for (std::size_t i = 0; i < len; i++)
219 const int& idx = indexVector_arg[i];
220 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
221 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
224 avgRed += (colorInt >> 0) & 0xFF;
225 avgGreen += (colorInt >> 8) & 0xFF;
226 avgBlue += (colorInt >> 16) & 0xFF;
232 unsigned char diffRed;
233 unsigned char diffGreen;
234 unsigned char diffBlue;
237 avgRed /=
static_cast<unsigned int> (len);
238 avgGreen /=
static_cast<unsigned int> (len);
239 avgBlue /=
static_cast<unsigned int> (len);
242 for (std::size_t i = 0; i < len; i++)
244 const int& idx = indexVector_arg[i];
245 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
246 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
249 diffRed = (
static_cast<unsigned char> (avgRed)) ^
static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
250 diffGreen = (
static_cast<unsigned char> (avgGreen)) ^
static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
251 diffBlue = (
static_cast<unsigned char> (avgBlue)) ^
static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
284 decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
286 assert (beginIdx_arg <= endIdx_arg);
289 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
302 for (std::size_t i = 0; i < pointCount; i++)
304 unsigned int colorInt;
318 colorInt = ((avgRed ^ diffRed) << 0) |
319 ((avgGreen ^ diffGreen) << 8) |
320 ((avgBlue ^ diffBlue) << 16);
325 colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
328 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
329 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
342 setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
344 assert (beginIdx_arg <= endIdx_arg);
347 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
350 for (std::size_t i = 0; i < pointCount; i++)
352 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
353 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
383 template<
typename Po
intT>
391 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;