44 #pragma GCC system_header
48 #pragma warning (push, 2)
50 #pragma warning (disable: 4244)
53 #include <pcl/point_struct_traits.h>
54 #include <boost/mpl/assert.hpp>
55 #include <boost/preprocessor/seq/for_each.hpp>
56 #include <boost/preprocessor/seq/transform.hpp>
57 #include <boost/preprocessor/tuple/elem.hpp>
58 #include <boost/preprocessor/cat.hpp>
61 #include <type_traits>
64 #define POINT_CLOUD_REGISTER_POINT_STRUCT(name, fseq) \
65 POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, \
66 BOOST_PP_CAT(POINT_CLOUD_REGISTER_POINT_STRUCT_X fseq, 0))
69 #define POINT_CLOUD_REGISTER_POINT_WRAPPER(wrapper, pod) \
70 BOOST_MPL_ASSERT_MSG(sizeof(wrapper) == sizeof(pod), POINT_WRAPPER_AND_POD_TYPES_HAVE_DIFFERENT_SIZES, (wrapper&, pod&)); \
73 template<> struct POD<wrapper> { using type = pod; }; \
80 #define POINT_CLOUD_REGISTER_POINT_STRUCT_X(type, name, tag) \
81 ((type, name, tag)) POINT_CLOUD_REGISTER_POINT_STRUCT_Y
82 #define POINT_CLOUD_REGISTER_POINT_STRUCT_Y(type, name, tag) \
83 ((type, name, tag)) POINT_CLOUD_REGISTER_POINT_STRUCT_X
84 #define POINT_CLOUD_REGISTER_POINT_STRUCT_X0
85 #define POINT_CLOUD_REGISTER_POINT_STRUCT_Y0
91 template<
typename T>
inline
92 std::enable_if_t<!std::is_array<T>::value>
98 template<
typename T>
inline
99 std::enable_if_t<std::is_array<T>::value>
100 plus (std::remove_const_t<T> &l,
const T &r)
102 using type = std::remove_all_extents_t<T>;
103 constexpr std::uint32_t count =
sizeof(T) /
sizeof(type);
104 for (std::uint32_t i = 0; i < count; ++i)
108 template<
typename T1,
typename T2>
inline
109 std::enable_if_t<!std::is_array<T1>::value>
115 template<
typename T1,
typename T2>
inline
116 std::enable_if_t<std::is_array<T1>::value>
119 using type = std::remove_all_extents_t<T1>;
120 constexpr std::uint32_t count =
sizeof(T1) /
sizeof(type);
121 for (std::uint32_t i = 0; i < count; ++i)
125 template<
typename T>
inline
126 std::enable_if_t<!std::is_array<T>::value>
132 template<
typename T>
inline
133 std::enable_if_t<std::is_array<T>::value>
134 minus (std::remove_const_t<T> &l,
const T &r)
136 using type = std::remove_all_extents_t<T>;
137 constexpr std::uint32_t count =
sizeof(T) /
sizeof(type);
138 for (std::uint32_t i = 0; i < count; ++i)
142 template<
typename T1,
typename T2>
inline
143 std::enable_if_t<!std::is_array<T1>::value>
149 template<
typename T1,
typename T2>
inline
150 std::enable_if_t<std::is_array<T1>::value>
153 using type = std::remove_all_extents_t<T1>;
154 constexpr std::uint32_t count =
sizeof(T1) /
sizeof(type);
155 for (std::uint32_t i = 0; i < count; ++i)
159 template<
typename T1,
typename T2>
inline
160 std::enable_if_t<!std::is_array<T1>::value>
166 template<
typename T1,
typename T2>
inline
167 std::enable_if_t<std::is_array<T1>::value>
170 using type = std::remove_all_extents_t<T1>;
171 constexpr std::uint32_t count =
sizeof(T1) /
sizeof(type);
172 for (std::uint32_t i = 0; i < count; ++i)
176 template<
typename T1,
typename T2>
inline
177 std::enable_if_t<!std::is_array<T1>::value>
183 template<
typename T1,
typename T2>
inline
184 std::enable_if_t<std::is_array<T1>::value>
187 using type = std::remove_all_extents_t<T1>;
188 constexpr std::uint32_t count =
sizeof (T1) /
sizeof (type);
189 for (std::uint32_t i = 0; i < count; ++i)
193 template<
typename NoArrayT,
typename ScalarT>
inline
194 std::enable_if_t<!std::is_array<NoArrayT>::value>
200 template<
typename ArrayT,
typename ScalarT>
inline
201 std::enable_if_t<std::is_array<ArrayT>::value>
204 using type = std::remove_all_extents_t<ArrayT>;
205 constexpr std::uint32_t count =
sizeof (ArrayT) /
sizeof (type);
206 for (std::uint32_t i = 0; i < count; ++i)
207 p[i] = scalar / p[i];
213 #define PCL_PLUSEQ_POINT_TAG(r, data, elem) \
214 pcl::traits::plus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
215 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem));
218 #define PCL_PLUSEQSC_POINT_TAG(r, data, elem) \
219 pcl::traits::plusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
224 #define PCL_MINUSEQ_POINT_TAG(r, data, elem) \
225 pcl::traits::minus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
226 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem));
229 #define PCL_MINUSEQSC_POINT_TAG(r, data, elem) \
230 pcl::traits::minusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
235 #define PCL_MULEQSC_POINT_TAG(r, data, elem) \
236 pcl::traits::mulscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
240 #define PCL_DIVEQSC_POINT_TAG(r, data, elem) \
241 pcl::traits::divscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
245 #define PCL_DIVEQSC2_POINT_TAG(r, data, elem) \
246 pcl::traits::divscalar2 (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
253 #define POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, seq) \
258 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_TAG, name, seq) \
262 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_NAME, name, seq) \
263 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_OFFSET, name, seq) \
264 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_DATATYPE, name, seq) \
265 POINT_CLOUD_REGISTER_POINT_FIELD_LIST(name, POINT_CLOUD_EXTRACT_TAGS(seq)) \
270 operator+= (name& lhs, const name& rhs) \
272 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQ_POINT_TAG, _, seq) \
276 operator+= (name& p, const float& scalar) \
278 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQSC_POINT_TAG, _, seq) \
281 inline const name operator+ (const name& lhs, const name& rhs) \
282 { name result = lhs; result += rhs; return (result); } \
283 inline const name operator+ (const float& scalar, const name& p) \
284 { name result = p; result += scalar; return (result); } \
285 inline const name operator+ (const name& p, const float& scalar) \
286 { name result = p; result += scalar; return (result); } \
288 operator*= (name& p, const float& scalar) \
290 BOOST_PP_SEQ_FOR_EACH(PCL_MULEQSC_POINT_TAG, _, seq) \
293 inline const name operator* (const float& scalar, const name& p) \
294 { name result = p; result *= scalar; return (result); } \
295 inline const name operator* (const name& p, const float& scalar) \
296 { name result = p; result *= scalar; return (result); } \
298 operator-= (name& lhs, const name& rhs) \
300 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQ_POINT_TAG, _, seq) \
304 operator-= (name& p, const float& scalar) \
306 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQSC_POINT_TAG, _, seq) \
309 inline const name operator- (const name& lhs, const name& rhs) \
310 { name result = lhs; result -= rhs; return (result); } \
311 inline const name operator- (const float& scalar, const name& p) \
312 { name result = p; result *= -1.0f; result += scalar; return (result); } \
313 inline const name operator- (const name& p, const float& scalar) \
314 { name result = p; result -= scalar; return (result); } \
316 operator/= (name& p, const float& scalar) \
318 BOOST_PP_SEQ_FOR_EACH(PCL_DIVEQSC_POINT_TAG, _, seq) \
321 inline const name operator/ (const float& scalar, const name& p_in) \
322 { name p = p_in; BOOST_PP_SEQ_FOR_EACH(PCL_DIVEQSC2_POINT_TAG, _, seq) \
324 inline const name operator/ (const name& p, const float& scalar) \
325 { name result = p; result /= scalar; return (result); } \
330 #define POINT_CLOUD_REGISTER_FIELD_TAG(r, name, elem) \
331 struct BOOST_PP_TUPLE_ELEM(3, 2, elem); \
334 #define POINT_CLOUD_TAG_OP(s, data, elem) pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)
336 #define POINT_CLOUD_EXTRACT_TAGS(seq) BOOST_PP_SEQ_TRANSFORM(POINT_CLOUD_TAG_OP, _, seq)
339 #pragma warning (pop)
std::enable_if_t<!std::is_array< T1 >::value > plusscalar(T1 &p, const T2 &scalar)
std::enable_if_t<!std::is_array< T1 >::value > mulscalar(T1 &p, const T2 &scalar)
std::enable_if_t<!std::is_array< T1 >::value > minusscalar(T1 &p, const T2 &scalar)
std::enable_if_t<!std::is_array< NoArrayT >::value > divscalar2(NoArrayT &p, const ScalarT &scalar)
std::enable_if_t<!std::is_array< T1 >::value > divscalar(T1 &p, const T2 &scalar)
std::enable_if_t<!std::is_array< T >::value > plus(T &l, const T &r)
std::enable_if_t<!std::is_array< T >::value > minus(T &l, const T &r)