40 #ifndef PCL_SURFACE_IMPL_MLS_OMP_H_
41 #define PCL_SURFACE_IMPL_MLS_OMP_H_
47 template <
typename Po
intInT,
typename Po
intOutT>
void
50 typedef std::size_t size_t;
52 nr_coeff_ = (order_ + 1) * (order_ + 2) / 2;
54 #pragma omp parallel for schedule (dynamic, threads_)
56 for (
int cp = 0; cp < static_cast<int> (indices_->size ()); ++cp)
60 std::vector<int> nn_indices;
61 std::vector<float> nn_sqr_dists;
64 if (!searchForNeighbors (cp, nn_indices, nn_sqr_dists))
70 if (nn_indices.size () < 3)
75 NormalCloud projected_points_normals;
78 this->computeMLSPointNormal (cp, *input_, nn_indices, nn_sqr_dists, projected_points, projected_points_normals);
83 output.insert (output.end (), projected_points.begin (), projected_points.end ());
85 normals_->insert (normals_->end (), projected_points_normals.begin (), projected_points_normals.end ());
92 if (upsample_method_ == MovingLeastSquares<PointInT, PointOutT>::VOXEL_GRID_DILATION)
94 MLSVoxelGrid voxel_grid (input_, indices_, voxel_size_);
96 for (
int iteration = 0; iteration < dilation_iteration_num_; ++iteration)
99 #if ((__GNUC__ > 4) && (__GNUC_MINOR__ > 2))
100 #pragma omp parallel for schedule (dynamic, threads_)
102 for (
typename MLSVoxelGrid::HashMap::iterator h_it = voxel_grid.voxel_grid_.begin (); h_it != voxel_grid.voxel_grid_.end (); ++h_it)
104 typename MLSVoxelGrid::HashMap::value_type voxel = *h_it;
108 voxel_grid.getPosition (voxel.first, pos);
115 std::vector<int> nn_indices;
116 std::vector<float> nn_dists;
117 tree_->nearestKSearch (p, 1, nn_indices, nn_dists);
118 int input_index = nn_indices.front ();
122 if (mls_results_[input_index].valid ==
false)
125 Eigen::Vector3f add_point = p.getVector3fMap (),
126 input_point = input_->points[input_index].getVector3fMap ();
128 Eigen::Vector3d aux = mls_results_[input_index].u;
129 Eigen::Vector3f u = aux.cast<
float> ();
130 aux = mls_results_[input_index].v;
131 Eigen::Vector3f v = aux.cast<
float> ();
133 float u_disp = (add_point - input_point).dot (u),
134 v_disp = (add_point - input_point).dot (v);
136 PointOutT result_point;
138 this->projectPointToMLSSurface (u_disp, v_disp,
139 mls_results_[input_index].u, mls_results_[input_index].v,
140 mls_results_[input_index].plane_normal,
141 mls_results_[input_index].curvature,
143 mls_results_[input_index].c_vec,
144 mls_results_[input_index].num_neighbors,
145 result_point, result_normal);
147 float d_before = (pos - input_point).norm (),
148 d_after = (result_point.getVector3fMap () - input_point). norm();
149 if (d_after > d_before)
154 output.push_back (result_point);
155 if (compute_normals_)
156 normals_->push_back (result_normal);
162 #define PCL_INSTANTIATE_MovingLeastSquaresOMP(T,OutT) template class PCL_EXPORTS pcl::MovingLeastSquaresOMP<T,OutT>;
164 #endif // PCL_SURFACE_IMPL_MLS_OMP_H_