41 #ifndef PCL_REGISTER_POINT_STRUCT_H_ 42 #define PCL_REGISTER_POINT_STRUCT_H_ 45 #pragma GCC system_header 49 #pragma warning (push, 2) 51 #pragma warning (disable: 4244) 56 #include <pcl/pcl_macros.h> 57 #include <pcl/point_traits.h> 58 #include <boost/mpl/vector.hpp> 59 #include <boost/preprocessor/seq/enum.hpp> 60 #include <boost/preprocessor/seq/for_each.hpp> 61 #include <boost/preprocessor/seq/transform.hpp> 62 #include <boost/preprocessor/cat.hpp> 63 #include <boost/preprocessor/comparison.hpp> 64 #include <boost/utility.hpp> 65 #include <boost/type_traits.hpp> 70 #define POINT_CLOUD_REGISTER_POINT_STRUCT(name, fseq) \ 71 POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, \ 72 BOOST_PP_CAT(POINT_CLOUD_REGISTER_POINT_STRUCT_X fseq, 0)) \ 75 #define POINT_CLOUD_REGISTER_POINT_WRAPPER(wrapper, pod) \ 76 BOOST_MPL_ASSERT_MSG(sizeof(wrapper) == sizeof(pod), POINT_WRAPPER_AND_POD_TYPES_HAVE_DIFFERENT_SIZES, (wrapper&, pod&)); \ 79 template<> struct POD<wrapper> { typedef pod type; }; \ 86 #define POINT_CLOUD_REGISTER_POINT_STRUCT_X(type, name, tag) \ 87 ((type, name, tag)) POINT_CLOUD_REGISTER_POINT_STRUCT_Y 88 #define POINT_CLOUD_REGISTER_POINT_STRUCT_Y(type, name, tag) \ 89 ((type, name, tag)) POINT_CLOUD_REGISTER_POINT_STRUCT_X 90 #define POINT_CLOUD_REGISTER_POINT_STRUCT_X0 91 #define POINT_CLOUD_REGISTER_POINT_STRUCT_Y0 97 template<
typename T>
inline 98 typename boost::disable_if_c<boost::is_array<T>::value>::type
104 template<
typename T>
inline 105 typename boost::enable_if_c<boost::is_array<T>::value>::type
106 plus (
typename boost::remove_const<T>::type &l,
const T &r)
108 typedef typename boost::remove_all_extents<T>::type type;
109 static const uint32_t count =
sizeof (T) /
sizeof (type);
110 for (
int i = 0; i < count; ++i)
114 template<
typename T1,
typename T2>
inline 115 typename boost::disable_if_c<boost::is_array<T1>::value>::type
121 template<
typename T1,
typename T2>
inline 122 typename boost::enable_if_c<boost::is_array<T1>::value>::type
125 typedef typename boost::remove_all_extents<T1>::type type;
126 static const uint32_t count =
sizeof (T1) /
sizeof (type);
127 for (
int i = 0; i < count; ++i)
131 template<
typename T>
inline 132 typename boost::disable_if_c<boost::is_array<T>::value>::type
138 template<
typename T>
inline 139 typename boost::enable_if_c<boost::is_array<T>::value>::type
140 minus (
typename boost::remove_const<T>::type &l,
const T &r)
142 typedef typename boost::remove_all_extents<T>::type type;
143 static const uint32_t count =
sizeof (T) /
sizeof (type);
144 for (
int i = 0; i < count; ++i)
148 template<
typename T1,
typename T2>
inline 149 typename boost::disable_if_c<boost::is_array<T1>::value>::type
155 template<
typename T1,
typename T2>
inline 156 typename boost::enable_if_c<boost::is_array<T1>::value>::type
159 typedef typename boost::remove_all_extents<T1>::type type;
160 static const uint32_t count =
sizeof (T1) /
sizeof (type);
161 for (
int i = 0; i < count; ++i)
165 template<
typename T1,
typename T2>
inline 166 typename boost::disable_if_c<boost::is_array<T1>::value>::type
172 template<
typename T1,
typename T2>
inline 173 typename boost::enable_if_c<boost::is_array<T1>::value>::type
176 typedef typename boost::remove_all_extents<T1>::type type;
177 static const uint32_t count =
sizeof (T1) /
sizeof (type);
178 for (
int i = 0; i < count; ++i)
182 template<
typename T1,
typename T2>
inline 183 typename boost::disable_if_c<boost::is_array<T1>::value>::type
189 template<
typename T1,
typename T2>
inline 190 typename boost::enable_if_c<boost::is_array<T1>::value>::type
193 typedef typename boost::remove_all_extents<T1>::type type;
194 static const uint32_t count =
sizeof (T1) /
sizeof (type);
195 for (
int i = 0; i < count; ++i)
202 #define PCL_PLUSEQ_POINT_TAG(r, data, elem) \ 203 pcl::traits::plus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \ 204 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem)); \ 207 #define PCL_PLUSEQSC_POINT_TAG(r, data, elem) \ 208 pcl::traits::plusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \ 213 #define PCL_MINUSEQ_POINT_TAG(r, data, elem) \ 214 pcl::traits::minus (lhs.BOOST_PP_TUPLE_ELEM(3, 1, elem), \ 215 rhs.BOOST_PP_TUPLE_ELEM(3, 1, elem)); \ 218 #define PCL_MINUSEQSC_POINT_TAG(r, data, elem) \ 219 pcl::traits::minusscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \ 224 #define PCL_MULEQSC_POINT_TAG(r, data, elem) \ 225 pcl::traits::mulscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \ 229 #define PCL_DIVEQSC_POINT_TAG(r, data, elem) \ 230 pcl::traits::divscalar (p.BOOST_PP_TUPLE_ELEM(3, 1, elem), \ 237 #define POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, seq) \ 242 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_TAG, name, seq) \ 246 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_NAME, name, seq) \ 247 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_OFFSET, name, seq) \ 248 BOOST_PP_SEQ_FOR_EACH(POINT_CLOUD_REGISTER_FIELD_DATATYPE, name, seq) \ 249 POINT_CLOUD_REGISTER_POINT_FIELD_LIST(name, POINT_CLOUD_EXTRACT_TAGS(seq)) \ 254 operator+= (name& lhs, const name& rhs) \ 256 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQ_POINT_TAG, _, seq) \ 260 operator+= (name& p, const float& scalar) \ 262 BOOST_PP_SEQ_FOR_EACH(PCL_PLUSEQSC_POINT_TAG, _, seq) \ 265 inline const name operator+ (const name& lhs, const name& rhs) \ 266 { name result = lhs; result += rhs; return (result); } \ 267 inline const name operator+ (const float& scalar, const name& p) \ 268 { name result = p; result += scalar; return (result); } \ 269 inline const name operator+ (const name& p, const float& scalar) \ 270 { name result = p; result += scalar; return (result); } \ 272 operator-= (name& lhs, const name& rhs) \ 274 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQ_POINT_TAG, _, seq) \ 278 operator-= (name& p, const float& scalar) \ 280 BOOST_PP_SEQ_FOR_EACH(PCL_MINUSEQSC_POINT_TAG, _, seq) \ 283 inline const name operator- (const name& lhs, const name& rhs) \ 284 { name result = lhs; result -= rhs; return (result); } \ 285 inline const name operator- (const float& scalar, const name& p) \ 286 { name result = p; result -= scalar; return (result); } \ 287 inline const name operator- (const name& p, const float& scalar) \ 288 { name result = p; result -= scalar; return (result); } \ 290 operator*= (name& p, const float& scalar) \ 292 BOOST_PP_SEQ_FOR_EACH(PCL_MULEQSC_POINT_TAG, _, seq) \ 295 inline const name operator* (const float& scalar, const name& p) \ 296 { name result = p; result *= scalar; return (result); } \ 297 inline const name operator* (const name& p, const float& scalar) \ 298 { name result = p; result *= scalar; return (result); } \ 300 operator/= (name& p, const float& scalar) \ 302 BOOST_PP_SEQ_FOR_EACH(PCL_DIVEQSC_POINT_TAG, _, seq) \ 305 inline const name operator/ (const float& scalar, const name& p) \ 306 { name result = p; result /= scalar; return (result); } \ 307 inline const name operator/ (const name& p, const float& scalar) \ 308 { name result = p; result /= scalar; return (result); } \ 313 #define POINT_CLOUD_REGISTER_FIELD_TAG(r, name, elem) \ 314 struct BOOST_PP_TUPLE_ELEM(3, 2, elem); \ 317 #define POINT_CLOUD_REGISTER_FIELD_NAME(r, point, elem) \ 318 template<int dummy> \ 319 struct name<point, pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem), dummy> \ 321 static const char value[]; \ 324 template<int dummy> \ 325 const char name<point, \ 326 pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem), \ 328 BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(3, 2, elem)); \ 331 #define POINT_CLOUD_REGISTER_FIELD_OFFSET(r, name, elem) \ 332 template<> struct offset<name, pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)> \ 334 static const size_t value = offsetof(name, BOOST_PP_TUPLE_ELEM(3, 1, elem)); \ 342 #define POINT_CLOUD_REGISTER_FIELD_DATATYPE(r, name, elem) \ 343 template<> struct datatype<name, pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem)> \ 345 typedef boost::mpl::identity<BOOST_PP_TUPLE_ELEM(3, 0, elem)>::type type; \ 346 typedef decomposeArray<type> decomposed; \ 347 static const uint8_t value = asEnum<decomposed::type>::value; \ 348 static const uint32_t size = decomposed::value; \ 352 #define POINT_CLOUD_TAG_OP(s, data, elem) pcl::fields::BOOST_PP_TUPLE_ELEM(3, 2, elem) 354 #define POINT_CLOUD_EXTRACT_TAGS(seq) BOOST_PP_SEQ_TRANSFORM(POINT_CLOUD_TAG_OP, _, seq) 356 #define POINT_CLOUD_REGISTER_POINT_FIELD_LIST(name, seq) \ 357 template<> struct fieldList<name> \ 359 typedef boost::mpl::vector<BOOST_PP_SEQ_ENUM(seq)> type; \ 364 #pragma warning (pop) 367 #endif //#ifndef PCL_REGISTER_POINT_STRUCT_H_ boost::disable_if_c< boost::is_array< T >::value >::type plus(T &l, const T &r)
boost::disable_if_c< boost::is_array< T1 >::value >::type mulscalar(T1 &p, const T2 &scalar)
boost::disable_if_c< boost::is_array< T1 >::value >::type divscalar(T1 &p, const T2 &scalar)
boost::disable_if_c< boost::is_array< T1 >::value >::type minusscalar(T1 &p, const T2 &scalar)
boost::disable_if_c< boost::is_array< T >::value >::type minus(T &l, const T &r)
boost::disable_if_c< boost::is_array< T1 >::value >::type plusscalar(T1 &p, const T2 &scalar)