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

Comparing ray/src/gen/genrev.c (file contents):
Revision 2.8 by greg, Sat Aug 21 11:54:06 2004 UTC vs.
Revision 2.17 by greg, Wed Apr 23 01:57:04 2025 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   */
13  
14   #include  <stdlib.h>
15 #include  <stdio.h>
16 #include  <string.h>
15   #include  <math.h>
16  
17 + #include  "rtio.h"
18   #include  "rterror.h"
19   #include  "resolu.h"
21 #include  "rterror.h"
20   #include  "calcomp.h"
21  
22   #define  ZNAME          "Z`SYS`"                /* z function name */
# Line 35 | Line 33 | static const char      RCSid[] = "$Id$";
33  
34  
35   void
36 < computen(nzp, nrp, z0, r0, z1, r1)              /* compute normal */
37 < double  *nzp, *nrp, z0, r0, z1, r1;
36 > computen(                       /* compute normal */
37 >        double  *nzp,
38 >        double  *nrp,
39 >        double z0,
40 >        double r0,
41 >        double z1,
42 >        double r1
43 > )
44   {
45          double  dr, dz, len;
46  
# Line 88 | Line 92 | l_bspline(char *nm)
92  
93  
94   int
95 < main(argc, argv)
96 < int  argc;
97 < char  *argv[];
95 > main(
96 >        int  argc,
97 >        char  *argv[]
98 > )
99   {
100          char  stmp[256];
101          char  *modname;
# Line 100 | Line 105 | char  *argv[];
105          int  i, nseg;
106          int  orient;
107  
108 +        esupport |= E_VARIABLE|E_FUNCTION|E_RCONST;
109 +        esupport &= ~(E_OUTCHAN|E_INCHAN);
110          varset("PI", ':', PI);
111          funset("hermite", 5, ':', l_hermite);
112          funset("bezier", 5, ':', l_bezier);
# Line 111 | Line 118 | char  *argv[];
118          for (i = 6; i < argc; i++)
119                  if (!strcmp(argv[i], "-e"))
120                          scompile(argv[++i], NULL, 0);
121 <                else if (!strcmp(argv[i], "-f"))
122 <                        fcompile(argv[++i]);
123 <                else if (!strcmp(argv[i], "-s"))
121 >                else if (!strcmp(argv[i], "-f")) {
122 >                        char  *fpath = getpath(argv[++i], getrlibpath(), 0);
123 >                        if (fpath == NULL) {
124 >                                fprintf(stderr, "%s: cannot find file '%s'\n",
125 >                                                argv[0], argv[i]);
126 >                                quit(1);
127 >                        }
128 >                        fcompile(fpath);
129 >                } else if (!strcmp(argv[i], "-s"))
130                          smooth = 1;
131                  else
132                          goto userror;
# Line 122 | Line 135 | char  *argv[];
135          scompile(stmp, NULL, 0);
136          sprintf(stmp, "%s(t)=%s;", RNAME, argv[4]);
137          scompile(stmp, NULL, 0);
138 <        nseg = atoi(argv[5]);
138 >        nseg = eval(argv[5]) + .5;
139          if (nseg <= 0)
140                  goto userror;
141          modname = smooth ? "Phong" : argv[1];
142  
143          fputs("# ", stdout);
144          printargs(argc, argv, stdout);
145 <        eclock = 0;
145 >        doptimize(1);
146 >        eclock++;
147  
148          lastnz = lastnr = 0.0;
149          t = 0.0;
# Line 164 | Line 178 | char  *argv[];
178                          printf("0\n4\n");
179                          if (orient&(UP|DOWN)) {
180                                  t = (nextnz - lastnz)/(z - lastz);
181 <                                printf("\t%15.9g\t%15.9g\n",
181 >                                printf("\t%18.12g\t%18.12g\n",
182                                                  t, lastnz - t*lastz);
183                          } else
184                                  printf("\t0\t%d\n", orient&IN ? 1 : -1);
185                          if (orient&(OUT|IN))  {
186                                  t = (nextnr - lastnr)/(r - lastr);
187 <                                printf("\t%15.9g\t%15.9g\n",
187 >                                printf("\t%18.12g\t%18.12g\n",
188                                                  t, lastnr - t*lastr);
189                          } else
190                                  printf("\t0\t%d\n", orient&UP ? 1 : -1);
# Line 180 | Line 194 | char  *argv[];
194                                          orient&DOWN ? "tube" : "cylinder",
195                                          argv[2], i);
196                          printf("0\n0\n7\n");
197 <                        printf("\t0\t0\t%15.9g\n", lastz);
198 <                        printf("\t0\t0\t%15.9g\n", z);
199 <                        printf("\t%15.9g\n", r);
197 >                        printf("\t0\t0\t%18.12g\n", lastz);
198 >                        printf("\t0\t0\t%18.12g\n", z);
199 >                        printf("\t%18.12g\n", r);
200                  } else if (!(orient&(UP|DOWN))) {
201                          printf("\n%s ring %s.%d\n", modname, argv[2], i);
202                          printf("0\n0\n8\n");
203 <                        printf("\t0\t0\t%15.9g\n", z);
204 <                        printf("\t0\t0\t%15.9g\n", orient&IN ? 1.0 : -1.0);
205 <                        printf("\t%15.9g\t%15.9g\n", lastr, r);
203 >                        printf("\t0\t0\t%18.12g\n", z);
204 >                        printf("\t0\t0\t%18.12g\n", orient&IN ? 1.0 : -1.0);
205 >                        printf("\t%18.12g\t%18.12g\n", lastr, r);
206                  } else {
207                          printf("\n%s %s %s.%d\n", modname,
208                                          orient&DOWN ? "cup" : "cone",
209                                          argv[2], i);
210                          printf("0\n0\n8\n");
211 <                        printf("\t0\t0\t%15.9g\n", lastz);
212 <                        printf("\t0\t0\t%15.9g\n", z);
213 <                        printf("\t%15.9g\t%15.9g\n", lastr, r);
211 >                        printf("\t0\t0\t%18.12g\n", lastz);
212 >                        printf("\t0\t0\t%18.12g\n", z);
213 >                        printf("\t%18.12g\t%18.12g\n", lastr, r);
214                  }
215          endfor:
216                  lastz = z; lastr = r;
# Line 212 | Line 226 | userror:
226                          argv[0]);
227          return 1;
228   }
215
216

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines