1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/* Class:       CubitDefines 
 * Description: CubitDefines class - all global definitions for CUBIT.
 * Owner:       Tim Tautges
 * Checked by:
 * Version: $Id: 
 */

#ifndef CUBITOBJECT_HPP
#define CUBITOBJECT_HPP

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <sys/types.h>
#include <assert.h>
#include "CGMUtilConfigure.h"

// platform defines we can use in Cubit
#if defined(_WIN32) && !defined(NT)
# define NT
#endif

#if defined(__APPLE__) && !defined(MACOSX)
# define MACOSX
#endif

#if defined(__linux__) && !defined(CUBIT_LINUX)
# define CUBIT_LINUX
#endif

#ifdef _MSC_VER
#pragma warning ( 4 : 4291 4244 4305 4018 4786)
#pragma warning(error : 4239)
#endif
/* Adds DBL_MIN, DBL_MAX definitions on some platforms*/
#include <float.h> 

/* sanity check defines (these ARE needed!) */

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifndef NULL
#define NULL 0
#endif

/* typedef for integers and flags of just a few bits.
 * Usage: "Bit isMarked : 1;" where 1 is bit width of isMarked.
 * If there are just a few small flags in a class, cBit and IttyBit might
 * save some space; the length of int and short are machine dependent,
 * but char is as short as possible on all platforms.
 */
typedef unsigned int Bit;
typedef unsigned short IttyBit;
typedef unsigned char cBit;

static int const INVALID_ENTITY_ID = -1 ;

/* Boolean flags. */
#ifdef __cplusplus
  typedef bool CubitBoolean;
  const bool CUBIT_TRUE = true;
  const bool CUBIT_FALSE = false;
#else
  typedef char CubitBoolean;
  #define CUBIT_TRUE 1;
  #define CUBIT_FALSE 0;
#endif

/* Completion status */
enum CubitStatus { CUBIT_FAILURE = 0, CUBIT_SUCCESS = 1 } ;

/* Flags that indicate the Forward and Reversed senses. */
enum CubitSense {CUBIT_UNKNOWN = -1, CUBIT_FORWARD = 0, CUBIT_REVERSED = 1};

/* Flags to indicate whether a point is outside or off of an entity, inside 
   or on an entity, or on the boundary of an entity.  Defined so that calling 
   code can do true/false checks if it doesn't care if point is inside or on 
   the boundary. */
enum CubitPointContainment {CUBIT_PNT_UNKNOWN = -1, CUBIT_PNT_OUTSIDE = 0, 
                            CUBIT_PNT_OFF = 0, CUBIT_PNT_INSIDE = 1, 
                            CUBIT_PNT_ON = 1, CUBIT_PNT_BOUNDARY = 2};

enum FirmnessType {LIMP, SOFT, FIRM, HARD};
/* Firmness continuum - how bad does the user want something? 
   LIMP - default setting--i.e. "don't care" or "unset"
   SOFT - determined by basic geometric criteria--"about right" or "automatically set"
   FIRM - determined by advanced heuristic data, including adjacent environmental data
   HARD - user set--"must be this way"
*/
enum SizeIntervalType{ NOT_SET=LIMP,CALCULATED=SOFT,USER_SET=HARD};

/* Relationships between types of objects in the Entity Relationship
 * Diagram */
enum CubitEntityRelation 
{ 
    CUBIT_RELATION_NONE = -1, 
    CUBIT_RELATION_PARENT = 0, 
    CUBIT_RELATION_CHILD = 1 
} ;

/* Flag types for associativity data stored out and read back from
 * ExodusII files */
enum CubitAssocDataType 
{ 
   CUBIT_ASSOC_NULL = 0, 
   CUBIT_ASSOC_GEOM_REFENTITY = 1, 
   CUBIT_ASSOC_BC_BLOCK = 2, 
   CUBIT_ASSOC_BC_NSET = 3, 
   CUBIT_ASSOC_BC_SSET = 4 
} ;

enum ObserverType {
    MODEL_OBSERVER,
      /* big brother observer */

    DRAWING_OBSERVER,
      /* any observer concerned with drawing */

    GUI_OBSERVER
      /* a gui-type observer */
};

/* CSG operations for facetbool */
enum CubitFacetboolOp
{
   CUBIT_FB_UNION,
   CUBIT_FB_INTERSECTION,
   CUBIT_FB_SUBTRACTION
};

/* #define's for the entire CUBIT system */

