Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
project_inliers.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id: project_inliers.h 6144 2012-07-04 22:06:28Z rusu $
35  *
36  */
37 
38 #ifndef PCL_FILTERS_PROJECT_INLIERS_H_
39 #define PCL_FILTERS_PROJECT_INLIERS_H_
40 
41 #include <pcl/point_types.h>
42 #include <pcl/filters/filter.h>
43 #include <pcl/ModelCoefficients.h>
44 // Sample Consensus models
59 
60 namespace pcl
61 {
63 
68  template<typename PointT>
69  class ProjectInliers : public Filter<PointT>
70  {
75 
76  typedef typename Filter<PointT>::PointCloud PointCloud;
77  typedef typename PointCloud::Ptr PointCloudPtr;
79 
80  typedef typename SampleConsensusModel<PointT>::Ptr SampleConsensusModelPtr;
81  public:
83  ProjectInliers () : model_ (), sacmodel_ (), model_type_ (), copy_all_data_ (false)
84  {
85  filter_name_ = "ProjectInliers";
86  }
87 
91  inline void
92  setModelType (int model)
93  {
94  model_type_ = model;
95  }
96 
98  inline int
100  {
101  return (model_type_);
102  }
103 
107  inline void
109  {
110  model_ = model;
111  }
112 
116  {
117  return (model_);
118  }
119 
123  inline void
124  setCopyAllData (bool val)
125  {
126  copy_all_data_ = val;
127  }
128 
130  inline bool
132  {
133  return (copy_all_data_);
134  }
135  protected:
137 
140  void
141  applyFilter (PointCloud &output);
142 
143  private:
146 
148  SampleConsensusModelPtr sacmodel_;
149 
151  int model_type_;
152 
154  bool copy_all_data_;
155 
159  virtual bool
160  initSACModel (int model_type);
161  };
162 
164 
170  template<>
171  class PCL_EXPORTS ProjectInliers<sensor_msgs::PointCloud2> : public Filter<sensor_msgs::PointCloud2>
172  {
175 
179 
180  typedef SampleConsensusModel<PointXYZ>::Ptr SampleConsensusModelPtr;
181 
182  public:
184  ProjectInliers () : model_type_ (), copy_all_data_ (false), copy_all_fields_ (true), model_ (), sacmodel_ ()
185  {
186  filter_name_ = "ProjectInliers";
187  }
188 
192  inline void
193  setModelType (int model)
194  {
195  model_type_ = model;
196  }
197 
199  inline int
200  getModelType () const
201  {
202  return (model_type_);
203  }
204 
208  inline void
210  {
211  model_ = model;
212  }
213 
217  {
218  return (model_);
219  }
220 
224  inline void
225  setCopyAllFields (bool val)
226  {
227  copy_all_fields_ = val;
228  }
229 
231  inline bool
233  {
234  return (copy_all_fields_);
235  }
236 
240  inline void
241  setCopyAllData (bool val)
242  {
243  copy_all_data_ = val;
244  }
245 
247  inline bool
248  getCopyAllData () const
249  {
250  return (copy_all_data_);
251  }
252  protected:
254  int model_type_;
255 
257  bool copy_all_data_;
258 
260  bool copy_all_fields_;
261 
264 
265  void
266  applyFilter (PointCloud2 &output);
267 
268  private:
270  SampleConsensusModelPtr sacmodel_;
271 
272  virtual bool
273  initSACModel (int model_type);
274  };
275 }
276 
277 #endif //#ifndef PCL_FILTERS_PROJECT_INLIERS_H_