shadowpoints.hpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  * 
00004  * Point Cloud Library (PCL) - www.pointclouds.org
00005  * Copyright (c) 2009-2011, Willow Garage, Inc.
00006  * 
00007  * All rights reserved.
00008  * 
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met: 
00012  * 
00013  *  * Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  *  * Redistributions in binary form must reproduce the above
00016  *    copyright notice, this list of conditions and the following
00017  *    disclaimer in the documentation and/or other materials provided
00018  *    with the distribution.
00019  *  * Neither the name of the copyright holder(s) nor the names of its
00020  *    contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  * 
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  * POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  */
00037 
00038 #ifndef PCL_FILTERS_IMPL_SHADOW_POINTS_FILTER_H_
00039 #define PCL_FILTERS_IMPL_SHADOW_POINTS_FILTER_H_
00040 
00041 #include <pcl/filters/shadowpoints.h>
00042 
00043 #include <vector>
00044 
00046 template<typename PointT, typename NormalT> void
00047 pcl::ShadowPoints<PointT, NormalT>::applyFilter (PointCloud &output)
00048 {
00049   assert (input_normals_ != NULL);
00050   output.points.resize (input_->points.size ());
00051   if (extract_removed_indices_)
00052     removed_indices_->resize (input_->points.size ());
00053 
00054   unsigned int cp = 0;
00055   unsigned int ri = 0;
00056   for (unsigned int i = 0; i < input_->points.size (); i++)
00057   {
00058     const NormalT &normal = input_normals_->points[i];
00059     const PointT &pt = input_->points[i];
00060     float val = fabsf (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
00061 
00062     if ( (val >= threshold_) ^ negative_)
00063       output.points[cp++] = pt;
00064     else 
00065     {
00066       if (extract_removed_indices_)
00067         (*removed_indices_)[ri++] = i;
00068       if (keep_organized_)
00069       {
00070         PointT &pt_new = output.points[cp++] = pt;
00071         pt_new.x = pt_new.y = pt_new.z = user_filter_value_;
00072       }
00073 
00074     }  
00075   }
00076   output.points.resize (cp);
00077   removed_indices_->resize (ri);
00078   output.width = 1;
00079   output.height = static_cast<uint32_t> (output.points.size ());
00080 }
00081 
00083 template<typename PointT, typename NormalT> void
00084 pcl::ShadowPoints<PointT, NormalT>::applyFilter (std::vector<int> &indices)
00085 {
00086   assert (input_normals_ != NULL);
00087   indices.resize (input_->points.size ());
00088   if (extract_removed_indices_)
00089     removed_indices_->resize (indices_->size ());
00090 
00091   unsigned int k = 0;
00092   unsigned int z = 0;
00093   for (std::vector<int>::const_iterator idx = indices_->begin (); idx != indices_->end (); ++idx)
00094   {
00095     const NormalT &normal = input_normals_->points[*idx];
00096     const PointT &pt = input_->points[*idx];
00097     
00098     float val = fabsf (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
00099 
00100     if ( (val >= threshold_) ^ negative_)
00101       indices[k++] = *idx;
00102     else if (extract_removed_indices_)
00103       (*removed_indices_)[z++] = *idx;
00104   }
00105   indices.resize (k);
00106   removed_indices_->resize (z);
00107 }
00108 
00109 #define PCL_INSTANTIATE_ShadowPoints(T,NT) template class PCL_EXPORTS pcl::ShadowPoints<T,NT>;
00110 
00111 #endif    // PCL_FILTERS_IMPL_NORMAL_SPACE_SAMPLE_H_


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:33:37