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 static const 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 static const 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 static const 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 static const 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 static const 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 static const std::uint32_t count =
sizeof (T1) /
sizeof (type);
189 for (std::uint32_t i = 0; i < count; ++i)
196 #define PCL_PLUSEQ_POINT_TAG(r, data, elem) \
197 pcl::traits::plus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
198 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem));
201 #define PCL_PLUSEQSC_POINT_TAG(r, data, elem) \
202 pcl::traits::plusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
207 #define PCL_MINUSEQ_POINT_TAG(r, data, elem) \
208 pcl::traits::minus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
209 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem));
212 #define PCL_MINUSEQSC_POINT_TAG(r, data, elem) \
213 pcl::traits::minusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
218 #define PCL_MULEQSC_POINT_TAG(r, data, elem) \
219 pcl::traits::mulscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
223 #define PCL_DIVEQSC_POINT_TAG(r, data, elem) \
224 pcl::traits::divscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
231 #define POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, seq) \
236 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_TAG, name, seq) \
240 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_NAME, name, seq) \
241 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_OFFSET, name, seq) \
242 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_DATATYPE, name, seq) \
243 POINT_CLOUD_REGISTER_POINT_FIELD_LIST(name, POINT_CLOUD_EXTRACT_TAGS(seq)) \
248 operator+= (name& lhs, const name& rhs) \
250 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQ_POINT_TAG, _, seq) \
254 operator+= (name& p, const float& scalar) \
256 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQSC_POINT_TAG, _, seq) \
259 inline const name operator+ (const name& lhs, const name& rhs) \
260 { name result = lhs; result += rhs; return (result); } \
261 inline const name operator+ (const float& scalar, const name& p) \
262 { name result = p; result += scalar; return (result); } \
263 inline const name operator+ (const name& p, const float& scalar) \
264 { name result = p; result += scalar; return (result); } \
266 operator-= (name& lhs, const name& rhs) \
268 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQ_POINT_TAG, _, seq) \
272 operator-= (name& p, const float& scalar) \
274 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQSC_POINT_TAG, _, seq) \
277 inline const name operator- (const name& lhs, const name& rhs) \
278 { name result = lhs; result -= rhs; return (result); } \
279 inline const name operator- (const float& scalar, const name& p) \
280 { name result = p; result -= scalar; return (result); } \
281 inline const name operator- (const name& p, const float& scalar) \
282 { name result = p; result -= scalar; return (result); } \
284 operator*= (name& p, const float& scalar) \
286 BOOST_PP_SEQ_FOR_EACH(PCL_MULEQSC_POINT_TAG, _, seq) \
289 inline const name operator* (const float& scalar, const name& p) \
290 { name result = p; result *= scalar; return (result); } \
291 inline const name operator* (const name& p, const float& scalar) \
292 { name result = p; result *= scalar; return (result); } \
294 operator/= (name& p, const float& scalar) \
296 BOOST_PP_SEQ_FOR_EACH(PCL_DIVEQSC_POINT_TAG, _, seq) \
299 inline const name operator/ (const float& scalar, const name& p) \
300 { name result = p; result /= scalar; return (result); } \
301 inline const name operator/ (const name& p, const float& scalar) \
302 { name result = p; result /= scalar; return (result); } \
307 #define POINT_CLOUD_REGISTER_FIELD_TAG(r, name, elem) \
308 struct BOOST_PP_TUPLE_ELEM(3, 2, elem); \
311 #define POINT_CLOUD_TAG_OP(s, data, elem) pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)
313 #define POINT_CLOUD_EXTRACT_TAGS(seq) BOOST_PP_SEQ_TRANSFORM(POINT_CLOUD_TAG_OP, _, seq)
316 #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< 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)