58 template<
typename Po
intT>
161 encodeAverageOfPoints (
const typename std::vector<int>& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
163 unsigned int avgRed = 0;
164 unsigned int avgGreen = 0;
165 unsigned int avgBlue = 0;
168 std::size_t len = indexVector_arg.size ();
169 for (std::size_t i = 0; i < len; i++)
172 const int& idx = indexVector_arg[i];
173 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
174 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
177 avgRed += (colorInt >> 0) & 0xFF;
178 avgGreen += (colorInt >> 8) & 0xFF;
179 avgBlue += (colorInt >> 16) & 0xFF;
186 avgRed /=
static_cast<unsigned int> (len);
187 avgGreen /=
static_cast<unsigned int> (len);
188 avgBlue /=
static_cast<unsigned int> (len);
208 encodePoints (
const typename std::vector<int>& indexVector_arg,
unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg)
211 unsigned int avgGreen;
212 unsigned int avgBlue;
215 avgRed = avgGreen = avgBlue = 0;
218 std::size_t len = indexVector_arg.size ();
219 for (std::size_t i = 0; i < len; i++)
222 const int& idx = indexVector_arg[i];
223 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
224 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
227 avgRed += (colorInt >> 0) & 0xFF;
228 avgGreen += (colorInt >> 8) & 0xFF;
229 avgBlue += (colorInt >> 16) & 0xFF;
235 unsigned char diffRed;
236 unsigned char diffGreen;
237 unsigned char diffBlue;
240 avgRed /=
static_cast<unsigned int> (len);
241 avgGreen /=
static_cast<unsigned int> (len);
242 avgBlue /=
static_cast<unsigned int> (len);
245 for (std::size_t i = 0; i < len; i++)
247 const int& idx = indexVector_arg[i];
248 const char* idxPointPtr =
reinterpret_cast<const char*
> (&(*inputCloud_arg)[idx]);
249 const int& colorInt = *
reinterpret_cast<const int*
> (idxPointPtr+rgba_offset_arg);
252 diffRed = (
static_cast<unsigned char> (avgRed)) ^
static_cast<unsigned char> (((colorInt >> 0) & 0xFF));
253 diffGreen = (
static_cast<unsigned char> (avgGreen)) ^
static_cast<unsigned char> (((colorInt >> 8) & 0xFF));
254 diffBlue = (
static_cast<unsigned char> (avgBlue)) ^
static_cast<unsigned char> (((colorInt >> 16) & 0xFF));
287 decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
289 assert (beginIdx_arg <= endIdx_arg);
292 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
305 for (std::size_t i = 0; i < pointCount; i++)
307 unsigned int colorInt;
321 colorInt = ((avgRed ^ diffRed) << 0) |
322 ((avgGreen ^ diffGreen) << 8) |
323 ((avgBlue ^ diffBlue) << 16);
328 colorInt = (avgRed << 0) | (avgGreen << 8) | (avgBlue << 16);
331 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
332 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
345 setDefaultColor (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg,
unsigned char rgba_offset_arg)
347 assert (beginIdx_arg <= endIdx_arg);
350 unsigned int pointCount =
static_cast<unsigned int> (endIdx_arg - beginIdx_arg);
353 for (std::size_t i = 0; i < pointCount; i++)
355 char* idxPointPtr =
reinterpret_cast<char*
> (&(*outputCloud_arg)[beginIdx_arg + i]);
356 int& pointColor = *
reinterpret_cast<int*
> (idxPointPtr+rgba_offset_arg);
386 template<
typename Po
intT>
394 #define PCL_INSTANTIATE_ColorCoding(T) template class PCL_EXPORTS pcl::octree::ColorCoding<T>;