#ifdef __cplusplus
#ifdef M_PI
const double CUBIT_PI           =              M_PI;<--- Skipping configuration 'M_PI' since the value of 'M_PI' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#else
const double CUBIT_PI           =              3.1415926535897932384626;
#endif
#else
#ifdef M_PI
#define CUBIT_PI         M_PI
#else
#define CUBIT_PI         3.1415926535897932384626
#endif
#endif
#define DEGREES_TO_RADIANS(angle) ( (angle) / 180.0 * CUBIT_PI )
#define RADIANS_TO_DEGREES(angle) ( 180.0 * (angle) / CUBIT_PI )
#ifdef __cplusplus
#ifdef INT_MAX
const int CUBIT_INT_MAX = INT_MAX;<--- Skipping configuration 'INT_MAX' since the value of 'INT_MAX' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#else
const int CUBIT_INT_MAX = 2147483647;
const int INT_MAX = CUBIT_INT_MAX;
#endif
#else
#ifdef INT_MAX
#define CUBIT_INT_MAX INT_MAX
#else
#define CUBIT_INT_MAX 2147483647
#define INT_MAX CUBIT_INT_MAX
#endif
#endif

#ifdef __cplusplus
#ifdef INT_MIN
const int CUBIT_INT_MIN = INT_MIN;<--- Skipping configuration 'INT_MIN' since the value of 'INT_MIN' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#else
const int CUBIT_INT_MIN = -2147483647;
const int INT_MIN = CUBIT_INT_MIN;
#endif
#else
#ifdef INT_MIN
#define CUBIT_INT_MIN INT_MIN
#else
#define CUBIT_INT_MIN -2147483647
#define INT_MIN CUBIT_INT_MIN
#endif
#endif

#ifdef __cplusplus
#ifdef DBL_MIN
const double CUBIT_DBL_MIN      =              DBL_MIN;<--- Skipping configuration 'DBL_MIN' since the value of 'DBL_MIN' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#else
const double CUBIT_DBL_MIN      =              1.0E-30;
#endif
#else
#ifdef DBL_MIN
#define CUBIT_DBL_MIN           DBL_MIN
#else
#define CUBIT_DBL_MIN           1.0E-30
#endif
#endif

#ifdef __cplusplus
#ifdef DBL_MAX
const double CUBIT_DBL_MAX      =              DBL_MAX;<--- Skipping configuration 'DBL_MAX' since the value of 'DBL_MAX' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
#else
const double CUBIT_DBL_MAX      =              1.0E30;
#endif 
#else
#ifdef DBL_MAX
#define CUBIT_DBL_MAX           DBL_MAX
#else
#define CUBIT_DBL_MAX           1.0E30
#endif 
#endif

#define CUBIT_MIN(a,b)                   ( (a) < (b) ? (a) : (b) )
#define CUBIT_MAX(a,b)                   ( (a) > (b) ? (a) : (b) )

#define CUBIT_MIN_4(a,b,c,d)             (( (a) < (b) ? (a) : (b) ) < \
                                          ( (c) < (d) ? (c) : (d) ) ? \
                                          ( (a) < (b) ? (a) : (b) ) : \
                                          ( (c) < (d) ? (c) : (d) ))

#define CUBIT_MAX_4(a,b,c,d)             (( (a) > (b) ? (a) : (b) ) > \
                                          ( (c) > (d) ? (c) : (d) ) ? \
                                          ( (a) > (b) ? (a) : (b) ) : \
                                          ( (c) > (d) ? (c) : (d) ))


  

/* Operators on enum types */
#if 0 /* Does not work on broken Microsoft compiler */
#ifdef __cplusplus

  /* Logical Operators for CubitBoolean type */
  
  inline CubitBoolean operator!( const CubitBoolean b )
  { return (CubitBoolean)(!(bool)b); }

  inline CubitBoolean operator&&( const CubitBoolean a, const CubitBoolean b )
  { return (CubitBoolean)((bool)a && (bool)b); }

  inline CubitBoolean operator||( const CubitBoolean a, const CubitBoolean b )
  { return (CubitBoolean)((bool)a || (bool)b); }


  /* Logical Operators for CubitStatus type */

  inline CubitStatus operator!( const CubitStatus b )
  { return (CubitStatus)(!(bool)b); }

  inline CubitStatus operator&&( const CubitStatus a, const CubitStatus b )
  { return (CubitStatus)((bool)a && (bool)b); }

  inline CubitStatus operator||( const CubitStatus a, const CubitStatus b )
  { return (CubitStatus)((bool)a || (bool)b); }


  /* Arithmatic Operators for CubitSense type */

  inline CubitSense operator-( const CubitSense s )
  { return (s == CUBIT_UNKNOWN) ? CUBIT_UNKNOWN : (CubitSense)(1 - s); }

  inline CubitSense operator*( const CubitSense a, const CubitSense b )
  { return (( a == CUBIT_UNKNOWN ) || ( b == CUBIT_UNKNOWN )) ? 
      CUBIT_UNKNOWN : ( a == b ) ? CUBIT_FORWARD : CUBIT_REVERSED; }

  inline CubitSense operator*=( CubitSense& a, const CubitSense b )
  { return a = a * b; }

#endif
#endif

#endif