ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/impress.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     /*
5     * Program to convert meta-files to imPress format
6     *
7     *
8     * 1/2/86
9     */
10    
11    
12     #include "meta.h"
13    
14     #include "imPcodes.h"
15    
16     #include "imPfuncs.h"
17    
18    
19     #define XCOM "pexpand +OCIsv -P %s"
20    
21    
22     char *progname;
23    
24     FILE *imout;
25    
26     static short newpage = TRUE;
27    
28    
29    
30     main(argc, argv)
31    
32     int argc;
33     char **argv;
34    
35     {
36     FILE *fp;
37     #ifdef UNIX
38     FILE *popen();
39     #endif
40     short condonly, conditioned;
41     char comargs[200], command[300];
42    
43     #ifdef CPM
44     fixargs("impress", &argc, &argv);
45     #endif
46    
47     progname = *argv++;
48     argc--;
49    
50     condonly = FALSE;
51     #ifdef UNIX
52     conditioned = FALSE;
53     #else
54     conditioned = TRUE;
55     #endif
56    
57     while (argc && **argv == '-') {
58     switch (*(*argv+1)) {
59     #ifdef UNIX
60     case 'c':
61     condonly = TRUE;
62     break;
63     case 'r':
64     conditioned = TRUE;
65     break;
66     #endif
67     default:
68     error(WARNING, "unknown option");
69     break;
70     }
71     argv++;
72     argc--;
73     }
74    
75     imInit();
76    
77     if (conditioned) {
78     if (argc)
79     while (argc) {
80     fp = efopen(*argv, "r");
81     plot(fp);
82     fclose(fp);
83     argv++;
84     argc--;
85     }
86     else
87     plot(stdin);
88     } else {
89     comargs[0] = '\0';
90     while (argc) {
91     strcat(comargs, " ");
92     strcat(comargs, *argv);
93     argv++;
94     argc--;
95     }
96     sprintf(command, XCOM, comargs);
97     #ifdef UNIX
98     if (condonly)
99     return(system(command));
100     else {
101     if ((fp = popen(command, "r")) == NULL)
102     error(SYSTEM, "cannot execute input filter");
103     plot(fp);
104     pclose(fp);
105     }
106     #endif
107     }
108    
109     if (!newpage)
110     imEndPage();
111     imEof();
112    
113     return(0);
114     }
115    
116    
117    
118     plot(infp) /* plot meta-file */
119    
120     register FILE *infp;
121    
122     {
123     PRIMITIVE nextp;
124    
125     do {
126     readp(&nextp, infp);
127     while (isprim(nextp.com)) {
128     doprim(&nextp);
129     fargs(&nextp);
130     readp(&nextp, infp);
131     }
132     doglobal(&nextp);
133     fargs(&nextp);
134     } while (nextp.com != PEOF);
135    
136     }
137    
138    
139    
140    
141    
142    
143     doglobal(g) /* execute a global command */
144    
145     register PRIMITIVE *g;
146    
147     {
148     char c;
149    
150     switch (g->com) {
151    
152     case PEOF:
153     break;
154    
155     case PDRAW:
156     fflush(stdout);
157     break;
158    
159     case PEOP:
160     if (!newpage)
161     imEndPage(); /* don't waste paper */
162     newpage = TRUE;
163     break;
164    
165     case PSET:
166     set(g->arg0, g->args);
167     break;
168    
169     case PUNSET:
170     unset(g->arg0);
171     break;
172    
173     case PRESET:
174     reset(g->arg0);
175     break;
176    
177     default:
178     sprintf(errmsg, "unknown command '%c' in doglobal", g->com);
179     error(WARNING, errmsg);
180     break;
181     }
182    
183     }
184    
185    
186    
187    
188     doprim(p) /* plot primitive */
189    
190     register PRIMITIVE *p;
191    
192     {
193    
194     switch (p->com) {
195    
196     case PMSTR:
197     printstr(p);
198     break;
199    
200     case PLSEG:
201     plotlseg(p);
202     break;
203    
204     case PRFILL:
205     fillrect(p);
206     break;
207    
208     case PTFILL:
209     filltri(p);
210     break;
211    
212     case PPFILL:
213     fillpoly(p);
214     break;
215    
216     default:
217     sprintf(errmsg, "unknown command '%c' in doprim", p->com);
218     error(WARNING, errmsg);
219     return;
220     }
221    
222     newpage = FALSE;
223    
224     }