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

Comparing ray/src/gen/replmarks.c (file contents):
Revision 2.2 by greg, Tue Mar 3 21:30:03 1992 UTC vs.
Revision 2.8 by schorsch, Mon Oct 27 10:27:25 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id";
3   #endif
6
4   /*
5   * Replace markers in Radiance scene description with objects or instances.
6   *
7   *      Created:        17 Feb 1991     Greg Ward
8   */
9  
10 < #include <stdio.h>
10 > #include <stdlib.h>
11   #include <ctype.h>
12   #include <math.h>
13 + #include <stdio.h>
14  
15 + #include "platform.h"
16 + #include "rtprocess.h"
17   #include "fvect.h"
18  
19   #ifdef  M_PI
20 < #define  PI             M_PI
20 > #define  PI             ((double)M_PI)
21   #else
22   #define  PI             3.14159265358979323846
23   #endif
# Line 148 | Line 148 | cvcomm(fname, fin)             /* convert a command */
148   char    *fname;
149   FILE    *fin;
150   {
151 <        FILE    *pin, *popen();
151 >        FILE    *pin;
152          char    buf[512], *fgetline();
153  
154          fgetline(buf, sizeof(buf), fin);
# Line 170 | Line 170 | cvobject(fname, fin)           /* convert an object */
170   char    *fname;
171   FILE    *fin;
172   {
173 +        extern char     *fgetword();
174          char    buf[128], typ[16], nam[128];
175          int     i, n;
176          register int    j;
# Line 194 | Line 195 | FILE   *fin;
195                          goto readerr;
196                  printf("%d", n);
197                  for (j = 0; j < n; j++) {
198 <                        if (fscanf(fin, "%s", buf) != 1)
198 >                        if (fgetword(buf, sizeof(buf), fin) == NULL)
199                                  goto readerr;
200                          if (j%3 == 0)
201                                  putchar('\n');
202 <                        printf("\t%s", buf);
202 >                        putchar('\t');
203 >                        fputword(buf, stdout);
204                  }
205                  putchar('\n');
206          }
# Line 218 | Line 220 | FILE   *fin;
220          int     n;
221          char    buf[256];
222  
223 +        buf[0] = '\0';                  /* bug fix thanks to schorsch */
224          if (m->doxform) {
225                  sprintf(buf, "xform -e -n %s", mark);
226                  if (m->modout != NULL)
# Line 258 | Line 261 | EDGE   *e1, *e2;
261  
262   int
263   buildxf(xf, markscale, fin)             /* build transform for marker */
264 < char    *xf;
264 > register char   *xf;
265   double  markscale;
266   FILE    *fin;
267   {
# Line 325 | Line 328 | FILE   *fin;
328          if (markscale > 0.0) {          /* add scale factor */
329                  sprintf(xf, " -s %f", xlen*markscale);
330                  n += 2;
331 <                xf += strlen(xf);
331 >                while (*xf) ++xf;
332          }
333                                          /* add rotation */
334          n += addrot(xf, xvec, yvec, zvec);
335 <        xf += strlen(xf);
335 >        while (*xf) ++xf;
336                                          /* add translation */
337          n += 4;
338          sprintf(xf, " -t %f %f %f", vlist[elist[1].beg][0],
# Line 339 | Line 342 | FILE   *fin;
342  
343  
344   addrot(xf, xp, yp, zp)          /* compute rotation (x,y,z) => (xp,yp,zp) */
345 < char    *xf;
345 > register char   *xf;
346   FVECT   xp, yp, zp;
347   {
348          int     n;
# Line 349 | Line 352 | FVECT  xp, yp, zp;
352          theta = atan2(yp[2], zp[2]);
353          if (!FEQ(theta,0.0)) {
354                  sprintf(xf, " -rx %f", theta*(180./PI));
355 <                xf += strlen(xf);
355 >                while (*xf) ++xf;
356                  n += 2;
357          }
358          theta = asin(-xp[2]);
359          if (!FEQ(theta,0.0)) {
360                  sprintf(xf, " -ry %f", theta*(180./PI));
361 <                xf += strlen(xf);
361 >                while (*xf) ++xf;
362                  n += 2;
363          }
364          theta = atan2(xp[1], xp[0]);
365          if (!FEQ(theta,0.0)) {
366                  sprintf(xf, " -rz %f", theta*(180./PI));
367 <                /* xf += strlen(xf); */
367 >                /* while (*xf) ++xf; */
368                  n += 2;
369          }
370          return(n);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines