5#include <SimoxUtility/color/ColorMap.h>
9#include <RobotAPI/interface/ArViz/Elements.h>
17 using data::ColoredPoint;
40 this->_checkFinite = enabled;
47 data_->transparency = t;
55 data_->pointSizeInPixels = s;
64 data_->points.clear();
69 points(std::vector<ColoredPoint>
const& ps)
71 std::size_t memorySize = ps.size() *
sizeof(ps[0]);
72 const Ice::Byte*
const begin =
reinterpret_cast<const Ice::Byte*
>(ps.data());
73 const Ice::Byte*
const end = begin + memorySize;
74 data_->points.assign(begin, end);
94 const Ice::Byte*
const begin =
reinterpret_cast<const Ice::Byte*
>(&p);
95 const Ice::Byte*
const end = begin +
sizeof(p);
96 data_->points.insert(
data_->points.end(), begin, end);
117 template <
typename ColorCoeff =
int>
127 return addPoint(
x, y, z, simox::Color(r, g, b, a));
133 return addPoint(
x, y, z, simox::Color::black(255));
137 addPoint(
float x,
float y,
float z, std::size_t
id,
int alpha = 255)
139 return addPoint(
x, y, z, simox::color::GlasbeyLUT::at(
id, alpha));
147 template <
class Po
intT>
163 template <
class Po
intT>
167 if constexpr (detail::has_member_label<PointT>::value)
169 return addPoint(p.x, p.y, p.z, simox::color::GlasbeyLUT::at(p.label));
173 return addPoint(p.x, p.y, p.z, simox::Color(p.r, p.g, p.b, p.a));
177 return addPoint(p.x, p.y, p.z, Color::gray());
187 template <
class Po
intT>
193 return addPoint(p.x, p.y, p.z, simox::color::GlasbeyLUT::at(p.label));
197 return addPoint(p.x, p.y, p.z, simox::Color(p.r, p.g, p.b, p.a));
204 template <
class Po
intCloudT>
212 template <
class Po
intCloudT>
220 template <
class Po
intCloudT>
229 template <
class Po
intCloudT>
234 cloud, [
this, colorByLabel](
const auto& p) { this->
addPoint(p, colorByLabel); });
238 template <
class Po
intCloudT>
244 [
this, colorByLabel](
int,
const auto& p)
249 template <
class Po
intCloudT>
265 template <
class Po
intCloudT,
class ColorFuncT>
270 cloud, [
this, &colorFunc](
const auto& p) {
addPoint(p, colorFunc(p)); });
276 template <
class Po
intCloudT,
class ColorFuncT>
279 const std::vector<int>& indices,
280 const ColorFuncT& colorFunc)
284 [
this, &colorFunc](
int,
const auto& p)
295 template <
class Po
intCloudT,
class ScalarFuncT>
298 const simox::ColorMap& colorMap,
299 const ScalarFuncT& scalarFunc)
302 [&colorMap, scalarFunc](
const auto& p)
303 {
return colorMap(scalarFunc(p)); });
309 template <
class Po
intCloudT,
class ScalarFuncT>
312 const std::vector<int>& indices,
313 const simox::ColorMap& colorMap,
314 const ScalarFuncT& scalarFunc)
318 [colorMap, scalarFunc](
const auto& p)
319 {
return colorMap(scalarFunc(p)); });
336 template <
class Po
intCloudT,
class Po
intFunc>
344 for (
const auto& p : cloud)
365 template <
class Po
intCloudT,
class Po
intFunc>
368 const std::vector<int>& indices,
369 const PointFunc& pointFunc,
376 for (
int i : indices)
379 const auto& p = cloud.at(
size_t(i));
387 template <
class Po
intT>
391 return !_checkFinite ||
396 bool _checkFinite =
false;
IceInternal::Handle< data::ElementPointCloud > data_
ElementOps(std::string const &id)
PointCloud & color(Color color)
PointCloud & setPointCloud(const PointCloudT &cloud, const PointFunc &pointFunc, bool clear=true)
Set the point cloud from a pcl::PointCloud.
PointCloud & addPoint(float x, float y, float z)
PointCloud & pointSizeInPixels(float s)
PointCloud & pointCloud(const PointCloudT &cloud, Color color)
Draw a unicolored point cloud with given color.
PointCloud & pointCloud(const PointCloudT &cloud)
Draw a point cloud.
PointCloud & pointCloud(const PointCloudT &cloud, const std::vector< int > &indices)
Draw a point cloud with given indices.
PointCloud & pointCloud(const PointCloudT &pointCloud, const std::vector< int > &indices, const simox::ColorMap &colorMap, const ScalarFuncT &scalarFunc)
Draw a colored point cloud with using a color map and given indices.
PointCloud & addPoint(float x, float y, float z, const simox::Color &color)
PointCloud & pointCloud(const PointCloudT &cloud, const std::vector< int > &indices, const ColorFuncT &colorFunc)
Draw a colored point cloud with custom colors and given indices.
PointCloud & addPoint(float x, float y, float z, std::size_t id, int alpha=255)
PointCloud & addPoint(const PointT &p)
Add a point with its "natural" color.
PointCloud & pointCloud(const PointCloudT &pointCloud, const simox::ColorMap &colorMap, const ScalarFuncT &scalarFunc)
Draw a colored point cloud with using a color map.
PointCloud & addPoint(float x, float y, float z, ColorCoeff r, ColorCoeff g, ColorCoeff b, ColorCoeff a=255)
PointCloud & pointCloud(const PointCloudT &cloud, bool colorByLabel)
Draw a point cloud.
PointCloud & addPoint(ColoredPoint const &p)
PointCloud & pointCloud(const PointCloudT &cloud, const std::vector< int > &indices, bool colorByLabel)
Draw a point cloud with given indices.
ElementOps(std::string const &id)
PointCloud & addPoint(const PointT &p, bool colorByLabel)
Add a colored or labeled point.
PointCloud & setPointCloud(const PointCloudT &cloud, const std::vector< int > &indices, const PointFunc &pointFunc, bool clear=true)
Set the point cloud from a pcl::PointCloud.
PointCloud & checkFinite(bool enabled=true)
Enable or disable checking whether points are finite when adding them (disabled by default).
PointCloud & addPoint(float x, float y, float z, const data::Color &color)
PointCloud & transparency(float t)
PointCloud & pointCloud(const PointCloudT &cloud, const ColorFuncT &colorFunc)
Draw a colored point cloud with custom colors.
PointCloud & points(std::vector< ColoredPoint > const &ps)
PointCloud & addPoint(const PointT &p, Color color)
Add a point in the given color.
PointCloud & addPointUnchecked(ColoredPoint const &p)
PointCloud & pointCloud(const PointCloudT &cloud, const std::vector< int > &indices, Color color)
Draw a unicolored point cloud with given color and indices.
static constexpr bool value
#define ARMARX_CHECK_FITS_SIZE(number, size)
Check whether number is nonnegative (>= 0) and less than size.
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
pcl::PointCloud< PointT > PointCloudT
bool isfinite(const std::vector< T, Ts... > &v)