Point Cloud Library (PCL)
1.10.1
pcl
filters
impl
filter_indices.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2009, 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 the copyright holder(s) 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: filter.hpp 1800 2011-07-15 11:45:31Z marton $
35
*
36
*/
37
38
#ifndef PCL_FILTERS_IMPL_FILTER_INDICES_H_
39
#define PCL_FILTERS_IMPL_FILTER_INDICES_H_
40
41
#include <
pcl/pcl_macros.h
>
42
#include <pcl/filters/filter_indices.h>
43
44
template
<
typename
Po
int
T>
void
45
pcl::removeNaNFromPointCloud
(
const
pcl::PointCloud<PointT>
&cloud_in,
46
std::vector<int> &index)
47
{
48
// Reserve enough space for the indices
49
index.resize (cloud_in.
points
.size ());
50
51
// If the data is dense, we don't need to check for NaN
52
if
(cloud_in.
is_dense
)
53
{
54
for
(
int
j = 0; j < static_cast<int> (cloud_in.
points
.size ()); ++j)
55
index[j] = j;
56
}
57
else
58
{
59
int
j = 0;
60
for
(
int
i = 0; i < static_cast<int> (cloud_in.
points
.size ()); ++i)
61
{
62
if
(!std::isfinite (cloud_in.
points
[i].x) ||
63
!std::isfinite (cloud_in.
points
[i].y) ||
64
!std::isfinite (cloud_in.
points
[i].z))
65
continue
;
66
index[j] = i;
67
j++;
68
}
69
if
(j !=
static_cast<
int
>
(cloud_in.
points
.size ()))
70
{
71
// Resize to the correct size
72
index.resize (j);
73
}
74
}
75
}
76
77
#define PCL_INSTANTIATE_removeNanFromPointCloud(T) template PCL_EXPORTS void pcl::removeNaNFromPointCloud<T>(const pcl::PointCloud<T>&, std::vector<int>&);
78
79
#endif // PCL_FILTERS_IMPL_FILTER_INDICES_H_
80
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl::PointCloud::points
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Definition:
point_cloud.h:397
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition:
projection_matrix.h:52
pcl::PointCloud::is_dense
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
Definition:
point_cloud.h:405
pcl::removeNaNFromPointCloud
void removeNaNFromPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, std::vector< int > &index)
Removes points with x, y, or z equal to NaN.
Definition:
filter.hpp:46