Point Cloud Library (PCL)  1.7.0
shot_lrf_omp.hpp
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  */
39 
40 #ifndef PCL_FEATURES_IMPL_SHOT_LRF_OMP_H_
41 #define PCL_FEATURES_IMPL_SHOT_LRF_OMP_H_
42 
43 #include <utility>
44 #include <pcl/features/shot_lrf_omp.h>
45 #include <pcl/features/shot_lrf.h>
46 
47 template<typename PointInT, typename PointOutT>
48 void
50 {
51  //check whether used with search radius or search k-neighbors
52  if (this->getKSearch () != 0)
53  {
54  PCL_ERROR(
55  "[pcl::%s::computeFeature] Error! Search method set to k-neighborhood. Call setKSearch(0) and setRadiusSearch( radius ) to use this class.\n",
56  getClassName().c_str ());
57  return;
58  }
59  tree_->setSortedResults (true);
60 
61  int data_size = static_cast<int> (indices_->size ());
62 #ifdef _OPENMP
63 #pragma omp parallel for num_threads(threads_)
64 #endif
65  for (int i = 0; i < data_size; ++i)
66  {
67  // point result
68  Eigen::Matrix3f rf;
69  PointOutT& output_rf = output[i];
70 
71  //output_rf.confidence = getLocalRF ((*indices_)[i], rf);
72  //if (output_rf.confidence == std::numeric_limits<float>::max ())
73 
74  std::vector<int> n_indices;
75  std::vector<float> n_sqr_distances;
76  this->searchForNeighbors ((*indices_)[i], search_parameter_, n_indices, n_sqr_distances);
77  if (getLocalRF ((*indices_)[i], rf) == std::numeric_limits<float>::max ())
78  {
79  output.is_dense = false;
80  }
81 
82  for (int d = 0; d < 3; ++d)
83  {
84  output_rf.x_axis[d] = rf.row (0)[d];
85  output_rf.y_axis[d] = rf.row (1)[d];
86  output_rf.z_axis[d] = rf.row (2)[d];
87  }
88  }
89 
90 }
91 
92 #define PCL_INSTANTIATE_SHOTLocalReferenceFrameEstimationOMP(T,OutT) template class PCL_EXPORTS pcl::SHOTLocalReferenceFrameEstimationOMP<T,OutT>;
93 
94 #endif // PCL_FEATURES_IMPL_SHOT_LRF_H_