44 #pragma GCC system_header
48 #pragma warning (push, 2)
50 #pragma warning (disable: 4244)
56 #include <pcl/point_traits.h>
57 #include <boost/mpl/vector.hpp>
58 #include <boost/preprocessor/seq/enum.hpp>
59 #include <boost/preprocessor/seq/for_each.hpp>
60 #include <boost/preprocessor/seq/transform.hpp>
61 #include <boost/preprocessor/cat.hpp>
62 #include <boost/preprocessor/comparison.hpp>
66 #include <type_traits>
69 #define POINT_CLOUD_REGISTER_POINT_STRUCT(name, fseq) \
70 POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, \
71 BOOST_PP_CAT(POINT_CLOUD_REGISTER_POINT_STRUCT_X fseq, 0))
74 #define POINT_CLOUD_REGISTER_POINT_WRAPPER(wrapper, pod) \
75 BOOST_MPL_ASSERT_MSG(sizeof(wrapper) == sizeof(pod), POINT_WRAPPER_AND_POD_TYPES_HAVE_DIFFERENT_SIZES, (wrapper&, pod&)); \
78 template<> struct POD<wrapper> { using type = pod; }; \
85 #define POINT_CLOUD_REGISTER_POINT_STRUCT_X(type, name, tag) \
86 ((type, name, tag)) POINT_CLOUD_REGISTER_POINT_STRUCT_Y
87 #define POINT_CLOUD_REGISTER_POINT_STRUCT_Y(type, name, tag) \
88 ((type, name, tag)) POINT_CLOUD_REGISTER_POINT_STRUCT_X
89 #define POINT_CLOUD_REGISTER_POINT_STRUCT_X0
90 #define POINT_CLOUD_REGISTER_POINT_STRUCT_Y0
96 template<
typename T>
inline
97 std::enable_if_t<!std::is_array<T>::value>
103 template<
typename T>
inline
104 std::enable_if_t<std::is_array<T>::value>
105 plus (std::remove_const_t<T> &l,
const T &r)
107 using type = std::remove_all_extents_t<T>;
108 static const std::uint32_t count =
sizeof (T) /
sizeof (type);
109 for (std::uint32_t i = 0; i < count; ++i)
113 template<
typename T1,
typename T2>
inline
114 std::enable_if_t<!std::is_array<T1>::value>
120 template<
typename T1,
typename T2>
inline
121 std::enable_if_t<std::is_array<T1>::value>
124 using type = std::remove_all_extents_t<T1>;
125 static const std::uint32_t count =
sizeof (T1) /
sizeof (type);
126 for (std::uint32_t i = 0; i < count; ++i)
130 template<
typename T>
inline
131 std::enable_if_t<!std::is_array<T>::value>
137 template<
typename T>
inline
138 std::enable_if_t<std::is_array<T>::value>
139 minus (std::remove_const_t<T> &l,
const T &r)
141 using type = std::remove_all_extents_t<T>;
142 static const std::uint32_t count =
sizeof (T) /
sizeof (type);
143 for (std::uint32_t i = 0; i < count; ++i)
147 template<
typename T1,
typename T2>
inline
148 std::enable_if_t<!std::is_array<T1>::value>
154 template<
typename T1,
typename T2>
inline
155 std::enable_if_t<std::is_array<T1>::value>
158 using type = std::remove_all_extents_t<T1>;
159 static const std::uint32_t count =
sizeof (T1) /
sizeof (type);
160 for (std::uint32_t i = 0; i < count; ++i)
164 template<
typename T1,
typename T2>
inline
165 std::enable_if_t<!std::is_array<T1>::value>
171 template<
typename T1,
typename T2>
inline
172 std::enable_if_t<std::is_array<T1>::value>
175 using type = std::remove_all_extents_t<T1>;
176 static const std::uint32_t count =
sizeof (T1) /
sizeof (type);
177 for (std::uint32_t i = 0; i < count; ++i)
181 template<
typename T1,
typename T2>
inline
182 std::enable_if_t<!std::is_array<T1>::value>
188 template<
typename T1,
typename T2>
inline
189 std::enable_if_t<std::is_array<T1>::value>
192 using type = std::remove_all_extents_t<T1>;
193 static const std::uint32_t count =
sizeof (T1) /
sizeof (type);
194 for (std::uint32_t i = 0; i < count; ++i)
201 #define PCL_PLUSEQ_POINT_TAG(r, data, elem) \
202 pcl::traits::plus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
203 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem));
206 #define PCL_PLUSEQSC_POINT_TAG(r, data, elem) \
207 pcl::traits::plusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
212 #define PCL_MINUSEQ_POINT_TAG(r, data, elem) \
213 pcl::traits::minus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
214 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem));
217 #define PCL_MINUSEQSC_POINT_TAG(r, data, elem) \
218 pcl::traits::minusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
223 #define PCL_MULEQSC_POINT_TAG(r, data, elem) \
224 pcl::traits::mulscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
228 #define PCL_DIVEQSC_POINT_TAG(r, data, elem) \
229 pcl::traits::divscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \
236 #define POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, seq) \
241 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_TAG, name, seq) \
245 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_NAME, name, seq) \
246 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_OFFSET, name, seq) \
247 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_DATATYPE, name, seq) \
248 POINT_CLOUD_REGISTER_POINT_FIELD_LIST(name, POINT_CLOUD_EXTRACT_TAGS(seq)) \
253 operator+= (name& lhs, const name& rhs) \
255 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQ_POINT_TAG, _, seq) \
259 operator+= (name& p, const float& scalar) \
261 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQSC_POINT_TAG, _, seq) \
264 inline const name operator+ (const name& lhs, const name& rhs) \
265 { name result = lhs; result += rhs; return (result); } \
266 inline const name operator+ (const float& scalar, const name& p) \
267 { name result = p; result += scalar; return (result); } \
268 inline const name operator+ (const name& p, const float& scalar) \
269 { name result = p; result += scalar; return (result); } \
271 operator-= (name& lhs, const name& rhs) \
273 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQ_POINT_TAG, _, seq) \
277 operator-= (name& p, const float& scalar) \
279 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQSC_POINT_TAG, _, seq) \
282 inline const name operator- (const name& lhs, const name& rhs) \
283 { name result = lhs; result -= rhs; return (result); } \
284 inline const name operator- (const float& scalar, const name& p) \
285 { name result = p; result -= scalar; return (result); } \
286 inline const name operator- (const name& p, const float& scalar) \
287 { name result = p; result -= scalar; return (result); } \
289 operator*= (name& p, const float& scalar) \
291 BOOST_PP_SEQ_FOR_EACH(PCL_MULEQSC_POINT_TAG, _, seq) \
294 inline const name operator* (const float& scalar, const name& p) \
295 { name result = p; result *= scalar; return (result); } \
296 inline const name operator* (const name& p, const float& scalar) \
297 { name result = p; result *= scalar; return (result); } \
299 operator/= (name& p, const float& scalar) \
301 BOOST_PP_SEQ_FOR_EACH(PCL_DIVEQSC_POINT_TAG, _, seq) \
304 inline const name operator/ (const float& scalar, const name& p) \
305 { name result = p; result /= scalar; return (result); } \
306 inline const name operator/ (const name& p, const float& scalar) \
307 { name result = p; result /= scalar; return (result); } \
312 #define POINT_CLOUD_REGISTER_FIELD_TAG(r, name, elem) \
313 struct BOOST_PP_TUPLE_ELEM(3, 2, elem); \
316 #define POINT_CLOUD_REGISTER_FIELD_NAME(r, point, elem) \
317 template<int dummy> \
318 struct name<point, pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem), dummy> \
320 static const char value[]; \
323 template<int dummy> \
324 const char name<point, \
325 pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem), \
327 BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(3, 2, elem));
330 #define POINT_CLOUD_REGISTER_FIELD_OFFSET(r, name, elem) \
331 template<> struct offset<name, pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)> \
333 static const std::size_t value = offsetof(name, BOOST_PP_TUPLE_ELEM(3, 1, elem)); \
337 #define POINT_CLOUD_REGISTER_FIELD_DATATYPE(r, name, elem) \
338 template<> struct datatype<name, pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)> \
340 using type = boost::mpl::identity<BOOST_PP_TUPLE_ELEM(3, 0, elem)>::type; \
341 using decomposed = decomposeArray<type>; \
342 static const std::uint8_t value = asEnum<decomposed::type>::value; \
343 static const std::uint32_t size = decomposed::value; \
347 #define POINT_CLOUD_TAG_OP(s, data, elem) pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)
349 #define POINT_CLOUD_EXTRACT_TAGS(seq) BOOST_PP_SEQ_TRANSFORM(POINT_CLOUD_TAG_OP, _, seq)
351 #define POINT_CLOUD_REGISTER_POINT_FIELD_LIST(name, seq) \
352 template<> struct fieldList<name> \
354 using type = boost::mpl::vector<BOOST_PP_SEQ_ENUM(seq)>; \
359 #pragma warning (pop)