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.2 by schorsch, Mon Oct 27 10:28:59 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  
38 < 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 <
103 < plot(infp)              /* plot meta-file */
104 <
105 < FILE  *infp;
106 <
107 < {
108 <    PRIMITIVE  nextp;
109 <
110 <    set(SALL, NULL);
111 <    do {
112 <        readp(&nextp, infp);
113 <        while (isprim(nextp.com)) {
114 <            doprim(&nextp, 1);
115 <            readp(&nextp, infp);
116 <        }
117 <        doglobal(&nextp, 1);
118 <    } while (nextp.com != PEOF);
119 <
120 < }
121 <
122 <
123 <
124 < replay(xmin, ymin, xmax, ymax)          /* play back region */
125 < int  xmin, ymin, xmax, ymax;
126 < {
127 <    register PRIMITIVE  *p;
128 <
129 <    unset(SALL);
130 <    set(SALL, NULL);
131 <    for (p = recording.ptop; p != NULL; p = p->pnext)
132 <        if (isprim(p->com)) {
133 <            if (overlap(p, xmin, ymin, xmax, ymax))
134 <                doprim(p, 0);
135 <        } else
136 <            doglobal(p, 0);
137 <
138 < }
139 <
140 <
141 <
142 <
38 > void
39   save(p)                         /* record primitive */
40   PRIMITIVE  *p;
41   {
# Line 147 | Line 43 | PRIMITIVE  *p;
43  
44      if ((pnew = palloc()) == NULL)
45              error(SYSTEM, "out of memory in save");
46 <    mcopy(pnew, p, sizeof(PRIMITIVE));
46 >    mcopy((char *)pnew, (char *)p, sizeof(PRIMITIVE));
47      add(pnew, &recording);
48   }
49  
50  
51 <
156 <
51 > void
52   doglobal(g, sf)                 /* execute a global command */
158
53   register PRIMITIVE  *g;
54   int  sf;
161
55   {
56  
57      switch (g->com) {
# Line 167 | Line 60 | int  sf;
60              return;
61  
62          case PDRAW:
63 <            XFlush();
63 >            pXFlush();
64              break;
65  
66          case PEOP:
# Line 200 | Line 93 | int  sf;
93   }
94  
95  
96 <
204 <
96 > void
97   doprim(p, sf)           /* plot primitive */
206
98   register PRIMITIVE  *p;
99   int  sf;
209
100   {
101  
102      switch (p->com) {
# Line 242 | 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