Go to the documentation of this file.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
00039
00040 #ifndef PCL_SURFACE_IMPL_MLS_OMP_H_
00041 #define PCL_SURFACE_IMPL_MLS_OMP_H_
00042
00043 #include <cstddef>
00044 #include <pcl/surface/mls_omp.h>
00045
00047 template <typename PointInT, typename PointOutT> void
00048 pcl::MovingLeastSquaresOMP<PointInT, PointOutT>::performProcessing (PointCloudOut &output)
00049 {
00050 typedef std::size_t size_t;
00051
00052 nr_coeff_ = (order_ + 1) * (order_ + 2) / 2;
00053
00054 #pragma omp parallel for schedule (dynamic, threads_)
00055
00056 for (int cp = 0; cp < static_cast<int> (indices_->size ()); ++cp)
00057 {
00058
00059
00060 std::vector<int> nn_indices;
00061 std::vector<float> nn_sqr_dists;
00062
00063
00064 if (!searchForNeighbors (cp, nn_indices, nn_sqr_dists))
00065 continue;
00066
00067
00068
00069
00070 if (nn_indices.size () < 3)
00071 continue;
00072
00073
00074 PointCloudOut projected_points;
00075 NormalCloud projected_points_normals;
00076
00077
00078 this->computeMLSPointNormal (cp, *input_, nn_indices, nn_sqr_dists, projected_points, projected_points_normals);
00079
00080 #pragma omp critical
00081 {
00082
00083 output.insert (output.end (), projected_points.begin (), projected_points.end ());
00084 if (compute_normals_)
00085 normals_->insert (normals_->end (), projected_points_normals.begin (), projected_points_normals.end ());
00086 }
00087 }
00088
00089
00090
00091
00092 if (upsample_method_ == MovingLeastSquares<PointInT, PointOutT>::VOXEL_GRID_DILATION)
00093 {
00094 MLSVoxelGrid voxel_grid (input_, indices_, voxel_size_);
00095
00096 for (int iteration = 0; iteration < dilation_iteration_num_; ++iteration)
00097 voxel_grid.dilate ();
00098
00099 #if ((__GNUC__ > 4) && (__GNUC_MINOR__ > 2))
00100 #pragma omp parallel for schedule (dynamic, threads_)
00101 #endif
00102 for (typename MLSVoxelGrid::HashMap::iterator h_it = voxel_grid.voxel_grid_.begin (); h_it != voxel_grid.voxel_grid_.end (); ++h_it)
00103 {
00104 typename MLSVoxelGrid::HashMap::value_type voxel = *h_it;
00105
00106
00107 Eigen::Vector3f pos;
00108 voxel_grid.getPosition (voxel.first, pos);
00109
00110 PointInT p;
00111 p.x = pos[0];
00112 p.y = pos[1];
00113 p.z = pos[2];
00114
00115 std::vector<int> nn_indices;
00116 std::vector<float> nn_dists;
00117 tree_->nearestKSearch (p, 1, nn_indices, nn_dists);
00118 int input_index = nn_indices.front ();
00119
00120
00121
00122 if (mls_results_[input_index].valid == false)
00123 continue;
00124
00125 Eigen::Vector3f add_point = p.getVector3fMap (),
00126 input_point = input_->points[input_index].getVector3fMap ();
00127
00128 Eigen::Vector3d aux = mls_results_[input_index].u;
00129 Eigen::Vector3f u = aux.cast<float> ();
00130 aux = mls_results_[input_index].v;
00131 Eigen::Vector3f v = aux.cast<float> ();
00132
00133 float u_disp = (add_point - input_point).dot (u),
00134 v_disp = (add_point - input_point).dot (v);
00135
00136 PointOutT result_point;
00137 pcl::Normal result_normal;
00138 this->projectPointToMLSSurface (u_disp, v_disp,
00139 mls_results_[input_index].u, mls_results_[input_index].v,
00140 mls_results_[input_index].plane_normal,
00141 mls_results_[input_index].curvature,
00142 input_point,
00143 mls_results_[input_index].c_vec,
00144 mls_results_[input_index].num_neighbors,
00145 result_point, result_normal);
00146
00147 float d_before = (pos - input_point).norm (),
00148 d_after = (result_point.getVector3fMap () - input_point). norm();
00149 if (d_after > d_before)
00150 continue;
00151
00152 #pragma critical
00153 {
00154 output.push_back (result_point);
00155 if (compute_normals_)
00156 normals_->push_back (result_normal);
00157 }
00158 }
00159 }
00160 }
00161
00162 #define PCL_INSTANTIATE_MovingLeastSquaresOMP(T,OutT) template class PCL_EXPORTS pcl::MovingLeastSquaresOMP<T,OutT>;
00163
00164 #endif // PCL_SURFACE_IMPL_MLS_OMP_H_
00165