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.11 by greg, Thu Jan 29 22:20:31 2004 UTC vs.
Revision 2.15 by greg, Fri Jan 25 02:11:13 2008 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char RCSid[] = "$Id";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   * Replace markers in Radiance scene description with objects or instances.
# Line 26 | Line 26 | static const char RCSid[] = "$Id";
26   #define  FEQ(a,b)       ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7)
27  
28   #define  MAXVERT        6       /* maximum number of vertices for markers */
29 < #define  MAXMARK        32      /* maximum number of markers */
29 > #define  MAXMARK        128     /* maximum number of markers */
30  
31   #define  USE_XFORM      1       /* use !xform inline command */
32   #define  USE_INSTANCE   2       /* use instance primitive */
# Line 43 | Line 43 | struct mrkr {
43          char    *modin;                 /* input modifier indicating marker */
44          char    *objname;               /* output object file or octree */
45          int     usetype;                /* one of USE_* above */
46 < }  marker[MAXMARK];             /* array of markers */
46 > }  marker[MAXMARK+1];           /* array of markers */
47   int     nmarkers = 0;           /* number of markers */
48  
49   int     expand;                 /* expand commands? */
# Line 102 | Line 102 | main(
102                  } while (argv[i][0] == '-');
103                  if (marker[nmarkers].objname == NULL)
104                          goto userr;
105 +                if (nmarkers >= MAXMARK) {
106 +                        fprintf(stderr, "%s: too many markers\n", progname);
107 +                        return 1;
108 +                }
109                  marker[nmarkers++].modin = argv[i++];
106                if (nmarkers >= MAXMARK)
107                        break;
110                  marker[nmarkers].mscale = marker[nmarkers-1].mscale;
111          }
112          if (nmarkers == 0)
# Line 200 | Line 202 | cvobject(              /* convert an object */
202          int     i, n;
203          register int    j;
204  
205 <        if (fscanf(fin, "%s %s %s", buf, typ, nam) != 3)
205 >        if (fgetword(buf, sizeof(buf), fin) == NULL ||
206 >                        fgetword(typ, sizeof(typ), fin) == NULL ||
207 >                        fgetword(nam, sizeof(nam), fin) == NULL)
208                  goto readerr;
209          if (!strcmp(typ, "polygon"))
210                  for (j = 0; j < nmarkers; j++)
# Line 208 | Line 212 | cvobject(              /* convert an object */
212                                  replace(fname, &marker[j], nam, fin);
213                                  return;
214                          }
215 <        printf("\n%s %s %s\n", buf, typ, nam);
215 >        putchar('\n'); fputword(buf, stdout);
216 >        printf(" %s ", typ);
217 >        fputword(nam, stdout); putchar('\n');
218          if (!strcmp(typ, "alias")) {            /* alias special case */
219 <                if (fscanf(fin, "%s", buf) != 1)
219 >                if (fgetword(buf, sizeof(buf), fin) == NULL)
220                          goto readerr;
221 <                printf("\t%s\n", buf);
221 >                putchar('\t'); fputword(buf, stdout); putchar('\n');
222                  return;
223          }
224          for (i = 0; i < 3; i++) {               /* pass along arguments */
# Line 385 | Line 391 | addrot(                /* compute rotation (x,y,z) => (xp,yp,zp) */
391          int     n;
392          double  theta;
393  
394 +        if (yp[2]*yp[2] + zp[2]*zp[2] < 2.*FTINY*FTINY) {
395 +                /* Special case for X' along Z-axis */
396 +                theta = -atan2(yp[0], yp[1]);
397 +                sprintf(xf, " -ry %f -rz %f",
398 +                                xp[2] < 0.0 ? 90.0 : -90.0,
399 +                                theta*(180./PI));
400 +                return(4);
401 +        }
402          n = 0;
403          theta = atan2(yp[2], zp[2]);
404          if (!FEQ(theta,0.0)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines