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

Comparing ray/src/gen/genbox.c (file contents):
Revision 2.8 by greg, Sat Jul 25 19:18:01 2020 UTC vs.
Revision 2.10 by greg, Thu Apr 8 15:13:08 2021 UTC

# Line 22 | Line 22 | double  size[3];       /* ppd size */
22  
23   double  bevel = 0.0;    /* bevel amount */
24  
25 < int  rounde = 0;                /* boolean true for rounde edges */
25 > int  rounde = 0;        /* boolean true for round edges */
26  
27   int  reverse = 0;       /* boolean true for reversed normals */
28  
29  
30
30   static void
31   vertex(int v)
32   {
33 <        register int  i;
33 >        int  i;
34  
35          for (i = 0; i < 3; i++) {
36                  if (v & 010)
37 <                        printf("\t%18.12g", v & 01 ? size[i]-bevel : bevel);
37 >                        printf("\t%18.12g", (v&01)^reverse ? size[i]-bevel : bevel);
38                  else
39 <                        printf("\t%18.12g", v & 01 ? size[i] : 0.0);
39 >                        printf("\t%18.12g", (v&01)^reverse ? size[i] : 0.0);
40                  v >>= 1;
41          }
42 <        printf("\n");
42 >        fputc('\n', stdout);
43   }
44  
45  
# Line 50 | Line 49 | side(int a, int b, int c, int d)               /* generate a rectan
49          printf("\n%s polygon %s.%c%c%c%c\n", cmtype, cname,
50                          let[a], let[b], let[c], let[d]);
51          printf("0\n0\n12\n");
52 <        if (reverse) {
53 <                vertex(d);
54 <                vertex(c);
55 <                vertex(b);
57 <                vertex(a);
58 <        } else {
59 <                vertex(a);
60 <                vertex(b);
61 <                vertex(c);
62 <                vertex(d);
63 <        }
52 >        vertex(a);
53 >        vertex(b);
54 >        vertex(c);
55 >        vertex(d);
56   }
57  
58  
# Line 70 | Line 62 | corner(int a, int b, int c)                    /* generate a triangular
62          printf("\n%s polygon %s.%c%c%c\n", cmtype, cname,
63                          let[a], let[b], let[c]);
64          printf("0\n0\n9\n");
65 <        if (reverse) {
66 <                vertex(c);
67 <                vertex(b);
76 <                vertex(a);
77 <        } else {
78 <                vertex(a);
79 <                vertex(b);
80 <                vertex(c);
81 <        }
65 >        vertex(a);
66 >        vertex(b);
67 >        vertex(c);
68   }
69  
70  
# Line 104 | Line 90 | sphere(int v0)                 /* generate a sphere */
90  
91  
92   int
93 < main(int argc, char **argv)
93 > main(int argc, char *argv[])
94   {
95          int  i;
96          
# Line 116 | Line 102 | main(int argc, char **argv)
102          size[0] = atof(argv[3]);
103          size[1] = atof(argv[4]);
104          size[2] = atof(argv[5]);
105 +        if ((size[0] <= 0.0) | (size[1] <= 0.0) | (size[2] <= 0.0))
106 +                goto userr;
107  
108          for (i = 6; i < argc; i++) {
109                  if (argv[i][0] != '-')
110                          goto userr;
111                  switch (argv[i][1]) {
112 +                case 'i':
113 +                        reverse = 1;
114 +                        break;
115                  case 'r':
116                          rounde = 1;
117                          /* fall through */
118                  case 'b':
119                          bevel = atof(argv[++i]);
120 <                        break;
121 <                case 'i':
122 <                        reverse = 1;
132 <                        break;
120 >                        if (bevel > 0.0)
121 >                                break;
122 >                        /* fall through on error */
123                  default:
124                          goto userr;
125                  }
126          }
127 +        if (rounde & reverse)
128 +                fprintf(stderr, "%s: warning - option -i ignored with -r\n",
129 +                                argv[0]);
130  
131          fputs("# ", stdout);
132          printargs(argc, argv, stdout);
# Line 172 | Line 165 | main(int argc, char **argv)
165                  corner(037, 067, 057);
166          }
167          if (bevel > 0.0 && rounde) {
168 <                                        /* rounde edges */
168 >                                        /* round edges */
169                  cylinder(070, 071);
170                  cylinder(070, 074);
171                  cylinder(070, 072);
# Line 185 | Line 178 | main(int argc, char **argv)
178                  cylinder(076, 072);
179                  cylinder(076, 074);
180                  cylinder(076, 077);
181 <                                        /* rounde corners */
181 >                                        /* round corners */
182                  sphere(070);
183                  sphere(071);
184                  sphere(072);
# Line 195 | Line 188 | main(int argc, char **argv)
188                  sphere(076);
189                  sphere(077);
190          }
191 <        if (bevel == 0.0 ) {
191 >        if (bevel == 0.0) {
192                                          /* only need major faces */
193                  side(1, 5, 4, 0);
194                  side(4, 6, 2, 0);
# Line 208 | Line 201 | main(int argc, char **argv)
201   userr:
202          fprintf(stderr, "Usage: %s ", argv[0]);
203          fprintf(stderr, "material name xsize ysize zsize ");
204 <        fprintf(stderr, "[-i] [-b bevel | -r rounde]\n");
204 >        fprintf(stderr, "[-i] [-b bevel | -r round]\n");
205          return(1);
206   }
214

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines