7 #ifndef NUKLEI_PCL_BRIDGE_H
8 #define NUKLEI_PCL_BRIDGE_H
13 #include <pcl/point_types.h>
14 #include <pcl/point_cloud.h>
15 #include <boost/math/special_functions/fpclassify.hpp>
33 inline bool valid(
const pcl::PointXYZ& p)
35 float t = p.x + p.y + p.z;
36 return !(boost::math::isnan)(t);
39 inline bool valid(
const pcl::PointNormal& p)
41 float t = p.x + p.y + p.z + p.normal_x + p.normal_y + p.normal_z;
42 return !(boost::math::isnan)(t);
45 inline bool valid(
const pcl::PointXYZRGB& p)
47 float t = p.x + p.y + p.z;
48 return !(boost::math::isnan)(t);
51 inline bool valid(
const pcl::PointXYZRGBNormal& p)
53 float t = p.x + p.y + p.z + p.normal_x + p.normal_y + p.normal_z;
54 return !(boost::math::isnan)(t);
58 kernel::r3 nukleiKernelFromPclPoint(
const pcl::PointXYZ& p);
60 kernel::r3 nukleiKernelFromPclPoint(
const pcl::PointXYZRGB& p);
67 kernel::r3xs2p nukleiKernelFromPclPoint(
const pcl::PointNormal& p);
74 kernel::r3xs2p nukleiKernelFromPclPoint(
const pcl::PointXYZRGBNormal& p);
78 void pclPointFromNukleiKernel(pcl::PointXYZ& p,
const kernel::r3& k);
80 void pclPointFromNukleiKernel(pcl::PointXYZ& p,
const kernel::base& k);
83 void pclPointFromNukleiKernel(pcl::PointXYZRGB& p,
const kernel::r3& k);
85 void pclPointFromNukleiKernel(pcl::PointXYZRGB& p,
const kernel::base& k);
93 void pclPointFromNukleiKernel(pcl::PointNormal& p,
const kernel::r3xs2p& k);
95 void pclPointFromNukleiKernel(pcl::PointNormal& p,
const kernel::base& k);
103 void pclPointFromNukleiKernel(pcl::PointXYZRGBNormal& p,
const kernel::r3xs2p& k);
105 void pclPointFromNukleiKernel(pcl::PointXYZRGBNormal& p,
const kernel::base& k);
108 template<
typename Po
intT>
109 KernelCollection nukleiFromPcl(
const pcl::PointCloud<PointT>& cloud,
110 const bool removeInvalidPoints =
false)
113 for (
typename pcl::PointCloud<PointT>::const_iterator i = cloud.begin();
114 i != cloud.end(); ++i)
116 if (removeInvalidPoints && !valid(*i))
continue;
117 kc.add(nukleiKernelFromPclPoint(*i));
122 template<
typename Po
intT>
123 pcl::PointCloud<PointT> pclFromNuklei(
const KernelCollection& kc)
125 pcl::PointCloud<PointT> cloud;
127 cloud.width = kc.size();
129 cloud.is_dense =
true;
135 pclPointFromNukleiKernel(point, *i);
136 cloud.push_back(point);