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.7 by schorsch, Sun Nov 16 10:29:38 2003 UTC vs.
Revision 2.14 by greg, Sat Dec 28 18:05:14 2019 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"
20   #include  "calcomp.h"
21  
22   #define  ZNAME          "Z`SYS`"                /* z function name */
# Line 46 | Line 46 | double  *nzp, *nrp, z0, r0, z1, r1;
46   }
47  
48  
49 void
50 eputs(msg)
51 char  *msg;
52 {
53        fputs(msg, stderr);
54 }
55
56
57 void
58 wputs(msg)
59 char  *msg;
60 {
61        eputs(msg);
62 }
63
64
65 void
66 quit(code)
67 int  code;
68 {
69        exit(code);
70 }
71
72
73 void
74 printhead(ac, av)               /* print command header */
75 register int  ac;
76 register char  **av;
77 {
78        putchar('#');
79        while (ac--) {
80                putchar(' ');
81                fputs(*av++, stdout);
82        }
83        putchar('\n');
84 }
85
86
49   double
50   l_hermite(char *nm)
51   {
# Line 136 | Line 98 | char  *argv[];
98          int  i, nseg;
99          int  orient;
100  
101 +        esupport |= E_VARIABLE|E_FUNCTION|E_RCONST;
102 +        esupport &= ~(E_OUTCHAN|E_INCHAN);
103          varset("PI", ':', PI);
104          funset("hermite", 5, ':', l_hermite);
105          funset("bezier", 5, ':', l_bezier);
# Line 147 | Line 111 | char  *argv[];
111          for (i = 6; i < argc; i++)
112                  if (!strcmp(argv[i], "-e"))
113                          scompile(argv[++i], NULL, 0);
114 <                else if (!strcmp(argv[i], "-f"))
115 <                        fcompile(argv[++i]);
116 <                else if (!strcmp(argv[i], "-s"))
114 >                else if (!strcmp(argv[i], "-f")) {
115 >                        char  *fpath = getpath(argv[++i], getrlibpath(), 0);
116 >                        if (fpath == NULL) {
117 >                                fprintf(stderr, "%s: cannot find file '%s'\n",
118 >                                                argv[0], argv[i]);
119 >                                quit(1);
120 >                        }
121 >                        fcompile(fpath);
122 >                } else if (!strcmp(argv[i], "-s"))
123                          smooth = 1;
124                  else
125                          goto userror;
# Line 158 | Line 128 | char  *argv[];
128          scompile(stmp, NULL, 0);
129          sprintf(stmp, "%s(t)=%s;", RNAME, argv[4]);
130          scompile(stmp, NULL, 0);
131 <        nseg = atoi(argv[5]);
131 >        nseg = eval(argv[5]) + .5;
132          if (nseg <= 0)
133                  goto userror;
134          modname = smooth ? "Phong" : argv[1];
135  
136 <        printhead(argc, argv);
136 >        fputs("# ", stdout);
137 >        printargs(argc, argv, stdout);
138          eclock = 0;
139  
140          lastnz = lastnr = 0.0;
# Line 199 | Line 170 | char  *argv[];
170                          printf("0\n4\n");
171                          if (orient&(UP|DOWN)) {
172                                  t = (nextnz - lastnz)/(z - lastz);
173 <                                printf("\t%15.9g\t%15.9g\n",
173 >                                printf("\t%18.12g\t%18.12g\n",
174                                                  t, lastnz - t*lastz);
175                          } else
176                                  printf("\t0\t%d\n", orient&IN ? 1 : -1);
177                          if (orient&(OUT|IN))  {
178                                  t = (nextnr - lastnr)/(r - lastr);
179 <                                printf("\t%15.9g\t%15.9g\n",
179 >                                printf("\t%18.12g\t%18.12g\n",
180                                                  t, lastnr - t*lastr);
181                          } else
182                                  printf("\t0\t%d\n", orient&UP ? 1 : -1);
# Line 215 | Line 186 | char  *argv[];
186                                          orient&DOWN ? "tube" : "cylinder",
187                                          argv[2], i);
188                          printf("0\n0\n7\n");
189 <                        printf("\t0\t0\t%15.9g\n", lastz);
190 <                        printf("\t0\t0\t%15.9g\n", z);
191 <                        printf("\t%15.9g\n", r);
189 >                        printf("\t0\t0\t%18.12g\n", lastz);
190 >                        printf("\t0\t0\t%18.12g\n", z);
191 >                        printf("\t%18.12g\n", r);
192                  } else if (!(orient&(UP|DOWN))) {
193                          printf("\n%s ring %s.%d\n", modname, argv[2], i);
194                          printf("0\n0\n8\n");
195 <                        printf("\t0\t0\t%15.9g\n", z);
196 <                        printf("\t0\t0\t%15.9g\n", orient&IN ? 1.0 : -1.0);
197 <                        printf("\t%15.9g\t%15.9g\n", lastr, r);
195 >                        printf("\t0\t0\t%18.12g\n", z);
196 >                        printf("\t0\t0\t%18.12g\n", orient&IN ? 1.0 : -1.0);
197 >                        printf("\t%18.12g\t%18.12g\n", lastr, r);
198                  } else {
199                          printf("\n%s %s %s.%d\n", modname,
200                                          orient&DOWN ? "cup" : "cone",
201                                          argv[2], i);
202                          printf("0\n0\n8\n");
203 <                        printf("\t0\t0\t%15.9g\n", lastz);
204 <                        printf("\t0\t0\t%15.9g\n", z);
205 <                        printf("\t%15.9g\t%15.9g\n", lastr, r);
203 >                        printf("\t0\t0\t%18.12g\n", lastz);
204 >                        printf("\t0\t0\t%18.12g\n", z);
205 >                        printf("\t%18.12g\t%18.12g\n", lastr, r);
206                  }
207          endfor:
208                  lastz = z; lastr = r;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines