41 #ifndef PCL_FEATURES_IMPL_NORMAL_3D_OMP_H_
42 #define PCL_FEATURES_IMPL_NORMAL_3D_OMP_H_
44 #include <pcl/features/normal_3d_omp.h>
47 template <
typename Po
intInT,
typename Po
intOutT>
void
52 threads_ = omp_get_num_procs();
54 threads_ = nr_threads;
55 PCL_DEBUG (
"[pcl::NormalEstimationOMP::setNumberOfThreads] Setting number of threads to %u.\n", threads_);
59 PCL_WARN (
"[pcl::NormalEstimationOMP::setNumberOfThreads] Parallelization is requested, but OpenMP is not available! Continuing without parallelization.\n");
64 template <
typename Po
intInT,
typename Po
intOutT>
void
70 std::vector<float> nn_dists (k_);
72 output.is_dense =
true;
76 #pragma omp parallel for \
79 firstprivate(nn_indices, nn_dists) \
80 num_threads(threads_) \
81 schedule(dynamic, chunk_size_)
83 for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
86 if (this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0 ||
89 output[idx].normal[0] = output[idx].normal[1] = output[idx].normal[2] = output[idx].curvature = std::numeric_limits<float>::quiet_NaN ();
91 output.is_dense =
false;
95 output[idx].normal_x = n[0];
96 output[idx].normal_y = n[1];
97 output[idx].normal_z = n[2];
100 output[idx].normal[0], output[idx].normal[1], output[idx].normal[2]);
106 #pragma omp parallel for \
109 firstprivate(nn_indices, nn_dists) \
110 num_threads(threads_) \
111 schedule(dynamic, chunk_size_)
113 for (std::ptrdiff_t idx = 0; idx < static_cast<std::ptrdiff_t> (indices_->size ()); ++idx)
116 if (!isFinite ((*input_)[(*indices_)[idx]]) ||
117 this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists) == 0 ||
120 output[idx].normal[0] = output[idx].normal[1] = output[idx].normal[2] = output[idx].curvature = std::numeric_limits<float>::quiet_NaN ();
122 output.is_dense =
false;
126 output[idx].normal_x = n[0];
127 output[idx].normal_y = n[1];
128 output[idx].normal_z = n[2];
131 output[idx].normal[0], output[idx].normal[1], output[idx].normal[2]);
137 #define PCL_INSTANTIATE_NormalEstimationOMP(T,NT) template class PCL_EXPORTS pcl::NormalEstimationOMP<T,NT>;
NormalEstimationOMP estimates local surface properties at each 3D point, such as surface normals and ...
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
void flipNormalTowardsViewpoint(const PointT &point, float vp_x, float vp_y, float vp_z, Eigen::Matrix< Scalar, 4, 1 > &normal)
Flip (in place) the estimated normal of a point towards a given viewpoint.
bool computePointNormal(const pcl::PointCloud< PointT > &cloud, Eigen::Vector4f &plane_parameters, float &curvature)
Compute the Least-Squares plane fit for a given set of points, and return the estimated plane paramet...
IndicesAllocator<> Indices
Type used for indices in PCL.