ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/xmeta.c
(Generate patch)

Comparing ray/src/meta/xmeta.c (file contents):
Revision 1.3 by greg, Mon Nov 17 02:21:53 2003 UTC vs.
Revision 1.5 by greg, Wed Nov 21 18:51:05 2007 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   */
11  
12   #include  "rtprocess.h"
13 + #include  "string.h"
14   #include  "meta.h"
15   #include  "plot.h"
16  
17 + extern void     init(char *name, char *geom);
18  
19   #define  overlap(p,xmn,ymn,xmx,ymx)  (ov((p)->xy[XMN],(p)->xy[XMX],xmn,xmx) \
20                                       &&ov((p)->xy[YMN],(p)->xy[YMX],ymn,ymx))
# Line 30 | Line 32 | static PLIST  recording;
32  
33   int maxalloc = 0;               /* no limit */
34  
35 + extern void     pXFlush(void);
36  
37  
35 main(argc, argv)
36
37 int  argc;
38 char  **argv;
39
40 {
41 FILE  *fp;
42 char  *geometry = NULL;
43 short  condonly, conditioned;
44 char  comargs[500], command[600];
45
46 progname = *argv++;
47 argc--;
48
49 condonly = FALSE;
50 conditioned = FALSE;
51
52 for ( ; argc; argv++, argc--)
53    if (!strcmp(*argv, "-c"))
54        condonly = TRUE;
55    else if (!strcmp(*argv, "-r"))
56        conditioned = TRUE;
57    else if (**argv == '=')
58        geometry = *argv;
59    else
60        break;
61
62 if (conditioned) {
63    init(progname, geometry);
64    if (argc)
65       while (argc)  {
66          fp = efopen(*argv, "r");
67          plot(fp);
68          fclose(fp);
69          argv++;
70          argc--;
71          }
72    else
73       plot(stdin);
74 } else  {
75    comargs[0] = '\0';
76    while (argc)  {
77       strcat(comargs, " ");
78       strcat(comargs, *argv);
79       argv++;
80       argc--;
81       }
82    sprintf(command, XCOM, comargs);
83    if (condonly)
84       return(system(command));
85    else  {
86       init(progname, geometry);
87       if ((fp = popen(command, "r")) == NULL)
88          error(SYSTEM, "cannot execute input filter");
89       plot(fp);
90       pclose(fp);
91       }
92    }
93
94 if (!newpage)
95     endpage();
96
97 return(0);
98 }
99
100
101
102
38   void
104 plot(infp)              /* plot meta-file */
105
106 FILE  *infp;
107
108 {
109    PRIMITIVE  nextp;
110
111    set(SALL, NULL);
112    do {
113        readp(&nextp, infp);
114        while (isprim(nextp.com)) {
115            doprim(&nextp, 1);
116            readp(&nextp, infp);
117        }
118        doglobal(&nextp, 1);
119    } while (nextp.com != PEOF);
120
121 }
122
123
124
125 replay(xmin, ymin, xmax, ymax)          /* play back region */
126 int  xmin, ymin, xmax, ymax;
127 {
128    register PRIMITIVE  *p;
129
130    unset(SALL);
131    set(SALL, NULL);
132    for (p = recording.ptop; p != NULL; p = p->pnext)
133        if (isprim(p->com)) {
134            if (overlap(p, xmin, ymin, xmax, ymax))
135                doprim(p, 0);
136        } else
137            doglobal(p, 0);
138
139 }
140
141
142
143
39   save(p)                         /* record primitive */
40   PRIMITIVE  *p;
41   {
# Line 153 | Line 48 | PRIMITIVE  *p;
48   }
49  
50  
51 <
157 <
51 > void
52   doglobal(g, sf)                 /* execute a global command */
159
53   register PRIMITIVE  *g;
54   int  sf;
162
55   {
56  
57      switch (g->com) {
# Line 168 | Line 60 | int  sf;
60              return;
61  
62          case PDRAW:
63 <            XFlush();
63 >            pXFlush();
64              break;
65  
66          case PEOP:
# Line 201 | Line 93 | int  sf;
93   }
94  
95  
96 <
205 <
96 > void
97   doprim(p, sf)           /* plot primitive */
207
98   register PRIMITIVE  *p;
99   int  sf;
210
100   {
101  
102      switch (p->com) {
# Line 243 | Line 132 | int  sf;
132      }
133  
134   }
135 +
136 +
137 + void
138 + plot(infp)              /* plot meta-file */
139 + FILE  *infp;
140 + {
141 +    PRIMITIVE  nextp;
142 +
143 +    set(SALL, NULL);
144 +    do {
145 +        readp(&nextp, infp);
146 +        while (isprim(nextp.com)) {
147 +            doprim(&nextp, 1);
148 +            readp(&nextp, infp);
149 +        }
150 +        doglobal(&nextp, 1);
151 +    } while (nextp.com != PEOF);
152 +
153 + }
154 +
155 +
156 + void
157 + replay(xmin, ymin, xmax, ymax)          /* play back region */
158 + int  xmin, ymin, xmax, ymax;
159 + {
160 +    register PRIMITIVE  *p;
161 +
162 +    unset(SALL);
163 +    set(SALL, NULL);
164 +    for (p = recording.ptop; p != NULL; p = p->pnext)
165 +        if (isprim(p->com)) {
166 +            if (overlap(p, xmin, ymin, xmax, ymax))
167 +                doprim(p, 0);
168 +        } else
169 +            doglobal(p, 0);
170 +
171 + }
172 +
173 +
174 + int
175 + main(argc, argv)
176 + int  argc;
177 + char  **argv;
178 + {
179 + FILE  *fp;
180 + char  *geometry = NULL;
181 + short  condonly, conditioned;
182 + char  comargs[500], command[600];
183 +
184 + progname = *argv++;
185 + argc--;
186 +
187 + condonly = FALSE;
188 + conditioned = FALSE;
189 +
190 + for ( ; argc; argv++, argc--)
191 +    if (!strcmp(*argv, "-c"))
192 +        condonly = TRUE;
193 +    else if (!strcmp(*argv, "-r"))
194 +        conditioned = TRUE;
195 +    else if (**argv == '=')
196 +        geometry = *argv;
197 +    else
198 +        break;
199 +
200 + if (conditioned) {
201 +    init(progname, geometry);
202 +    if (argc)
203 +       while (argc)  {
204 +          fp = efopen(*argv, "r");
205 +          plot(fp);
206 +          fclose(fp);
207 +          argv++;
208 +          argc--;
209 +          }
210 +    else
211 +       plot(stdin);
212 + } else  {
213 +    comargs[0] = '\0';
214 +    while (argc)  {
215 +       strcat(comargs, " ");
216 +       strcat(comargs, *argv);
217 +       argv++;
218 +       argc--;
219 +       }
220 +    sprintf(command, XCOM, comargs);
221 +    if (condonly)
222 +       return(system(command));
223 +    else  {
224 +       init(progname, geometry);
225 +       if ((fp = popen(command, "r")) == NULL)
226 +          error(SYSTEM, "cannot execute input filter");
227 +       plot(fp);
228 +       pclose(fp);
229 +       }
230 +    }
231 +
232 + if (!newpage)
233 +     endpage();
234 +
235 + return(0);
236 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines