40 #include <pcl/point_struct_traits.h>
47 #include <type_traits>
81 template<
typename T>
struct asEnum {};
102 template<>
struct asType<detail::PointFieldTypes::FLOAT32> {
using type = float; };
103 template<>
struct asType<detail::PointFieldTypes::FLOAT64> {
using type = double; };
123 template <
typename Po
intInT,
typename OutT>
126 using Pod =
typename traits::POD<PointInT>::type;
135 const std::string &field,
138 : pt_ (reinterpret_cast<const
Pod&>(pt)), name_ (field), exists_ (exists), value_ (value)
149 const std::string &field,
151 : pt_ (reinterpret_cast<const
Pod&>(pt)), name_ (field), exists_ (exists_tmp_), value_ (value)
156 template <
typename Key>
inline void
159 if (name_ == pcl::traits::name<PointInT, Key>::value)
162 using T =
typename pcl::traits::datatype<PointInT, Key>::type;
163 const std::uint8_t* data_ptr =
reinterpret_cast<const std::uint8_t*
>(&pt_) + pcl::traits::offset<PointInT, Key>::value;
164 value_ =
static_cast<OutT
> (*
reinterpret_cast<const T*
>(data_ptr));
170 const std::string &name_;
188 template <
typename Po
intOutT,
typename InT>
191 using Pod =
typename traits::POD<PointOutT>::type;
199 const std::string &field,
201 : pt_ (reinterpret_cast<
Pod&>(pt)), name_ (field), value_ (value)
206 template <
typename Key>
inline void
209 if (name_ == pcl::traits::name<PointOutT, Key>::value)
211 using T =
typename pcl::traits::datatype<PointOutT, Key>::type;
213 *
reinterpret_cast<T*
>(data_ptr) =
static_cast<T
> (value_);
219 const std::string &name_;
228 template <
typename Po
intT,
typename ValT>
inline void
232 *
reinterpret_cast<ValT*
>(data_ptr) = value;
240 template <
typename Po
intT,
typename ValT>
inline void
244 value = *
reinterpret_cast<const ValT*
>(data_ptr);
247 template <
typename ...>
using void_t = void;
269 #ifndef __cpp_lib_is_invocable
271 template <
typename F,
typename... Args>
273 std::is_constructible<std::function<void(Args...)>,
274 std::reference_wrapper<std::remove_reference_t<F>>>::value;
276 template <
typename R,
typename F,
typename... Args>
278 std::is_constructible<std::function<R(Args...)>,
279 std::reference_wrapper<std::remove_reference_t<F>>>::value;
281 using std::is_invocable_v;
282 using std::is_invocable_r_v;
288 #ifndef __cpp_lib_remove_cvref
289 template <
typename T>
292 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 FLOAT64
static const std::uint8_t UINT8
static const std::uint8_t UINT32
static const std::uint8_t FLOAT32
static const std::uint8_t INT32
static const std::uint8_t UINT16
static const std::uint8_t INT8