40 #include <pcl/point_struct_traits.h>
47 #include <type_traits>
83 template<
typename T>
struct asEnum {};
101 template<>
struct asType<detail::PointFieldTypes::BOOL> {
using type = bool; };
102 template<>
struct asType<detail::PointFieldTypes::INT8> {
using type = std::int8_t; };
103 template<>
struct asType<detail::PointFieldTypes::UINT8> {
using type = std::uint8_t; };
104 template<>
struct asType<detail::PointFieldTypes::INT16> {
using type = std::int16_t; };
105 template<>
struct asType<detail::PointFieldTypes::UINT16> {
using type = std::uint16_t; };
106 template<>
struct asType<detail::PointFieldTypes::INT32> {
using type = std::int32_t; };
107 template<>
struct asType<detail::PointFieldTypes::UINT32> {
using type = std::uint32_t; };
108 template<>
struct asType<detail::PointFieldTypes::INT64> {
using type = std::int64_t; };
109 template<>
struct asType<detail::PointFieldTypes::UINT64> {
using type = std::uint64_t; };
110 template<>
struct asType<detail::PointFieldTypes::FLOAT32> {
using type = float; };
111 template<>
struct asType<detail::PointFieldTypes::FLOAT64> {
using type = double; };
131 template <
typename Po
intInT,
typename OutT>
134 using Pod =
typename traits::POD<PointInT>::type;
143 const std::string &field,
146 : pt_ (reinterpret_cast<const
Pod&>(pt)), name_ (field), exists_ (exists), value_ (value)
157 const std::string &field,
159 : pt_ (reinterpret_cast<const
Pod&>(pt)), name_ (field), exists_ (exists_tmp_), value_ (value)
164 template <
typename Key>
inline void
167 if (name_ == pcl::traits::name<PointInT, Key>::value)
170 using T =
typename pcl::traits::datatype<PointInT, Key>::type;
171 const std::uint8_t* data_ptr =
reinterpret_cast<const std::uint8_t*
>(&pt_) + pcl::traits::offset<PointInT, Key>::value;
172 value_ =
static_cast<OutT
> (*
reinterpret_cast<const T*
>(data_ptr));
178 const std::string &name_;
196 template <
typename Po
intOutT,
typename InT>
199 using Pod =
typename traits::POD<PointOutT>::type;
207 const std::string &field,
209 : pt_ (reinterpret_cast<
Pod&>(pt)), name_ (field), value_ (value)
214 template <
typename Key>
inline void
217 if (name_ == pcl::traits::name<PointOutT, Key>::value)
219 using T =
typename pcl::traits::datatype<PointOutT, Key>::type;
220 std::uint8_t* data_ptr =
reinterpret_cast<std::uint8_t*
>(&pt_) + pcl::traits::offset<PointOutT, Key>::value;
221 *
reinterpret_cast<T*
>(data_ptr) =
static_cast<T
> (value_);
227 const std::string &name_;
236 template <
typename Po
intT,
typename ValT>
inline void
239 std::uint8_t* data_ptr =
reinterpret_cast<std::uint8_t*
>(&pt) + field_offset;
240 *
reinterpret_cast<ValT*
>(data_ptr) = value;
248 template <
typename Po
intT,
typename ValT>
inline void
251 const std::uint8_t* data_ptr =
reinterpret_cast<const std::uint8_t*
>(&pt) + field_offset;
252 value = *
reinterpret_cast<const ValT*
>(data_ptr);
255 template <
typename ...>
using void_t = void;
277 #ifndef __cpp_lib_is_invocable
279 template <
typename F,
typename... Args>
281 std::is_constructible<std::function<void(Args...)>,
282 std::reference_wrapper<std::remove_reference_t<F>>>::value;
284 template <
typename R,
typename F,
typename... Args>
286 std::is_constructible<std::function<R(Args...)>,
287 std::reference_wrapper<std::remove_reference_t<F>>>::value;
289 using std::is_invocable_v;
290 using std::is_invocable_r_v;
296 #ifndef __cpp_lib_remove_cvref
297 template <
typename T>
300 using std::remove_cvref_t;
typename asType< index >::type asType_t
static constexpr std::uint8_t asEnum_v
void setFieldValue(PointT &pt, std::size_t field_offset, const ValT &value)
Set the value at a specified field in a point.
constexpr bool is_invocable_v
void getFieldValue(const PointT &pt, std::size_t field_offset, ValT &value)
Get the value at a specified field in a point.
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
constexpr bool is_invocable_r_v
A helper functor that can copy a specific value if the given field exists.
CopyIfFieldExists(const PointInT &pt, const std::string &field, OutT &value)
Constructor.
CopyIfFieldExists(const PointInT &pt, const std::string &field, bool &exists, OutT &value)
Constructor.
void operator()()
Operator.
typename traits::POD< PointInT >::type Pod
A point structure representing Euclidean xyz coordinates, and the RGB color.
A helper functor that can set a specific value in a field if the field exists.
SetIfFieldExists(PointOutT &pt, const std::string &field, const InT &value)
Constructor.
typename traits::POD< PointOutT >::type Pod
void operator()()
Operator.
Tests at compile time if type T has a custom allocator.
Enumeration for different numerical types.
static const std::uint8_t INT16
static const std::uint8_t INT64
static const std::uint8_t FLOAT64
static const std::uint8_t UINT64
static const std::uint8_t UINT8
static const std::uint8_t UINT32
static const std::uint8_t BOOL
static const std::uint8_t FLOAT32
static const std::uint8_t INT32
static const std::uint8_t UINT16
static const std::uint8_t INT8