00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_FEATURES_IMPL_BOUNDARY_H_
00039 #define PCL_FEATURES_IMPL_BOUNDARY_H_
00040
00041 #include "pcl/features/boundary.h"
00042 #include <cfloat>
00043
00045 template <typename PointInT, typename PointNT, typename PointOutT> bool
00046 pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>::isBoundaryPoint (
00047 const pcl::PointCloud<PointInT> &cloud, int q_idx,
00048 const std::vector<int> &indices,
00049 const Eigen::Vector3f &u, const Eigen::Vector3f &v,
00050 float angle_threshold)
00051 {
00052 return (isBoundaryPoint (cloud, cloud.points[q_idx], indices, u, v, angle_threshold));
00053 }
00054
00056 template <typename PointInT, typename PointNT, typename PointOutT> bool
00057 pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>::isBoundaryPoint (
00058 const pcl::PointCloud<PointInT> &cloud, const PointInT &q_point,
00059 const std::vector<int> &indices,
00060 const Eigen::Vector3f &u, const Eigen::Vector3f &v,
00061 float angle_threshold)
00062 {
00063 if (indices.size () < 3)
00064 return (false);
00065 float uvn_nn[2];
00066 Eigen::Vector3f delta;
00067 delta.setZero ();
00068
00069 std::vector<float> angles;
00070 angles.reserve (indices.size ());
00071 for (size_t i = 0; i < indices.size (); ++i)
00072 {
00073 delta[0] = cloud.points[indices[i]].x - q_point.x;
00074 delta[1] = cloud.points[indices[i]].y - q_point.y;
00075 delta[2] = cloud.points[indices[i]].z - q_point.z;
00076
00077 uvn_nn[0] = u.dot (delta);
00078 uvn_nn[1] = v.dot (delta);
00079
00080 if (uvn_nn[0] == 0 && uvn_nn[1] == 0)
00081 continue;
00082 angles.push_back (atan2 (uvn_nn[1], uvn_nn[0]));
00083 }
00084 std::sort (angles.begin (), angles.end ());
00085
00086
00087 float max_dif = FLT_MIN, dif;
00088 for (size_t i = 0; i < angles.size () - 1; ++i)
00089 {
00090 dif = angles[i + 1] - angles[i];
00091 if (max_dif < dif)
00092 max_dif = dif;
00093 }
00094
00095 dif = 2 * M_PI - angles[angles.size () - 1] + angles[0];
00096 if (max_dif < dif)
00097 max_dif = dif;
00098
00099
00100 if (max_dif > angle_threshold)
00101 return (true);
00102 else
00103 return (false);
00104 }
00105
00107 template <typename PointInT, typename PointNT, typename PointOutT> void
00108 pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut &output)
00109 {
00110
00111 if (!normals_)
00112 {
00113 ROS_ERROR ("[pcl::%s::computeFeature] No input dataset containing normals was given!", getClassName ().c_str ());
00114 output.width = output.height = 0;
00115 output.points.clear ();
00116 return;
00117 }
00118 if (normals_->points.size () != surface_->points.size ())
00119 {
00120 ROS_ERROR ("[pcl::%s::computeFeature] The number of points in the input dataset differs from the number of points in the dataset containing the normals!", getClassName ().c_str ());
00121 output.width = output.height = 0;
00122 output.points.clear ();
00123 return;
00124 }
00125
00126
00127
00128 std::vector<int> nn_indices (k_);
00129 std::vector<float> nn_dists (k_);
00130
00131 Eigen::Vector3f u, v;
00132
00133
00134 for (size_t idx = 0; idx < indices_->size (); ++idx)
00135 {
00136 searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists);
00137
00138
00139 getCoordinateSystemOnPlane (normals_->points[(*indices_)[idx]], u, v);
00140
00141
00142 output.points[idx].boundary_point = isBoundaryPoint (*surface_, input_->points[(*indices_)[idx]], nn_indices, u, v, angle_threshold_);
00143 }
00144 }
00145
00146 #define PCL_INSTANTIATE_BoundaryEstimation(PointInT,PointNT,PointOutT) template class pcl::BoundaryEstimation<PointInT, PointNT, PointOutT>;
00147
00148 #endif // PCL_FEATURES_IMPL_BOUNDARY_H_
00149