home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BoldtOld
/
MERGE
/
llvs_per_plane.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-14
|
8KB
|
240 lines
/* -*-c-mode-*- */
/*------------------------------------------------------
* LLVS_PER_PLANE.H - C Macros for the Per Plane Method
* James H. Burrill, Jr. Created on Thu Mar 13 10:38:29 1986
* Last mod -
*--------------------------------------------------------
* Contents:
*--------------------------------------------------------
* (c) Copyright 1986 by The University of Massachusetts
*------------------------------------------------------*/
#define MAXPLANE 9
#define PI 3.141592653589
#define PI2 6.283185307178
#define PI_OVER_2 1.570796326945
#define NULL 0
#define TRUE 1
#define FALSE 0
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
#define GETBIT(base,offset) \
((base)[(offset) >> 3] >>((offset) & 0x07) & 0x01)
#define SETBIT(base,offset,value) \
if (value != 0) (base)[(offset) >> 3] |= 1 << ((offset) & 0x07); \
else (base)[(offset) >> 3] &= ~(1 << ((offset) & 0x07))
/*------------------------------------------------------
*
* PLANE
* This structure describes the format of a plane passed
* to C. Each plane is passed to the C routine as a separate
* argument of type PLANE.
*
*-------------------------------------------------------
*/
typedef struct {
int plane_base[1]; /* plane data starts here */
} PLANE;
/*----------------------------------------------------------
*
* PLANE_INFO
* Other information is available for each plane. This
* information is passed in an array of PLANE_INFO[MAXPLANE].
* The Lisp function BUILD-PLANE-INFO-VECTOR-C may be used to
* build the array. The background-value is passed as a C float
* value if the plane is a floating point plane, C int
* type otherwise.
*
*----------------------------------------------------------*/
/* plane info struct */
typedef struct {
long int datatype; /* data type */
#define LLVS_BIT 0 /* bit type */
#define LLVS_BYTE 1 /* unsigned byte type */
#define LLVS_SHORT 2 /* signed 16 bit type */
#define LLVS_INT 3 /* integer type */
#define LLVS_FLOAT 4 /* float type */
#define FLOAT 4 /* float type */
long int level; /* plane level */
long int row_location; /* row location */
long int column_location; /* column location */
long int row_dimension; /* row dimension */
long int column_dimension; /* column dimension */
union {
long int fixnum; /* background value */
float flonum; /* dito, but as a flonum */
} background;
} PLANE_INFO;
/*---------------------------------------------------------
*
* MASK_VALUES
* The mask values are passed as an array on int.
* The Lisp function BUILD-MASK-VALUES-C can be used to prepare
* structure to be passed to C.
*
*---------------------------------------------------------*/
typedef struct {
long int num_values; /* number of values */
long int value_base[1]; /* value(s) start here */
} MASK_VALUES;
/*---------------------------------------------------------
*
* LIMITS
* The LIMITS are passed in this structure. The Lisp
* function BUILD-LIMITS-C may be used to prepare this structure.
*
*---------------------------------------------------------*/
typedef struct {
long int startrow,endrow,deltarow,startcol,endcol,deltacol,level;
} LIMITS;
/*------------------------------------------------------------
*
* TRANSLEVEL
* This macro converts a row or column index from the
* conceptual plane into a row or column index into the
* actual plane.
*
* result - the resultant row or column index.
* current - the row or column index to be converted.
* deltalevel - a positive or negative integer denoting the
* difference in levels between the conceptual
* plane and the actual plane ---
* (conceptual level - actual level).
* location - the row or column location of the actual plane.
*
*------------------------------------------------------------*/
#define TRANSLEVEL(result,current,deltalevel,location) \
if ((deltalevel) < 0) result = ((current) << -(deltalevel)) - (location);\
else result = ((current) >> (deltalevel)) - (location)
/*-------------------------------------------------------------
*
* GET_PIXEL
* Gets a pixel from a PLANE.
*
* result - the resultant pixel converted to the type of result.
* bkgv - the value to be used if the pixel is not in the actual
* plane.
* plane - a pointer to a PLANE structure.
* row - the row index in the actual plane.
* col - the column index in the actual plane.
*
*---------------------------------------------------------------*/
#define GET_PIXEL(result,bkgv,plane,row,col,pl_info) \
if ((row) < 0 || (row) >= pl_info.row_dimension || \
(col) < 0 || (col) >= pl_info.column_dimension) \
result = (bkgv); \
else { \
register llvsoffset; \
llvsoffset = (col) + ((row) * pl_info.column_dimension); \
switch (pl_info.datatype) { \
case LLVS_BIT: \
result = GETBIT(((char*) plane->plane_base),llvsoffset); \
break; \
case LLVS_BYTE: \
result = ((unsigned char*) plane->plane_base)[llvsoffset]; \
break; \
case LLVS_SHORT: \
result = ((short int*) plane->plane_base)[llvsoffset]; \
break; \
case LLVS_INT: \
result = ((int*) plane->plane_base)[llvsoffset]; \
break; \
case LLVS_FLOAT: \
result = ((float*) plane->plane_base)[llvsoffset]; \
break; \
}}
/*-------------------------------------------------------------------
*
* SET_PIXEL
* Sets a pixel in the plane. If the pixel does not exist, nothing
* is done.
*
* value - this value is converted to the proper type and put in the
* pixel.
* plane - a pointer to a structure of type PLANE.
* row - the row index into the actual plane.
* col - the column index into the actual plane.
* pl_info - row, column, dimensions, etc
*------------------------------------------------------------------*/
#define SET_PIXEL(value,plane,row,col,pl_info) \
if ((row) >= 0 && (row) < pl_info.row_dimension && \
(col) >= 0 && (col) < pl_info.column_dimension) { \
register llvsoffset; \
llvsoffset = (col) + ((row) * pl_info.column_dimension); \
switch (pl_info.datatype) { \
case LLVS_BIT: \
SETBIT(((char*)plane->plane_base),llvsoffset,value); \
break; \
case LLVS_BYTE: \
((unsigned char*) plane->plane_base)[llvsoffset] = value; \
break; \
case LLVS_SHORT: \
((short int*) plane->plane_base)[llvsoffset] = value; \
break; \
case LLVS_INT: \
((int*) plane->plane_base)[llvsoffset] = value; \
break; \
case LLVS_FLOAT: \
((float*) plane->plane_base)[llvsoffset] = value; \
break; \
}}
#define ZERO_PLANE(pl_info) \
(pl_info.row_dimension == 0 || \
pl_info.column_dimension == 0)
#define PLANE_LEV_ERR(pl_info,pl1,pl2)\
(pl_info[pl1].level != pl_info[pl2].level)
#define PLANE_LOC_ERR(pl_info,pl1,pl2) \
(pl_info[pl1].row_location != pl_info[pl2].row_location)
#define PLANE_SIZE_ERR(pl_info,pl1,pl2) \
(pl_info[pl1].row_dimension != pl_info[pl2].row_dimension || \
pl_info[pl1].column_dimension != pl_info[pl2].column_dimension)
#define LIMITS_ERR(lims)\
(lims->deltarow <= 0 || \
lims->deltacol <= 0 || \
lims->startrow > lims->endrow || \
lims->startcol > lims->endcol)
#define EXTERNAL globalref
/* scratch_size
This macro defines the size of a statically allocated array to be used
as a scratch area by the image operators written in C. The primary use will
probably be to receive the pixels returned by a window function. The size of
this array is guaranteed to be scratch_size*4 bytes. The user is free to use
an EXTERN statement to declare the type and organization of the array.
Examples:
extern int scratch[scratch_size];
extern float scratch [scratch_size];
extern char scratch [4 * scratch_size];
*/
#define SCRATCH_SIZE 2048