Point Cloud Library (PCL) 1.15.1-dev
Loading...
Searching...
No Matches
field_traits.hpp
1/*
2* SPDX-License-Identifier: BSD-3-Clause
3*
4* Point Cloud Library (PCL) - www.pointclouds.org
5* Copyright (c) 2025-, Open Perception Inc.
6*
7* All rights reserved
8*/
9
10#pragma once
11
12#include <pcl/point_struct_traits.h> // for pcl::traits::fieldList
13
14// Forward declarations of common pcl field types
15namespace pcl
16{
17namespace fields
18{
19struct x;
20struct y;
21struct z;
22struct normal_x;
23struct normal_y;
24struct normal_z;
25struct curvature;
26struct intensity;
27struct rgb;
28struct rgba;
29struct label;
30} // namespace fields
31} // namespace pcl
32
33#include <boost/mpl/and.hpp> // for boost::mpl::and_
34#include <boost/mpl/bool.hpp> // for boost::mpl::bool_
35#include <boost/mpl/contains.hpp> // for boost::mpl::contains
36#include <boost/mpl/fold.hpp> // for boost::mpl::fold
37#include <boost/mpl/or.hpp> // for boost::mpl::or_
38#include <boost/mpl/placeholders.hpp> // for boost::mpl::_1, boost::mpl::_2
39#include <boost/mpl/vector.hpp> // for boost::mpl::vector
40
41namespace pcl
42{
43namespace traits
44{
45
46template <typename PointT, typename Field>
47struct has_field : boost::mpl::contains<typename pcl::traits::fieldList<PointT>::type, Field>::type
48{ };
49
50template <typename PointT, typename Field>
51struct has_all_fields : boost::mpl::fold<Field,
52 boost::mpl::bool_<true>,
53 boost::mpl::and_<boost::mpl::_1,
54 has_field<PointT, boost::mpl::_2> > >::type
55{ };
56
57template <typename PointT, typename Field>
58struct has_any_field : boost::mpl::fold<Field,
59 boost::mpl::bool_<false>,
60 boost::mpl::or_<boost::mpl::_1,
61 has_field<PointT, boost::mpl::_2> > >::type
62{ };
63
64template <typename PointT>
65struct has_xy : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x,
66 pcl::fields::y> >
67{ };
68
69template <typename PointT>
70struct has_xyz : has_all_fields<PointT, boost::mpl::vector<pcl::fields::x,
71 pcl::fields::y,
72 pcl::fields::z> >
73{ };
74
75template <typename PointT>
76struct has_normal : has_all_fields<PointT, boost::mpl::vector<pcl::fields::normal_x,
77 pcl::fields::normal_y,
78 pcl::fields::normal_z> >
79{ };
80
81template <typename PointT>
82struct has_curvature : has_field<PointT, pcl::fields::curvature>
83{ };
84
85template <typename PointT>
86struct has_intensity : has_field<PointT, pcl::fields::intensity>
87{ };
88
89template <typename PointT>
90struct has_color : has_any_field<PointT, boost::mpl::vector<pcl::fields::rgb,
91 pcl::fields::rgba> >
92{ };
93
94template <typename PointT>
95struct has_label : has_field<PointT, pcl::fields::label>
96{ };
97
98} // namespace traits
99} // namespace pcl
Metafunction to check if a given point type has all given fields.
Metafunction to check if a given point type has any of the given fields.
Metafunction to check if a given point type has either rgb or rgba field.
Metafunction to check if a given point type has curvature field.
Metafunction to check if a given point type has a given field.
Metafunction to check if a given point type has intensity field.
Metafunction to check if a given point type has label field.
Metafunction to check if a given point type has normal_x, normal_y, and normal_z fields.
Traits defined for ease of use with common fields.
Metafunction to check if a given point type has x, y, and z fields.