Point Cloud Library (PCL) 1.15.1-dev
Loading...
Searching...
No Matches
field_traits.h
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 <type_traits> // for std::enable_if
13
14namespace pcl
15{
16namespace traits
17{
18
19/** \brief Metafunction to check if a given point type has a given field.
20 *
21 * Example usage at run-time:
22 *
23 * \code
24 * bool curvature_available = pcl::traits::has_field<PointT, pcl::fields::curvature>::value;
25 * \endcode
26 *
27 * Example usage at compile-time:
28 *
29 * \code
30 * BOOST_MPL_ASSERT_MSG ((pcl::traits::has_field<PointT, pcl::fields::label>::value),
31 * POINT_TYPE_SHOULD_HAVE_LABEL_FIELD,
32 * (PointT));
33 * \endcode
34 */
35template <typename PointT, typename Field>
36struct has_field;
37
38/** Metafunction to check if a given point type has all given fields. */
39template <typename PointT, typename Field>
40struct has_all_fields;
41
42/** Metafunction to check if a given point type has any of the given fields. */
43template <typename PointT, typename Field>
44struct has_any_field;
45
46/** \brief Traits defined for ease of use with common fields
47 *
48 * has_<fields to be detected>: struct with `value` datamember defined at compiletime
49 * has_<fields to be detected>_v: constexpr boolean
50 * Has<Fields to be detected>: concept modelling name alias for `enable_if`
51 */
52
53/** Metafunction to check if a given point type has x and y fields. */
54template <typename PointT>
55struct has_xy;
56
57template <typename PointT>
59
60template <typename PointT>
61using HasXY = std::enable_if_t<has_xy_v<PointT>, bool>;
62
63template <typename PointT>
64using HasNoXY = std::enable_if_t<!has_xy_v<PointT>, bool>;
65
66/** Metafunction to check if a given point type has x, y, and z fields. */
67template <typename PointT>
68struct has_xyz;
69
70template <typename PointT>
72
73template <typename PointT>
74using HasXYZ = std::enable_if_t<has_xyz_v<PointT>, bool>;
75
76template <typename PointT>
77using HasNoXYZ = std::enable_if_t<!has_xyz_v<PointT>, bool>;
78
79/** Metafunction to check if a given point type has normal_x, normal_y, and
80 * normal_z fields. */
81template <typename PointT>
82struct has_normal;
83
84template <typename PointT>
86
87template <typename PointT>
88using HasNormal = std::enable_if_t<has_normal_v<PointT>, bool>;
89
90template <typename PointT>
91using HasNoNormal = std::enable_if_t<!has_normal_v<PointT>, bool>;
92
93/** Metafunction to check if a given point type has curvature field. */
94template <typename PointT>
95struct has_curvature;
96
97template <typename PointT>
99
100template <typename PointT>
101using HasCurvature = std::enable_if_t<has_curvature_v<PointT>, bool>;
102
103template <typename PointT>
104using HasNoCurvature = std::enable_if_t<!has_curvature_v<PointT>, bool>;
105
106/** Metafunction to check if a given point type has intensity field. */
107template <typename PointT>
108struct has_intensity;
109
110template <typename PointT>
112
113template <typename PointT>
114using HasIntensity = std::enable_if_t<has_intensity_v<PointT>, bool>;
115
116template <typename PointT>
117using HasNoIntensity = std::enable_if_t<!has_intensity_v<PointT>, bool>;
118
119/** Metafunction to check if a given point type has either rgb or rgba field. */
120template <typename PointT>
121struct has_color;
122
123template <typename PointT>
125
126template <typename PointT>
127using HasColor = std::enable_if_t<has_color_v<PointT>, bool>;
128
129template <typename PointT>
130using HasNoColor = std::enable_if_t<!has_color_v<PointT>, bool>;
131
132/** Metafunction to check if a given point type has label field. */
133template <typename PointT>
134struct has_label;
135
136template <typename PointT>
138
139template <typename PointT>
140using HasLabel = std::enable_if_t<has_label_v<PointT>, bool>;
141
142template <typename PointT>
143using HasNoLabel = std::enable_if_t<!has_label_v<PointT>, bool>;
144
145} // namespace traits
146} // namespace pcl
147
148#include <pcl/impl/field_traits.hpp>
constexpr auto has_xyz_v
std::enable_if_t< has_curvature_v< PointT >, bool > HasCurvature
std::enable_if_t< has_normal_v< PointT >, bool > HasNormal
std::enable_if_t< has_intensity_v< PointT >, bool > HasIntensity
constexpr auto has_xy_v
std::enable_if_t< has_color_v< PointT >, bool > HasColor
std::enable_if_t<!has_normal_v< PointT >, bool > HasNoNormal
constexpr auto has_label_v
constexpr auto has_color_v
constexpr auto has_intensity_v
std::enable_if_t<!has_xyz_v< PointT >, bool > HasNoXYZ
std::enable_if_t<!has_intensity_v< PointT >, bool > HasNoIntensity
std::enable_if_t< has_xyz_v< PointT >, bool > HasXYZ
std::enable_if_t<!has_curvature_v< PointT >, bool > HasNoCurvature
std::enable_if_t<!has_color_v< PointT >, bool > HasNoColor
std::enable_if_t<!has_xy_v< PointT >, bool > HasNoXY
std::enable_if_t<!has_label_v< PointT >, bool > HasNoLabel
constexpr auto has_curvature_v
std::enable_if_t< has_xy_v< PointT >, bool > HasXY
std::enable_if_t< has_label_v< PointT >, bool > HasLabel
constexpr auto has_normal_v
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.