Coin Logo http://www.sim.no
http://www.coin3d.org

Basic.h

00001 /**************************************************************************\
00002  * 
00003  *  FILE: Basic.h
00004  *
00005  *  This source file is part of DIME.
00006  *  Copyright (C) 1998-1999 by Systems In Motion.  All rights reserved.
00007  *
00008  *  This library is free software; you can redistribute it and/or modify it
00009  *  under the terms of the GNU General Public License, version 2, as
00010  *  published by the Free Software Foundation.
00011  *
00012  *  This library is distributed in the hope that it will be useful, but
00013  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  General Public License (the accompanying file named COPYING) for more
00016  *  details.
00017  *
00018  **************************************************************************
00019  *
00020  *  If you need DIME for a non-GPL project, contact Systems In Motion
00021  *  to acquire a Professional Edition License:
00022  *
00023  *  Systems In Motion                                   http://www.sim.no/
00024  *  Prof. Brochs gate 6                                       sales@sim.no
00025  *  N-7030 Trondheim                                   Voice: +47 22114160
00026  *  NORWAY                                               Fax: +47 67172912
00027  *
00028 \**************************************************************************/
00029 
00030 #ifndef DIME_BASIC_H
00031 #define DIME_BASIC_H
00032 
00033 #include <stdlib.h>
00034 #include <stdio.h>
00035 #include <stdarg.h>
00036 #include <string.h>
00037 #include <assert.h>
00038 #include <math.h>
00039 
00040 // we prefer to use floats to save mem. Applications needing
00041 // scientific calculations should typedef this to double
00042 typedef float dxfdouble;
00043 // typedef double dxfdouble;
00044 
00045 #include <float.h>
00046 
00047 #ifndef M_PI
00048 #define M_PI 3.14159265358979323846
00049 #endif // !M_PI
00050 
00051 #define DXFABS(x) ((x)<0?-(x):(x))
00052 #define DXFMAX(x,y) ((x)>(y)?(x):(y))
00053 #define DXFMIN(x,y) ((x)<(y)?(x):(y))
00054 #define DXFDEG2RAD(x) (M_PI*(x)/180.0)
00055 #define DXFRAD2DEG(x) (180.0*(x)/M_PI)
00056 
00057 
00058 #ifdef __sgi
00059 #define bool int
00060 #define true 1
00061 #define false 0
00062 #endif // __sgi
00063 
00064 
00065 template <class T> inline
00066 T DXFSQR(const T x)
00067 {
00068   return x*x;
00069 }
00070 
00071 #if defined(__BEOS__)
00072 #include <support/SupportDefs.h>
00073 #else // ! defined(__BEOS__)
00074 typedef signed char int8;
00075 typedef unsigned char uint8;
00076 typedef signed short int16;
00077 typedef unsigned short uint16;
00078 #ifdef _WIN32
00079 typedef long int32;
00080 #else // ! defined(_WIN32)
00081 typedef signed int int32;
00082 #endif // ! defined(_WIN32)
00083 typedef unsigned int uint32;
00084 #endif // ! defined(__BEOS__)
00085 
00086 #ifdef macintosh
00087  char* strdup( const char* );
00088 #endif
00089  
00090 #define ARRAY_NEW(memh, type, num) \
00091 memh ? (type*) memh->allocMem((num)*sizeof(type)) : new type[num]
00092 
00093 #define DXF_STRCPY(mh, d, s) \
00094 mh ? d = mh->stringAlloc(s) : d = new char[strlen(s)+1]; if (d) strcpy(d,s)
00095 
00096 typedef bool dimeCallbackFunc(const class dimeState * const, class dimeEntity *, void *);
00097 typedef dimeCallbackFunc * dimeCallback;
00098 
00099 typedef union {
00100   int8  int8_data;
00101   int16 int16_data;
00102   int32 int32_data;
00103   float float_data;
00104   dxfdouble double_data;
00105   const char *string_data;
00106   const char *hex_data;
00107 } dimeParam;
00108 
00109 /* ********************************************************************** */
00110 /* Precaution to avoid an some errors easily made by the application
00111    programmer. */
00112 
00113 #ifdef DIME_DLL_API
00114 # error Leave the internal DIME_DLL_API define alone.
00115 #endif /* DIME_DLL_API */
00116 #ifdef DIME_INTERNAL
00117 # ifdef DIME_NOT_DLL
00118 #  error The DIME_NOT_DLL define is not supposed to be used when building the library, only when building Win32 applications.
00119 # endif /* DIME_INTERNAL && DIME_NOT_DLL */
00120 # ifdef DIME_DLL
00121 #  error The DIME_DLL define is not supposed to be used when building the library, only when building Win32 applications.
00122 # endif /* DIME_INTERNAL && DIME_DLL */
00123 #endif /* DIME_INTERNAL */
00124 
00125 /*
00126   On MSWindows platforms, one of these defines must always be set when
00127   building application programs:
00128 
00129    - "DIME_DLL", when the application programmer is using the library
00130      in the form of a dynamic link library (DLL)
00131 
00132    - "DIME_NOT_DLL", when the application programmer is using the
00133      library in the form of a static object library (LIB)
00134 
00135   Note that either DIME_DLL or DIME_NOT_DLL _must_ be defined by the
00136   application programmer on MSWindows platforms, or else the #error
00137   statement will hit. Set up one or the other of these two defines in
00138   your compiler environment according to how the library was built --
00139   as a DLL (use "DIME_DLL") or as a LIB (use "DIME_NOT_DLL").
00140 
00141   (Setting up defines for the compiler is typically done by either
00142   adding something like "/DDIME_DLL" to the compiler's argument line
00143   (for command-line build processes), or by adding the define to the
00144   list of preprocessor symbols in your IDE GUI (in the MSVC IDE, this
00145   is done from the "Project"->"Settings" menu, choose the "C/C++" tab,
00146   then "Preprocessor" from the dropdown box and add the appropriate
00147   define)).
00148 
00149   It is extremely important that the application programmer uses the
00150   correct define, as using "DIME_NOT_DLL" when "DIME_DLL" is correct
00151   will cause mysterious crashes.
00152  */
00153 /* FIXME: use a feature check to see if this is a platform which can
00154    recognize the __declspec keyword instead of the crap #if below.
00155    20011201 mortene. */
00156 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
00157 # ifdef DIME_INTERNAL
00158 #  ifdef DIME_MAKE_DLL
00159 #   define DIME_DLL_API __declspec(dllexport)
00160 #  endif /* DIME_MAKE_DLL */
00161 # else /* !DIME_INTERNAL */
00162 #  ifdef DIME_DLL
00163 #   ifdef DIME_NOT_DLL
00164 #    error Do not define both DIME_DLL and DIME_NOT_DLL at the same time
00165 #   endif
00166 #   define DIME_DLL_API __declspec(dllimport)
00167 #  else /* !DIME_DLL */
00168 #   ifndef DIME_NOT_DLL
00169 #    error Define either DIME_DLL or DIME_NOT_DLL as appropriate for your linkage! See dime/Basic.h for further instructions.
00170 #   endif /* DIME_NOT_DLL */
00171 #  endif /* !DIME_DLL */
00172 # endif /* !DIME_INTERNAL */
00173 #endif /* Microsoft Windows */
00174 
00175 /* Empty define to avoid errors when _not_ compiling an MSWindows DLL. */
00176 #ifndef DIME_DLL_API
00177 # define DIME_DLL_API
00178 #endif /* !DIME_DLL_API */
00179 
00180 int DIME_DLL_API dime_isnan(double value);
00181 int DIME_DLL_API dime_isinf(double value);
00182 int DIME_DLL_API dime_finite(double value);
00183 
00184 /* ********************************************************************** */
00185 
00186 #endif // !DIME_BASIC_H

Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.

Generated on Tue Dec 2 23:27:14 2008 for DIME by Doxygen. 1.4.7