41 #include <boost/cstdint.hpp>
49 using boost::uint16_t;
51 using boost::uint32_t;
53 using boost::uint64_t;
56 #if defined __INTEL_COMPILER
57 #pragma warning disable 2196 2536 279
61 #pragma warning (disable: 4521 4251)
67 #define _USE_MATH_DEFINES
71 #if defined _WIN32 && defined _MSC_VER
76 # define M_PI 3.14159265358979323846 // pi
77 # define M_PI_2 1.57079632679489661923 // pi/2
78 # define M_PI_4 0.78539816339744830962 // pi/4
79 # define M_PIl 3.1415926535897932384626433832795029L // pi
80 # define M_PI_2l 1.5707963267948966192313216916397514L // pi/2
81 # define M_PI_4l 0.7853981633974483096156608458198757L // pi/4
89 # define pcl_isnan(x) _isnan(x)
90 # define pcl_isfinite(x) (_finite(x) != 0)
91 # define pcl_isinf(x) (_finite(x) == 0)
93 # define __PRETTY_FUNCTION__ __FUNCTION__
94 # define __func__ __FUNCTION__
99 # define pcl_isnan(x) isnan(x)
100 # define pcl_isfinite(x) isfinite(x)
101 # define pcl_isinf(x) isinf(x)
103 #elif _GLIBCXX_USE_C99_MATH
106 # define pcl_isnan(x) std::isnan(x)
107 # define pcl_isfinite(x) std::isfinite(x)
108 # define pcl_isinf(x) std::isinf(x)
113 template <
typename T>
int
119 # define pcl_isfinite(x) std::isfinite(x)
120 # define pcl_isinf(x) std::isinf(x)
125 # define pcl_isnan(x) isnan(x)
126 # define pcl_isfinite(x) isfinite(x)
127 # define pcl_isinf(x) isinf(x)
132 #define DEG2RAD(x) ((x)*0.017453293)
136 #define RAD2DEG(x) ((x)*57.29578)
146 return (number < 0.0 ? ceil (number - 0.5) : floor (number + 0.5));
151 return (number < 0.0f ? ceilf (number - 0.5f) : floorf (number + 0.5f));
154 #define pcl_lrint(x) (static_cast<long int>(pcl_round(x)))
155 #define pcl_lrintf(x) (static_cast<long int>(pcl_round(x)))
161 return (static_cast<float> (logf (x) * M_LOG2E));
166 #define pcl_sleep(x) Sleep(1000*(x))
168 #define pcl_sleep(x) sleep(x)
173 #s << " = " << (s) << std::flush
177 #s << " = " << (s) << "\n"
181 #s << " = " << (s) << ", " << std::flush
185 #s << " = " << (s) << " " << std::flush
189 #s << " = " << RAD2DEG(s) << "deg" << std::flush
193 #s << " = " << RAD2DEG(s) << "deg\n"
197 #s << " = " << RAD2DEG(s) << "deg, " << std::flush
201 #s << " = " << RAD2DEG(s) << "deg " << std::flush
205 std::fixed << s << std::resetiosflags(std::ios_base::fixed)
208 #define ERASE_STRUCT(var) memset(&var, 0, sizeof(var))
212 #define ERASE_ARRAY(var, size) memset(var, 0, size*sizeof(*var))
216 #define SET_ARRAY(var, value, size) { for (int i = 0; i < static_cast<int> (size); ++i) var[i]=value; }
247 #define PCL_EXTERN_C extern "C"
253 #if defined WIN32 || defined _WIN32 || defined WINCE || defined __MINGW32__
254 #ifdef PCLAPI_EXPORTS
255 #define PCL_EXPORTS __declspec(dllexport)
263 #if defined WIN32 || defined _WIN32
264 #define PCL_CDECL __cdecl
265 #define PCL_STDCALL __stdcall
272 #define PCLAPI(rettype) PCL_EXTERN_C PCL_EXPORTS rettype PCL_CDECL
285 #define GCC_VERSION (__GNUC__ * 10000 \
286 + __GNUC_MINOR__ * 100 \
287 + __GNUC_PATCHLEVEL__)
288 #if GCC_VERSION < 40500
289 #define PCL_DEPRECATED(func, message) func __attribute__ ((deprecated))
291 #define PCL_DEPRECATED(func, message) func __attribute__ ((deprecated(message)))
294 #elif defined(_MSC_VER)
295 #define PCL_DEPRECATED(func, message) __declspec(deprecated(message)) func
297 #pragma message("WARNING: You need to implement PCL_DEPRECATED for this compiler")
298 #define PCL_DEPRECATED(func) func
319 #define GCC_VERSION (__GNUC__ * 10000 \
320 + __GNUC_MINOR__ * 100 \
321 + __GNUC_PATCHLEVEL__)
322 #if GCC_VERSION < 40500
323 #define PCL_DEPRECATED_CLASS(func, message) __attribute__ ((deprecated)) func
325 #define PCL_DEPRECATED_CLASS(func, message) __attribute__ ((deprecated(message))) func
328 #elif defined(_MSC_VER)
329 #define PCL_DEPRECATED_CLASS(func, message) __declspec(deprecated(message)) func
331 #pragma message("WARNING: You need to implement PCL_DEPRECATED for this compiler")
332 #define PCL_DEPRECATED_CLASS(func) func
335 #if defined (__GNUC__) || defined (__PGI) || defined (__IBMCPP__) || defined (__SUNPRO_CC)
336 #define PCL_ALIGN(alignment) __attribute__((aligned(alignment)))
337 #elif defined (_MSC_VER)
338 #define PCL_ALIGN(alignment) __declspec(align(alignment))
340 #error Alignment not supported on your platform
343 #if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \
345 #define GLIBC_MALLOC_ALIGNED 1
347 #define GLIBC_MALLOC_ALIGNED 0
350 #if defined(__FreeBSD__) && !defined(__arm__) && !defined(__mips__)
351 #define FREEBSD_MALLOC_ALIGNED 1
353 #define FREEBSD_MALLOC_ALIGNED 0
356 #if defined(__APPLE__) || defined(_WIN64) || GLIBC_MALLOC_ALIGNED || FREEBSD_MALLOC_ALIGNED
357 #define MALLOC_ALIGNED 1
359 #define MALLOC_ALIGNED 0
366 #if defined (MALLOC_ALIGNED)
367 ptr = std::malloc (size);
368 #elif defined (HAVE_POSIX_MEMALIGN)
369 if (posix_memalign (&ptr, 16, size))
371 #elif defined (HAVE_MM_MALLOC)
372 ptr = _mm_malloc (size, 16);
373 #elif defined (_MSC_VER)
374 ptr = _aligned_malloc (size, 16);
376 #error aligned_malloc not supported on your platform
385 #if defined (MALLOC_ALIGNED) || defined (HAVE_POSIX_MEMALIGN)
387 #elif defined (HAVE_MM_MALLOC)
388 ptr = _mm_free (ptr);
389 #elif defined (_MSC_VER)
392 #error aligned_free not supported on your platform
396 #endif //#ifndef PCL_MACROS_H_