You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
4.4 KiB
C++

#ifndef _DECLSPEC_H_
#define _DECLSPEC_H_
#include <stdint.h>
#include <cmath>
#include <stdio.h> /* printf */
#include <math.h> /* isnan, sqrt*/
#include <float.h>
#include <QVector>
#include <QList>
/*
#ifdef MLCORE_EXPORTS
# define LIBSPEC __declspec(dllexport)
#else
# define LIBSPEC __declspec(dllimport)
#endif
By default, we use the standard "extern" declarations.
#define MLCORE_EXPORT LIBSPEC*/
#ifdef _WIN64
//typedef __int64 MLLONG; /* A signed 8-byte integer under 64-bit Windows */
typedef size_t MLLONG; /* A signed 8-byte integer under 64-bit Windows */
#else
typedef long MLLONG; /* A signed 4 (or 8-byte for 64-bit) integer */
#endif
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y)) /* min and max value macros */
#endif
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef MOD /* Knuth-style modulo function (remainder after floored division) */
#define MOD(x, y) (x - y * floor((double)(x)/(double)(y)))
#endif
#ifndef ABS
#define ABS(a) ((a)>0?(a):(-(a)))
#endif
#ifndef MAX_STRLEN
#define MAX_STRLEN 512
#endif
#ifndef RMAXDOUBLE
#define RMAXDOUBLE 1e300
#endif
#ifndef RMINDOUBLE
#define RMINDOUBLE -1e300
#endif
#ifndef RNANDOUBLE
#define RNANDOUBLE std::numeric_limits<double>::quiet_NaN()
#endif
#ifndef RINFDOUBLE
#define RINFDOUBLE std::numeric_limits<double>::infinity()
#endif
#ifndef TOL
#define TOL 0.000001 // tolerance for comparisons
#endif
#ifndef FLOAT_ERROR
#define FLOAT_ERROR 0.00048F // 单精度浮点数误差
#endif
#ifndef DOUBLE_ERROR
#define DOUBLE_ERROR 0.000048 // 双精度浮点数误差(用于比较)
#endif
#ifndef DBL_ERROR
#define DBL_ERROR 0.000000048 // 双精度浮点数误差(用于计算)
#endif
#define MIN_VALUE 1E-5
#define MIN_DISTANCE 0.001f
#define MIN_AREA 0.000001f
#define MAGNETIC_DIST 0.003f
#ifndef PI
#define PI 3.14159265358979323846
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
#ifndef SIGN
#define SIGN(a) ((a)>0?1:-1)
#endif
#ifndef FILEBLOCK
#define FILEBLOCK 2*1024*1024
#endif
#ifndef ARC
#define ARC 180.0/3.141592654
#endif
#ifndef RHO
#define RHO (180.0/3.141592654)
#endif
#ifndef TT_
#define TT_ 2.0/3.0
#endif
#ifndef OS
#define OS 1.0/6.0
#endif
#define TEXT_TJ_BOTTOMLEFT 1
#define TEXT_TJ_BOTTOMCENTER 2
#define TEXT_TJ_BOTTOMRIGHT 3
#define TEXT_TJ_MIDDLELEFT 4
#define TEXT_TJ_MIDDLECENTER 5
#define TEXT_TJ_MIDDLERIGHT 6
#define TEXT_TJ_TOPLEFT 7
#define TEXT_TJ_TOPCENTER 8
#define TEXT_TJ_TOPRIGHT 9
#ifndef NAN
# ifdef _MSC_VER
# include <ymath.h>
# define NAN _Nan._Double
# else /* _MSC_VER */
static const double _NAN = (HUGE_VAL-HUGE_VAL);
# define NAN _NAN
# endif /* _MSC_VER */
#endif /* !NAN */
#ifndef isinf
#define isinf(x) \
( sizeof (x) == sizeof (float) ? __inline_isinf_f (x) \
: sizeof (x) == sizeof (double) ? __inline_isinf_d (x) \
: __inline_isinf (x))
static inline int __inline_isinf_f (float x)
{
return !_isnan (x) && _isnan (x - x);
}
static inline int __inline_isinf_d (double x)
{
return !_isnan (x) && _isnan (x - x);
}
static inline int __inline_isinf (long double x)
{
return !_isnan (x) && _isnan (x - x);
}
#endif /* !isinf */
#ifndef isfinite
# define isfinite(x) (!isinf(x) && !_isnan(x))
#endif
#ifndef isnormal
# define isnormal(x) \
( sizeof (x) == sizeof (float) ? __inline_isnormal_f (x) \
: sizeof (x) == sizeof (double) ? __inline_isnormal_d (x) \
: __inline_isnormal (x))
static inline int __inline_isnormal_f ( float x )
{
float abs_x = fabsf(x);
if ( x != x )
return 0;
return abs_x < HUGE_VAL && abs_x >= FLT_MIN;
}
static inline int __inline_isnormal_d ( double x )
{
double abs_x = fabs(x);
if ( x != x )
return 0;
return abs_x < HUGE_VAL && abs_x >= DBL_MIN;
}
static inline int __inline_isnormal ( long double x )
{
long double abs_x = fabsl(x);
if ( x != x )
return 0;
return abs_x < HUGE_VAL && abs_x >= LDBL_MIN;
}
#endif /* !isnormal */
typedef QVector<void*> QVoidAry;
typedef QVector<char> QCharAry;
typedef QVector<int> QIntAry;
typedef QVector<short> QShortAry;
typedef QVector<float> QFloatAry;
typedef QVector<double> QDoubleAry;
typedef QVector<long> QLongAry;
// typedef QVector<QPoint> QPointAry;
// typedef QVector<QRect> QRectAry;
#endif /* _DECLSPEC_H_ */