Point Cloud Library (PCL)  1.12.0-dev
point_tests.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, 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  * $Id: point_types.hpp 6415 2012-07-16 20:11:47Z rusu $
37  *
38  */
39 
40 #pragma once
41 
42 #include <pcl/point_types.h>
43 
44 #ifdef _MSC_VER
45 #include <Eigen/src/StlSupport/details.h>
46 #endif
47 
48 namespace pcl
49 {
50  /** Tests if the 3D components of a point are all finite
51  * param[in] pt point to be tested
52  * return true if finite, false otherwise
53  */
54  template <typename PointT> inline bool
55  isFinite (const PointT &pt)
56  {
57  return (std::isfinite (pt.x) && std::isfinite (pt.y) && std::isfinite (pt.z));
58  }
59 
60 #ifdef _MSC_VER
61  template <typename PointT> inline bool
62  isFinite (const Eigen::internal::workaround_msvc_stl_support<PointT> &pt)
63  {
64  return isFinite<PointT> (static_cast<const PointT&> (pt));
65  }
66 #endif
67 
68  template<> inline bool isFinite<pcl::Axis>(const pcl::Axis&) { return (true); }
69  template<> inline bool isFinite<pcl::BRISKSignature512>(const pcl::BRISKSignature512&) { return (true); }
70  template<> inline bool isFinite<pcl::BorderDescription>(const pcl::BorderDescription &) { return true; }
71  template<> inline bool isFinite<pcl::Boundary>(const pcl::Boundary&) { return (true); }
72  template<> inline bool isFinite<pcl::CPPFSignature>(const pcl::CPPFSignature&) { return (true); }
73  template<> inline bool isFinite<pcl::ESFSignature640>(const pcl::ESFSignature640&) { return (true); }
74  template<> inline bool isFinite<pcl::FPFHSignature33>(const pcl::FPFHSignature33&) { return (true); }
75  template<> inline bool isFinite<pcl::GASDSignature512>(const pcl::GASDSignature512&) { return (true); }
76  template<> inline bool isFinite<pcl::GASDSignature984>(const pcl::GASDSignature984&) { return (true); }
77  template<> inline bool isFinite<pcl::GASDSignature7992>(const pcl::GASDSignature7992&) { return (true); }
78  template<> inline bool isFinite<pcl::GRSDSignature21>(const pcl::GRSDSignature21&) { return (true); }
79  template<> inline bool isFinite<pcl::Intensity>(const pcl::Intensity&) { return (true); }
80  template<> inline bool isFinite<pcl::IntensityGradient>(const pcl::IntensityGradient&) { return (true); }
81  template<> inline bool isFinite<pcl::Label>(const pcl::Label&) { return (true); }
82  template<> inline bool isFinite<pcl::MomentInvariants>(const pcl::MomentInvariants&) { return (true); }
83  template<> inline bool isFinite<pcl::NormalBasedSignature12>(const pcl::NormalBasedSignature12&) { return (true); }
84  template<> inline bool isFinite<pcl::PFHRGBSignature250>(const pcl::PFHRGBSignature250&) { return (true); }
85  template<> inline bool isFinite<pcl::PFHSignature125>(const pcl::PFHSignature125&) { return (true); }
86  template<> inline bool isFinite<pcl::PPFRGBSignature>(const pcl::PPFRGBSignature&) { return (true); }
87 
88  template<> inline bool isFinite<pcl::PPFSignature>(const pcl::PPFSignature& pt)
89  {
90  return std::isfinite(pt.f1) && std::isfinite(pt.f2) && std::isfinite(pt.f3) && std::isfinite(pt.f4) && std::isfinite(pt.alpha_m);
91  }
92 
93  template<> inline bool isFinite<pcl::PrincipalCurvatures>(const pcl::PrincipalCurvatures&) { return (true); }
94  template<> inline bool isFinite<pcl::PrincipalRadiiRSD>(const pcl::PrincipalRadiiRSD&) { return (true); }
95  template<> inline bool isFinite<pcl::RGB>(const pcl::RGB&) { return (true); }
96  template<> inline bool isFinite<pcl::ReferenceFrame>(const pcl::ReferenceFrame&) { return (true); }
97  template<> inline bool isFinite<pcl::SHOT1344>(const pcl::SHOT1344&) { return (true); }
98  template<> inline bool isFinite<pcl::SHOT352>(const pcl::SHOT352&) { return (true); }
99  template<> inline bool isFinite<pcl::ShapeContext1980>(const pcl::ShapeContext1980&) { return (true); }
100  template<> inline bool isFinite<pcl::UniqueShapeContext1960>(const pcl::UniqueShapeContext1960&) { return (true); }
101  template<> inline bool isFinite<pcl::VFHSignature308>(const pcl::VFHSignature308&) { return (true); }
102 
103  // specification for pcl::PointXY
104  template <> inline bool
105  isFinite<pcl::PointXY> (const pcl::PointXY &p)
106  {
107  return (std::isfinite (p.x) && std::isfinite (p.y));
108  }
109 
110  // specification for pcl::Normal
111  template <> inline bool
112  isFinite<pcl::Normal> (const pcl::Normal &n)
113  {
114  return (std::isfinite (n.normal_x) && std::isfinite (n.normal_y) && std::isfinite (n.normal_z));
115  }
116 
117  // generic fallback cases
118  template <typename PointT, traits::HasNoXY<PointT> = true> constexpr inline bool
119  isXYFinite (const PointT&) noexcept
120  {
121  return true;
122  }
123 
124  template <typename PointT, traits::HasNoXYZ<PointT> = true> constexpr inline bool
125  isXYZFinite (const PointT&) noexcept
126  {
127  return true;
128  }
129 
130  template <typename PointT, traits::HasNoNormal<PointT> = true> constexpr inline bool
131  isNormalFinite (const PointT&) noexcept
132  {
133  return true;
134  }
135 
136  // special cases for checks
137  template <typename PointT, traits::HasXY<PointT> = true> inline bool
138  isXYFinite (const PointT& pt) noexcept
139  {
140  return std::isfinite(pt.x) && std::isfinite(pt.y);
141  }
142 
143  template <typename PointT, traits::HasXYZ<PointT> = true> inline bool
144  isXYZFinite (const PointT& pt) noexcept
145  {
146  return std::isfinite(pt.x) && std::isfinite(pt.y) && std::isfinite(pt.z);
147  }
148 
149  template <typename PointT, traits::HasNormal<PointT> = true> inline bool
150  isNormalFinite (const PointT& pt) noexcept
151  {
152  return std::isfinite(pt.normal_x) && std::isfinite(pt.normal_y) && std::isfinite(pt.normal_z);
153  }
154 }
pcl::PFHSignature125
A point structure representing the Point Feature Histogram (PFH).
Definition: point_types.hpp:1351
pcl
Definition: convolution.h:46
point_types.h
pcl::Normal
A point structure representing normal coordinates and the surface curvature estimate.
Definition: point_types.hpp:899
pcl::PrincipalRadiiRSD
A point structure representing the minimum and maximum surface radii (in meters) computed using RSD.
Definition: point_types.hpp:1285
pcl::PPFRGBSignature
A point structure for storing the Point Pair Color Feature (PPFRGB) values.
Definition: point_types.hpp:1417
pcl::isFinite
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
Definition: point_tests.h:55
pcl::NormalBasedSignature12
A point structure representing the Normal Based Signature for a feature matrix of 4-by-3.
Definition: point_types.hpp:1439
pcl::GASDSignature512
A point structure representing the Globally Aligned Spatial Distribution (GASD) shape descriptor.
Definition: point_types.hpp:1638
pcl::isXYZFinite
constexpr bool isXYZFinite(const PointT &) noexcept
Definition: point_tests.h:125
pcl::ReferenceFrame
Definition: point_types.hpp:1539
pcl::Boundary
A point structure representing a description of whether a point is lying on a surface boundary or not...
Definition: point_types.hpp:1300
pcl::FPFHSignature33
A point structure representing the Fast Point Feature Histogram (FPFH).
Definition: point_types.hpp:1564
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:674
pcl::UniqueShapeContext1960
A point structure representing a Unique Shape Context.
Definition: point_types.hpp:1467
pcl::Intensity
A point structure representing the grayscale intensity in single-channel images.
Definition: point_types.hpp:419
pcl::PointXY::x
float x
Definition: point_types.hpp:833
pcl::ShapeContext1980
A point structure representing a Shape Context.
Definition: point_types.hpp:1452
pcl::GASDSignature7992
A point structure representing the Globally Aligned Spatial Distribution (GASD) shape and color descr...
Definition: point_types.hpp:1666
pcl::PointXY::y
float y
Definition: point_types.hpp:834
pcl::GRSDSignature21
A point structure representing the Global Radius-based Surface Descriptor (GRSD).
Definition: point_types.hpp:1592
pcl::CPPFSignature
A point structure for storing the Point Pair Feature (CPPF) values.
Definition: point_types.hpp:1397
pcl::PPFSignature::f1
float f1
Definition: point_types.hpp:1382
pcl::Label
Definition: point_types.hpp:561
pcl::PPFSignature
A point structure for storing the Point Pair Feature (PPF) values.
Definition: point_types.hpp:1380
pcl::BRISKSignature512
A point structure representing the Binary Robust Invariant Scalable Keypoints (BRISK).
Definition: point_types.hpp:1606
pcl::Axis
A point structure representing an Axis using its normal coordinates.
Definition: point_types.hpp:932
pcl::RGB
A structure representing RGB color information.
Definition: point_types.hpp:391
pcl::PFHRGBSignature250
A point structure representing the Point Feature Histogram with colors (PFHRGB).
Definition: point_types.hpp:1366
pcl::MomentInvariants
A point structure representing the three moment invariants.
Definition: point_types.hpp:1270
pcl::PointXY
A 2D point structure representing Euclidean xy coordinates.
Definition: point_types.hpp:831
pcl::PrincipalCurvatures
A point structure representing the principal curvatures and their magnitudes.
Definition: point_types.hpp:1320
pcl::ESFSignature640
A point structure representing the Ensemble of Shape Functions (ESF).
Definition: point_types.hpp:1624
pcl::isXYFinite
constexpr bool isXYFinite(const PointT &) noexcept
Definition: point_tests.h:119
pcl::PPFSignature::f2
float f2
Definition: point_types.hpp:1382
pcl::GASDSignature984
A point structure representing the Globally Aligned Spatial Distribution (GASD) shape and color descr...
Definition: point_types.hpp:1652
pcl::PPFSignature::alpha_m
float alpha_m
Definition: point_types.hpp:1383
pcl::BorderDescription
A structure to store if a point in a range image lies on a border between an obstacle and the backgro...
Definition: point_types.hpp:1714
pcl::SHOT1344
A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape+col...
Definition: point_types.hpp:1498
pcl::SHOT352
A point structure representing the generic Signature of Histograms of OrienTations (SHOT) - shape onl...
Definition: point_types.hpp:1482
pcl::PPFSignature::f4
float f4
Definition: point_types.hpp:1382
pcl::isNormalFinite
constexpr bool isNormalFinite(const PointT &) noexcept
Definition: point_tests.h:131
pcl::PPFSignature::f3
float f3
Definition: point_types.hpp:1382
pcl::VFHSignature308
A point structure representing the Viewpoint Feature Histogram (VFH).
Definition: point_types.hpp:1578
pcl::IntensityGradient
A point structure representing the intensity gradient of an XYZI point cloud.
Definition: point_types.hpp:1732