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.7 by schorsch, Sun Jun 8 12:03:10 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 "fvect.h"
17  
18   #ifdef  M_PI
19 < #define  PI             M_PI
19 > #define  PI             ((double)M_PI)
20   #else
21   #define  PI             3.14159265358979323846
22   #endif
# Line 170 | Line 169 | cvobject(fname, fin)           /* convert an object */
169   char    *fname;
170   FILE    *fin;
171   {
172 +        extern char     *fgetword();
173          char    buf[128], typ[16], nam[128];
174          int     i, n;
175          register int    j;
# Line 194 | Line 194 | FILE   *fin;
194                          goto readerr;
195                  printf("%d", n);
196                  for (j = 0; j < n; j++) {
197 <                        if (fscanf(fin, "%s", buf) != 1)
197 >                        if (fgetword(buf, sizeof(buf), fin) == NULL)
198                                  goto readerr;
199                          if (j%3 == 0)
200                                  putchar('\n');
201 <                        printf("\t%s", buf);
201 >                        putchar('\t');
202 >                        fputword(buf, stdout);
203                  }
204                  putchar('\n');
205          }
# Line 218 | Line 219 | FILE   *fin;
219          int     n;
220          char    buf[256];
221  
222 +        buf[0] = '\0';                  /* bug fix thanks to schorsch */
223          if (m->doxform) {
224                  sprintf(buf, "xform -e -n %s", mark);
225                  if (m->modout != NULL)
# Line 258 | Line 260 | EDGE   *e1, *e2;
260  
261   int
262   buildxf(xf, markscale, fin)             /* build transform for marker */
263 < char    *xf;
263 > register char   *xf;
264   double  markscale;
265   FILE    *fin;
266   {
# Line 325 | Line 327 | FILE   *fin;
327          if (markscale > 0.0) {          /* add scale factor */
328                  sprintf(xf, " -s %f", xlen*markscale);
329                  n += 2;
330 <                xf += strlen(xf);
330 >                while (*xf) ++xf;
331          }
332                                          /* add rotation */
333          n += addrot(xf, xvec, yvec, zvec);
334 <        xf += strlen(xf);
334 >        while (*xf) ++xf;
335                                          /* add translation */
336          n += 4;
337          sprintf(xf, " -t %f %f %f", vlist[elist[1].beg][0],
# Line 339 | Line 341 | FILE   *fin;
341  
342  
343   addrot(xf, xp, yp, zp)          /* compute rotation (x,y,z) => (xp,yp,zp) */
344 < char    *xf;
344 > register char   *xf;
345   FVECT   xp, yp, zp;
346   {
347          int     n;
# Line 349 | Line 351 | FVECT  xp, yp, zp;
351          theta = atan2(yp[2], zp[2]);
352          if (!FEQ(theta,0.0)) {
353                  sprintf(xf, " -rx %f", theta*(180./PI));
354 <                xf += strlen(xf);
354 >                while (*xf) ++xf;
355                  n += 2;
356          }
357          theta = asin(-xp[2]);
358          if (!FEQ(theta,0.0)) {
359                  sprintf(xf, " -ry %f", theta*(180./PI));
360 <                xf += strlen(xf);
360 >                while (*xf) ++xf;
361                  n += 2;
362          }
363          theta = atan2(xp[1], xp[0]);
364          if (!FEQ(theta,0.0)) {
365                  sprintf(xf, " -rz %f", theta*(180./PI));
366 <                /* xf += strlen(xf); */
366 >                /* while (*xf) ++xf; */
367                  n += 2;
368          }
369          return(n);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines