40 #include <pcl/pcl_config.h>
41 #include <boost/cstdint.hpp>
49 using boost::uint16_t;
51 using boost::uint32_t;
53 using boost::uint64_t;
54 using boost::int_fast16_t;
57 #if defined __INTEL_COMPILER
58 #pragma warning disable 2196 2536 279
66 #pragma warning (disable: 4018 4244 4267 4521 4251 4661 4305 4503 4146)
72 #define _USE_MATH_DEFINES
76 #if defined _WIN32 && defined _MSC_VER
81 # define M_PI 3.14159265358979323846 // pi
82 # define M_PI_2 1.57079632679489661923 // pi/2
83 # define M_PI_4 0.78539816339744830962 // pi/4
84 # define M_PIl 3.1415926535897932384626433832795029L // pi
85 # define M_PI_2l 1.5707963267948966192313216916397514L // pi/2
86 # define M_PI_4l 0.7853981633974483096156608458198757L // pi/4
94 # define pcl_isnan(x) _isnan(x)
95 # define pcl_isfinite(x) (_finite(x) != 0)
96 # define pcl_isinf(x) (_finite(x) == 0)
98 # define __PRETTY_FUNCTION__ __FUNCTION__
99 # define __func__ __FUNCTION__
104 # define pcl_isnan(x) isnan(x)
105 # define pcl_isfinite(x) isfinite(x)
106 # define pcl_isinf(x) isinf(x)
108 #elif _GLIBCXX_USE_C99_MATH
111 # define pcl_isnan(x) std::isnan(x)
112 # define pcl_isfinite(x) std::isfinite(x)
113 # define pcl_isinf(x) std::isinf(x)
118 template <
typename T>
int
124 # define pcl_isfinite(x) std::isfinite(x)
125 # define pcl_isinf(x) std::isinf(x)
130 # define pcl_isnan(x) isnan(x)
131 # define pcl_isfinite(x) isfinite(x)
132 # define pcl_isinf(x) isinf(x)
137 #define DEG2RAD(x) ((x)*0.017453293)
141 #define RAD2DEG(x) ((x)*57.29578)
146 #define PCL_LINEAR_VERSION(major,minor,patch) ((major)<<16|(minor)<<8|(patch))
153 pcl_round (
double number)
155 return (number < 0.0 ? ceil (number - 0.5) : floor (number + 0.5));
158 pcl_round (
float number)
160 return (number < 0.0f ? ceilf (number - 0.5f) : floorf (number + 0.5f));
164 #define pcl_lrint(x) (lrint(static_cast<double> (x)))
165 #define pcl_lrintf(x) (lrintf(static_cast<float> (x)))
167 #define pcl_lrint(x) (static_cast<long int>(pcl_round(x)))
168 #define pcl_lrintf(x) (static_cast<long int>(pcl_round(x)))
176 return (static_cast<float> (logf (x) * M_LOG2E));
181 #define pcl_sleep(x) Sleep(1000*(x))
183 #define pcl_sleep(x) sleep(x)
188 #s << " = " << (s) << std::flush
192 #s << " = " << (s) << "\n"
196 #s << " = " << (s) << ", " << std::flush
200 #s << " = " << (s) << " " << std::flush
204 #s << " = " << RAD2DEG(s) << "deg" << std::flush
208 #s << " = " << RAD2DEG(s) << "deg\n"
212 #s << " = " << RAD2DEG(s) << "deg, " << std::flush
216 #s << " = " << RAD2DEG(s) << "deg " << std::flush
220 std::fixed << s << std::resetiosflags(std::ios_base::fixed)
223 #define ERASE_STRUCT(var) memset(&var, 0, sizeof(var))
227 #define ERASE_ARRAY(var, size) memset(var, 0, size*sizeof(*var))
231 #define SET_ARRAY(var, value, size) { for (int i = 0; i < static_cast<int> (size); ++i) var[i]=value; }
262 #define PCL_EXTERN_C extern "C"
268 #if defined WIN32 || defined _WIN32 || defined WINCE || defined __MINGW32__
269 #ifdef PCLAPI_EXPORTS
270 #define PCL_EXPORTS __declspec(dllexport)
278 #if defined WIN32 || defined _WIN32
279 #define PCL_CDECL __cdecl
280 #define PCL_STDCALL __stdcall
287 #define PCLAPI(rettype) PCL_EXTERN_C PCL_EXPORTS rettype PCL_CDECL
299 #ifndef __has_extension
300 #define __has_extension(x) 0 // Compatibility with pre-3.0 compilers.
303 #if (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) < PCL_LINEAR_VERSION(4,5,0) && ! defined(__clang__)) || defined(__INTEL_COMPILER)
304 #define PCL_DEPRECATED(func, message) func __attribute__ ((deprecated))
308 #if (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) >= PCL_LINEAR_VERSION(4,5,0)) || (defined(__clang__) && __has_extension(attribute_deprecated_with_message))
309 #define PCL_DEPRECATED(func, message) func __attribute__ ((deprecated(message)))
313 #define PCL_DEPRECATED(func, message) __declspec(deprecated(message)) func
316 #ifndef PCL_DEPRECATED
317 #pragma message("WARNING: You need to implement PCL_DEPRECATED for this compiler")
318 #define PCL_DEPRECATED(func) func
338 #if (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) < PCL_LINEAR_VERSION(4,5,0) && ! defined(__clang__)) || defined(__INTEL_COMPILER)
339 #define PCL_DEPRECATED_CLASS(func, message) __attribute__ ((deprecated)) func
343 #if (defined(__GNUC__) && PCL_LINEAR_VERSION(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) >= PCL_LINEAR_VERSION(4,5,0)) || (defined(__clang__) && __has_extension(attribute_deprecated_with_message))
344 #define PCL_DEPRECATED_CLASS(func, message) __attribute__ ((deprecated(message))) func
348 #define PCL_DEPRECATED_CLASS(func, message) __declspec(deprecated(message)) func
351 #ifndef PCL_DEPRECATED_CLASS
352 #pragma message("WARNING: You need to implement PCL_DEPRECATED_CLASS for this compiler")
353 #define PCL_DEPRECATED_CLASS(func) func
356 #if defined (__GNUC__) || defined (__PGI) || defined (__IBMCPP__) || defined (__SUNPRO_CC)
357 #define PCL_ALIGN(alignment) __attribute__((aligned(alignment)))
358 #elif defined (_MSC_VER)
359 #define PCL_ALIGN(alignment) __declspec(align(alignment))
361 #error Alignment not supported on your platform
364 #if defined(__GLIBC__) && PCL_LINEAR_VERSION(__GLIBC__,__GLIBC_MINOR__,0)>PCL_LINEAR_VERSION(2,8,0)
365 #define GLIBC_MALLOC_ALIGNED 1
367 #define GLIBC_MALLOC_ALIGNED 0
370 #if defined(__FreeBSD__) && !defined(__arm__) && !defined(__mips__)
371 #define FREEBSD_MALLOC_ALIGNED 1
373 #define FREEBSD_MALLOC_ALIGNED 0
376 #if defined(__APPLE__) || defined(_WIN64) || GLIBC_MALLOC_ALIGNED || FREEBSD_MALLOC_ALIGNED
377 #define MALLOC_ALIGNED 1
379 #define MALLOC_ALIGNED 0
383 aligned_malloc (
size_t size)
386 #if defined (MALLOC_ALIGNED)
387 ptr = std::malloc (size);
388 #elif defined (HAVE_POSIX_MEMALIGN)
389 if (posix_memalign (&ptr, 16, size))
391 #elif defined (HAVE_MM_MALLOC)
392 ptr = _mm_malloc (size, 16);
393 #elif defined (_MSC_VER)
394 ptr = _aligned_malloc (size, 16);
396 #error aligned_malloc not supported on your platform
403 aligned_free (
void* ptr)
405 #if defined (MALLOC_ALIGNED) || defined (HAVE_POSIX_MEMALIGN)
407 #elif defined (HAVE_MM_MALLOC)
408 ptr = _mm_free (ptr);
409 #elif defined (_MSC_VER)
412 #error aligned_free not supported on your platform
416 #endif //#ifndef PCL_MACROS_H_