Back to index

radiance  4R0+20100331
meta.h
Go to the documentation of this file.
00001 /* RCSid: $Id: meta.h,v 1.10 2004/03/22 02:24:23 greg Exp $ */
00002 /*
00003  *   Standard meta-file definitions and limits
00004  */
00005 #ifndef _RAD_META_H_
00006 #define _RAD_META_H_
00007 
00008 #include "copyright.h"
00009 
00010 #include  <stdio.h>
00011 #include  <stdlib.h>
00012 #include  <ctype.h>
00013 
00014 #include  "rterror.h"
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 #define  TRUE  1
00021 #define  FALSE  0
00022 
00023 #define  PEOF  'F'          /* end of file global */
00024 #define  PEOP  'E'          /* end of page global */
00025 #define  PPAUS  'P'         /* pause global */
00026 #define  PDRAW  'D'         /* draw global */
00027 #define  POPEN  'O'         /* open segment */
00028 #define  PCLOSE  'C'        /* close segment */
00029 #define  PSET  'S'          /* set global */
00030 #define  PUNSET  'U'        /* unset global */
00031 #define  PRESET  'R'        /* reset global to default */
00032 #define  PINCL  'I'         /* include file */
00033 
00034 #define  PLSEG  'l'         /* line segment command */
00035 #define  PRFILL  'r'        /* rectangle fill command */
00036 #define  PTFILL  't'        /* triangle fill command */
00037 #define  PMSTR  'm'         /* matrix string command */
00038 #define  PVSTR  'v'         /* vector string command */
00039 #define  PSEG  's'          /* print segment command */
00040 #define  PPFILL  'p'        /* polygon fill command */
00041 
00042 #define  NCOMMANDS  17             /* number of commands */
00043 
00044 #define  COML  "lrtmsvpOCESURPDIF" /* command letters */
00045 
00046 #define  ADELIM  '`'        /* additional argument delimiter */
00047 #define  CDELIM  '#'        /* comment delimiter */
00048 
00049 #define  MAXARGS  2048             /* maximum argument string for primitive */
00050 
00051 #define  SALL  0            /* set all */
00052 #define  SPAT0  04          /* set pattern 0 */
00053 #define  SPAT1  05          /* set pattern 1 */
00054 #define  SPAT2  06          /* set pattern 2 */
00055 #define  SPAT3  07          /* set pattern 3 */
00056 
00057 
00058 #ifdef  _WIN32  /* XXX */
00059 #define MDIR "C:\\tmp\\" /* XXX we just need something to compile for now */
00060 #define TTY "CON:"   /* XXX this probably doesn't work */
00061 #define TDIR "C:\\tmp\\" /* XXX we just need something to compile for now */
00062 #else  /* XXX */
00063 
00064 #define  TDIR  "/tmp/"             /* directory for temporary files */
00065 #ifndef  MDIR
00066 #define  MDIR  "/usr/local/lib/meta/"     /* directory for metafiles */
00067 #endif
00068 #define  TTY  "/dev/tty"    /* console name */
00069 #endif
00070 
00071 #define  MAXFNAME  64              /* maximum file name length */
00072 
00073 #define  XYSIZE  (1<<14)    /* metafile coordinate size */
00074 
00075 #ifndef max
00076 #define  max(x, y)  ((x) > (y) ? (x) : (y))
00077 #endif
00078 #ifndef min
00079 #define  min(x, y)  ((x) < (y) ? (x) : (y))
00080 #endif
00081 
00082 #define  abs(x)  ((x) < 0 ? -(x) : (x))
00083 
00084 #define  iscom(c)  (comndx(c) != -1)
00085 #define  isglob(c)  isupper(c)
00086 #define  isprim(c)  islower(c)
00087 
00088 #define  WIDTH(wspec)  ((wspec)==0 ? 0 : 12*(1<<(wspec)))
00089 #define  CONV(coord, size)  ((int)(((long)(coord)*(size))>>14))
00090 #define  ICONV(dcoord, size)  ((int)(((long)(dcoord)<<14)/(size)))
00091 
00092 #define  XMN  0                    /* index in xy array for xmin */
00093 #define  YMN  1                    /* index in xy array for ymin */
00094 #define  XMX  2                    /* index in xy array for xmax */
00095 #define  YMX  3                    /* index in xy array for ymax */
00096 
00097 
00098 /*
00099  *    Structure definitions for primitives
00100  */
00101 
00102 struct primitive  {                /* output primitive */
00103                    short  com,            /* command (0 - 127) */
00104                        arg0;              /* first argument (1 byte) */
00105                  int  xy[4];              /* extent=(xmin,ymin,xmax,ymax) */
00106                  char  *args;             /* additional arguments */
00107                  struct primitive  *pnext;       /* next primitive */
00108                  };
00109 
00110 typedef struct primitive  PRIMITIVE;
00111 
00112 struct plist  {                           /* list of primitives */
00113               PRIMITIVE  *ptop, *pbot;
00114               };
00115 
00116 typedef struct plist  PLIST;
00117 
00118 
00119 /*
00120  *   External declarations
00121  */
00122 
00123 char  *savestr();
00124 
00125 PRIMITIVE *pop();
00126 
00127 FILE  *efopen(), *mfopen();
00128 
00129 extern char  coms[];
00130 extern char  errmsg[];
00131 extern char  *progname;
00132 
00133        /* expand.c */
00134 extern void expand(FILE *infp, short *exlist);
00135        /* palloc.c */
00136 extern PRIMITIVE *palloc(void);
00137 extern void pfree(PRIMITIVE *p);
00138 extern void plfree(PLIST *pl);
00139        /* sort.c */
00140 extern void sort(FILE *infp, int (*pcmp)());
00141 extern void pmergesort(FILE *fi[], int nf, PLIST *pl, int (*pcmp)(), FILE *ofp);
00142        /* metacalls.c */
00143 extern void mdraw(int x, int y);
00144 extern void msegment(int xmin, int ymin, int xmax, int ymax, char *sname,
00145               int d, int thick, int color);
00146 extern void mvstr(int xmin, int ymin, int xmax, int ymax, char *s,
00147               int d, int thick, int color);
00148 extern void mtext(int x, int y, char *s, int cpi, int color);
00149 extern void mpoly(int x, int y, int border, int pat, int color);
00150 extern void mtriangle(int xmin, int ymin, int xmax, int ymax,
00151               int d, int pat, int color);
00152 extern void mrectangle(int xmin, int ymin, int xmax, int ymax,
00153               int pat, int color);
00154 extern void mline(int x, int y, int type, int thick, int color);
00155 extern void mcloseseg(void);
00156 extern void mopenseg(char *sname);
00157 extern void msetpat(int pn, char *pat);
00158 extern void minclude(char *fname);
00159 extern void mdone(void);
00160 extern void mendpage(void);
00161        /* misc.c */
00162 extern int comndx(int c);
00163 extern PRIMITIVE  *pop(PLIST  *pl);
00164 extern void push(PRIMITIVE  *p, PLIST  *pl);
00165 extern void add(PRIMITIVE  *p, PLIST  *pl);
00166 extern void append(PLIST  *pl1, PLIST  *pl2);
00167 extern void fargs(PRIMITIVE  *p);
00168 extern char * nextscan(char  *start, char  *format, char  *result);
00169 extern void mcopy(char  *p1, char  *p2, int  n);
00170        /* segment.c */
00171 extern int inseg(void);
00172 extern void closeseg(void);
00173 extern void openseg(char *name);
00174 extern void segprim(PRIMITIVE  *p);
00175 extern void segment(PRIMITIVE *p, void (*funcp)(PRIMITIVE *p));
00176 extern int xlate(short extrema, PRIMITIVE *p, PRIMITIVE *px);
00177        /* cgraph.c */
00178 extern void cgraph(int width, int length);
00179 extern void cplot(void);
00180 extern void cpoint(int  c, double  x, double  y);
00181        /* gcalc.c */
00182 extern void gcalc(char  *types);
00183        /* hfio.c, mfio.c */
00184 extern int readp(PRIMITIVE  *p, FILE  *fp);
00185 extern void writep(PRIMITIVE  *p, FILE  *fp);
00186 extern void writeof(FILE  *fp); 
00187 
00188 
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192 #endif /* _RAD_META_H_ */
00193