Point Cloud Library (PCL) 1.12.0
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_ != NULL);
50 output.resize (input_->size ());
51 if (extract_removed_indices_)
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 {
66 if (extract_removed_indices_)
67 (*removed_indices_)[ri++] = i;
68 if (keep_organized_)
69 {
70 PointT &pt_new = output[cp++] = pt;
71 pt_new.x = pt_new.y = pt_new.z = user_filter_value_;
72 }
73
74 }
75 }
76 output.resize (cp);
77 removed_indices_->resize (ri);
78 output.height = 1;
79 output.width = output.size ();
80}
81
82///////////////////////////////////////////////////////////////////////////////
83template<typename PointT, typename NormalT> void
85{
86 assert (input_normals_ != NULL);
87 indices.resize (input_->size ());
88 if (extract_removed_indices_)
89 removed_indices_->resize (indices_->size ());
90
91 unsigned int k = 0;
92 unsigned int z = 0;
93 for (const auto& idx : (*indices_))
94 {
95 const NormalT &normal = (*input_normals_)[idx];
96 const PointT &pt = (*input_)[idx];
97
98 float val = std::abs (normal.normal_x * pt.x + normal.normal_y * pt.y + normal.normal_z * pt.z);
99
100 if ( (val >= threshold_) ^ negative_)
101 indices[k++] = idx;
102 else if (extract_removed_indices_)
103 (*removed_indices_)[z++] = idx;
104 }
105 indices.resize (k);
106 removed_indices_->resize (z);
107}
108
109#define PCL_INSTANTIATE_ShadowPoints(T,NT) template class PCL_EXPORTS pcl::ShadowPoints<T,NT>;
110
111#endif // PCL_FILTERS_IMPL_NORMAL_SPACE_SAMPLE_H_
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
void resize(std::size_t count)
Resizes the container to contain count elements.
Definition: point_cloud.h:462
std::uint32_t width
The point cloud width (if organized as an image-structure).
Definition: point_cloud.h:398
std::uint32_t height
The point cloud height (if organized as an image-structure).
Definition: point_cloud.h:400
std::size_t size() const
Definition: point_cloud.h:443
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
A point structure representing normal coordinates and the surface curvature estimate.
A point structure representing Euclidean xyz coordinates, and the RGB color.