Point Cloud Library (PCL) 1.15.1
Loading...
Searching...
No Matches
shadowpoints.hpp
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2009-2011, Willow Garage, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of the copyright holder(s) nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#ifndef PCL_FILTERS_IMPL_SHADOW_POINTS_FILTER_H_
39#define PCL_FILTERS_IMPL_SHADOW_POINTS_FILTER_H_
40
41#include <pcl/filters/shadowpoints.h>
42
43#include <vector>
44
45///////////////////////////////////////////////////////////////////////////////
46template<typename PointT, typename NormalT> void
48{
49 assert (input_normals_ != nullptr);
50 output.resize (input_->size ());
52 removed_indices_->resize (input_->size ());
53
54 std::size_t cp = 0;
55 std::size_t ri = 0;
56 for (std::size_t i = 0; i < input_->size (); i++)
57 {
58 const NormalT &normal = (*input_normals_)[i];
59 const PointT &pt = (*input_)[i];
60 const float val = std::abs (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
61
62 if ( (val >= threshold_) ^ negative_)
63 output[cp++] = pt;
64 else
65 {
67 (*removed_indices_)[ri++] = i;
69 {
70 PointT &pt_new = output[cp++] = pt;
71 pt_new.x = pt_new.y = pt_new.z = user_filter_value_;
72 if(!std::isfinite(user_filter_value_))
73 output.is_dense = false;
74 }
75
76 }
77 }
78 output.resize (cp);
79 removed_indices_->resize (ri);
80 output.height = 1;
81 output.width = output.size ();
82}
83
84///////////////////////////////////////////////////////////////////////////////
85template<typename PointT, typename NormalT> void
87{
88 assert (input_normals_ != nullptr);
89 indices.resize (input_->size ());
91 removed_indices_->resize (indices_->size ());
92
93 unsigned int k = 0;
94 unsigned int z = 0;
95 for (const auto& idx : (*indices_))
96 {
97 const NormalT &normal = (*input_normals_)[idx];
98 const PointT &pt = (*input_)[idx];
99
100 float val = std::abs (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
101
102 if ( (val >= threshold_) ^ negative_)
103 indices[k++] = idx;
105 (*removed_indices_)[z++] = idx;
106 }
107 indices.resize (k);
108 removed_indices_->resize (z);
109}
110
111#define PCL_INSTANTIATE_ShadowPoints(T,NT) template class PCL_EXPORTS pcl::ShadowPoints<T,NT>;
112
113#endif // PCL_FILTERS_IMPL_NORMAL_SPACE_SAMPLE_H_
bool extract_removed_indices_
Set to true if we want to return the indices of the removed points.
Definition filter.h:161
IndicesPtr removed_indices_
Indices of the points that are removed.
Definition filter.h:155
float user_filter_value_
The user given value that the filtered point dimensions should be set to (default = NaN).
bool keep_organized_
False = remove points (default), true = redefine points, keep structure.
bool negative_
False = normal filter behavior (default), true = inverted behavior.
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
NormalsPtr input_normals_
The normals computed at each point in the input cloud.
void applyFilter(PointCloud &output) override
Sample of point indices into a separate PointCloud.
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133