cgma
CubitDefines.h
Go to the documentation of this file.
00001 /* Class:       CubitDefines 
00002  * Description: CubitDefines class - all global definitions for CUBIT.
00003  * Owner:       Tim Tautges
00004  * Checked by:
00005  * Version: $Id: 
00006  */
00007 
00008 #ifndef CUBITOBJECT_HPP
00009 #define CUBITOBJECT_HPP
00010 
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <limits.h>
00014 #include <math.h>
00015 #include <sys/types.h>
00016 #include <assert.h>
00017 #include "CGMUtilConfigure.h"
00018 
00019 // platform defines we can use in Cubit
00020 #if defined(_WIN32) && !defined(NT)
00021 # define NT
00022 #endif
00023 
00024 #if defined(__APPLE__) && !defined(MACOSX)
00025 # define MACOSX
00026 #endif
00027 
00028 #if defined(__linux__) && !defined(CUBIT_LINUX)
00029 # define CUBIT_LINUX
00030 #endif
00031 
00032 #ifdef _MSC_VER
00033 #pragma warning ( 4 : 4291 4244 4305 4018 4786)
00034 #pragma warning(error : 4239)
00035 #endif
00036 /* Adds DBL_MIN, DBL_MAX definitions on some platforms*/
00037 #include <float.h> 
00038 
00039 /* sanity check defines (these ARE needed!) */
00040 
00041 #ifndef TRUE
00042 #define TRUE 1
00043 #endif
00044 
00045 #ifndef FALSE
00046 #define FALSE 0
00047 #endif
00048 
00049 #ifndef NULL
00050 #define NULL 0
00051 #endif
00052 
00053 /* typedef for integers and flags of just a few bits.
00054  * Usage: "Bit isMarked : 1;" where 1 is bit width of isMarked.
00055  * If there are just a few small flags in a class, cBit and IttyBit might
00056  * save some space; the length of int and short are machine dependent,
00057  * but char is as short as possible on all platforms.
00058  */
00059 typedef unsigned int Bit;
00060 typedef unsigned short IttyBit;
00061 typedef unsigned char cBit;
00062 
00063 static int const INVALID_ENTITY_ID = -1 ;
00064 
00065 /* Boolean flags. */
00066 #ifdef __cplusplus
00067   typedef bool CubitBoolean;
00068   const bool CUBIT_TRUE = true;
00069   const bool CUBIT_FALSE = false;
00070 #else
00071   typedef char CubitBoolean;
00072   #define CUBIT_TRUE 1;
00073   #define CUBIT_FALSE 0;
00074 #endif
00075 
00076 /* Completion status */
00077 enum CubitStatus { CUBIT_FAILURE = 0, CUBIT_SUCCESS = 1 } ;
00078 
00079 /* Flags that indicate the Forward and Reversed senses. */
00080 enum CubitSense {CUBIT_UNKNOWN = -1, CUBIT_FORWARD = 0, CUBIT_REVERSED = 1};
00081 
00082 /* Flags to indicate whether a point is outside or off of an entity, inside 
00083    or on an entity, or on the boundary of an entity.  Defined so that calling 
00084    code can do true/false checks if it doesn't care if point is inside or on 
00085    the boundary. */
00086 enum CubitPointContainment {CUBIT_PNT_UNKNOWN = -1, CUBIT_PNT_OUTSIDE = 0, 
00087                             CUBIT_PNT_OFF = 0, CUBIT_PNT_INSIDE = 1, 
00088                             CUBIT_PNT_ON = 1, CUBIT_PNT_BOUNDARY = 2};
00089 
00090 enum FirmnessType {LIMP, SOFT, FIRM, HARD};
00091 /* Firmness continuum - how bad does the user want something? 
00092    LIMP - default setting--i.e. "don't care" or "unset"
00093    SOFT - determined by basic geometric criteria--"about right" or "automatically set"
00094    FIRM - determined by advanced heuristic data, including adjacent environmental data
00095    HARD - user set--"must be this way"
00096 */
00097 enum SizeIntervalType{ NOT_SET=LIMP,CALCULATED=SOFT,USER_SET=HARD};
00098 
00099 /* Relationships between types of objects in the Entity Relationship
00100  * Diagram */
00101 enum CubitEntityRelation 
00102 { 
00103     CUBIT_RELATION_NONE = -1, 
00104     CUBIT_RELATION_PARENT = 0, 
00105     CUBIT_RELATION_CHILD = 1 
00106 } ;
00107 
00108 /* Flag types for associativity data stored out and read back from
00109  * ExodusII files */
00110 enum CubitAssocDataType 
00111 { 
00112    CUBIT_ASSOC_NULL = 0, 
00113    CUBIT_ASSOC_GEOM_REFENTITY = 1, 
00114    CUBIT_ASSOC_BC_BLOCK = 2, 
00115    CUBIT_ASSOC_BC_NSET = 3, 
00116    CUBIT_ASSOC_BC_SSET = 4 
00117 } ;
00118 
00119 enum ObserverType {
00120     MODEL_OBSERVER,
00121       /* big brother observer */
00122 
00123     DRAWING_OBSERVER,
00124       /* any observer concerned with drawing */
00125 
00126     GUI_OBSERVER
00127       /* a gui-type observer */
00128 };
00129 
00130 /* CSG operations for facetbool */
00131 enum CubitFacetboolOp
00132 {
00133    CUBIT_FB_UNION,
00134    CUBIT_FB_INTERSECTION,
00135    CUBIT_FB_SUBTRACTION
00136 };
00137 
00138 /* #define's for the entire CUBIT system */
00139 
00140 #ifdef __cplusplus
00141 #ifdef M_PI
00142 const double CUBIT_PI           =              M_PI;
00143 #else
00144 const double CUBIT_PI           =              3.1415926535897932384626;
00145 #endif
00146 #else
00147 #ifdef M_PI
00148 #define CUBIT_PI         M_PI
00149 #else
00150 #define CUBIT_PI         3.1415926535897932384626
00151 #endif
00152 #endif
00153 #define DEGREES_TO_RADIANS(angle) ( (angle) / 180.0 * CUBIT_PI )
00154 #define RADIANS_TO_DEGREES(angle) ( 180.0 * (angle) / CUBIT_PI )
00155 #ifdef __cplusplus
00156 #ifdef INT_MAX
00157 const int CUBIT_INT_MAX = INT_MAX;
00158 #else
00159 const int CUBIT_INT_MAX = 2147483647;
00160 const int INT_MAX = CUBIT_INT_MAX;
00161 #endif
00162 #else
00163 #ifdef INT_MAX
00164 #define CUBIT_INT_MAX INT_MAX
00165 #else
00166 #define CUBIT_INT_MAX 2147483647
00167 #define INT_MAX CUBIT_INT_MAX
00168 #endif
00169 #endif
00170 
00171 #ifdef __cplusplus
00172 #ifdef INT_MIN
00173 const int CUBIT_INT_MIN = INT_MIN;
00174 #else
00175 const int CUBIT_INT_MIN = -2147483647;
00176 const int INT_MIN = CUBIT_INT_MIN;
00177 #endif
00178 #else
00179 #ifdef INT_MIN
00180 #define CUBIT_INT_MIN INT_MIN
00181 #else
00182 #define CUBIT_INT_MIN -2147483647
00183 #define INT_MIN CUBIT_INT_MIN
00184 #endif
00185 #endif
00186 
00187 #ifdef __cplusplus
00188 #ifdef DBL_MIN
00189 const double CUBIT_DBL_MIN      =              DBL_MIN;
00190 #else
00191 const double CUBIT_DBL_MIN      =              1.0E-30;
00192 #endif
00193 #else
00194 #ifdef DBL_MIN
00195 #define CUBIT_DBL_MIN           DBL_MIN
00196 #else
00197 #define CUBIT_DBL_MIN           1.0E-30
00198 #endif
00199 #endif
00200 
00201 #ifdef __cplusplus
00202 #ifdef DBL_MAX
00203 const double CUBIT_DBL_MAX      =              DBL_MAX;
00204 #else
00205 const double CUBIT_DBL_MAX      =              1.0E30;
00206 #endif 
00207 #else
00208 #ifdef DBL_MAX
00209 #define CUBIT_DBL_MAX           DBL_MAX
00210 #else
00211 #define CUBIT_DBL_MAX           1.0E30
00212 #endif 
00213 #endif
00214 
00215 #define CUBIT_MIN(a,b)                   ( (a) < (b) ? (a) : (b) )
00216 #define CUBIT_MAX(a,b)                   ( (a) > (b) ? (a) : (b) )
00217 
00218 #define CUBIT_MIN_4(a,b,c,d)             (( (a) < (b) ? (a) : (b) ) < \
00219                                           ( (c) < (d) ? (c) : (d) ) ? \
00220                                           ( (a) < (b) ? (a) : (b) ) : \
00221                                           ( (c) < (d) ? (c) : (d) ))
00222 
00223 #define CUBIT_MAX_4(a,b,c,d)             (( (a) > (b) ? (a) : (b) ) > \
00224                                           ( (c) > (d) ? (c) : (d) ) ? \
00225                                           ( (a) > (b) ? (a) : (b) ) : \
00226                                           ( (c) > (d) ? (c) : (d) ))
00227 
00228 
00229   
00230 
00231 /* Operators on enum types */
00232 #if 0 /* Does not work on broken Microsoft compiler */
00233 #ifdef __cplusplus
00234 
00235   /* Logical Operators for CubitBoolean type */
00236   
00237   inline CubitBoolean operator!( const CubitBoolean b )
00238   { return (CubitBoolean)(!(bool)b); }
00239 
00240   inline CubitBoolean operator&&( const CubitBoolean a, const CubitBoolean b )
00241   { return (CubitBoolean)((bool)a && (bool)b); }
00242 
00243   inline CubitBoolean operator||( const CubitBoolean a, const CubitBoolean b )
00244   { return (CubitBoolean)((bool)a || (bool)b); }
00245 
00246 
00247   /* Logical Operators for CubitStatus type */
00248 
00249   inline CubitStatus operator!( const CubitStatus b )
00250   { return (CubitStatus)(!(bool)b); }
00251 
00252   inline CubitStatus operator&&( const CubitStatus a, const CubitStatus b )
00253   { return (CubitStatus)((bool)a && (bool)b); }
00254 
00255   inline CubitStatus operator||( const CubitStatus a, const CubitStatus b )
00256   { return (CubitStatus)((bool)a || (bool)b); }
00257 
00258 
00259   /* Arithmatic Operators for CubitSense type */
00260 
00261   inline CubitSense operator-( const CubitSense s )
00262   { return (s == CUBIT_UNKNOWN) ? CUBIT_UNKNOWN : (CubitSense)(1 - s); }
00263 
00264   inline CubitSense operator*( const CubitSense a, const CubitSense b )
00265   { return (( a == CUBIT_UNKNOWN ) || ( b == CUBIT_UNKNOWN )) ? 
00266       CUBIT_UNKNOWN : ( a == b ) ? CUBIT_FORWARD : CUBIT_REVERSED; }
00267 
00268   inline CubitSense operator*=( CubitSense& a, const CubitSense b )
00269   { return a = a * b; }
00270 
00271 #endif
00272 #endif
00273 
00274 #endif
00275 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines