Programmer's Reference for the BIC Volume IO Library | ||
---|---|---|
<<< Previous | Next >>> |
There are several types and macros defined for use with the BIC Volume IO Library. All function declarations in the library are preceded with either the word public or private, which indicates whether the function is accessible from outside the file in which it resides. Users of the library will only be interested in those functions preceded by public. They are defined as follows:
#define public #define private static |
A type for logical values is defined:
typedef int BOOLEAN #define FALSE 0 #define TRUE 1 #define OFF FALSE #define ON TRUE |
Other useful types defined include:
typedef double Real; typedef enum { OK, ERROR, INTERNAL_ERROR, END_OF_FILE, QUIT } Status; typedef char Smallest_int; |
Some macros useful for general programming include:
N_DIMENSIONS |
A constant equal to 3, the number of dimensions in the real world.
X |
A constant equal to 0, used as an index into various XYZ structures.
Y |
A constant equal to 1, used as an index into various XYZ structures.
Z |
A constant equal to 2, used as an index into various XYZ structures.
SIZEOF_STATIC_ARRAY( array ) |
returns the number of elements in a statically allocated array, for example,
{ int size; int array[] = { 1, 2, 3 }; size = SIZEOF_STATIC_ARRAY( array ); /* == 3 */ } |
ROUND( x ) |
returns the nearest integer to the x. If halfway in between two integers, returns the higher of the two. Works correctly for negative, zero, and positive numbers.
IS_INT( x ) |
returns TRUE if the real argument is exactly an integer.
FRACTION( x ) |
returns the fractional part of the argument.
FLOOR( x ) |
returns the largest integer less than or equal to the argument.
CEILING( x ) |
returns the smallest integer greater than or equal to the argument.
ABS( x ) |
returns the absolute value of an integer or real.
MAX( x, y ) |
returns the maximum of two integers or reals.
MAX3( x, y, z ) |
returns the maximum of three integers or reals.
MIN( x, y ) |
returns the minimum of two integers or reals.
MIN3( x, y, z ) |
returns the minimum of three integers or reals.
INTERPOLATE( alpha, a, b ) |
returns the interpolation between a and b, where alpha is in the range zero to one.
PI |
returns the value of Π
DEG_TO_RAD |
returns the number of radians per degrees, used to multiply an angle in degrees to result in radians.
RAD_TO_DEG |
returns the number of degrees per radian, used to multiply an angle in radians to result in degrees.
IJ( i, j, nj ) |
converts the indices [i, j] of a 2-D ni by nj array into a single index, based on row-major order.
IJK( i, j, k, nj, nk ) |
converts the indices [i, j, k] of a 3-D ni by nj by nk array into a single index, based on row-major order.
for_less( i, start, end ) |
performs a for loop where i starts at start and increments until it is greater than or equal to end.
Equivalent to for( i = start; i < end; ++i ).
for_inclusive( i, start, end ) |
performs a for loop where i starts at start and increments until it is greater than end.
Equivalent to for( i = start; i <= end; ++i ).
GLUE(x,y) |
Special C source macro to stick two different identifiers together, i.e., GLUE(colour,_name) results in colour_name.
GLUE3(x,y,z) |
Special C source macro to stick three different identifiers together, i.e., GLUE(a,b,c) results in abc.
<<< Previous | Home | Next >>> |
Structure Arguments | Programming Utilities |