33 |
|
#include "view.h" |
34 |
|
#include "random.h" |
35 |
|
#include "paths.h" |
36 |
< |
#include "rtmisc.h" /* myhostname() */ |
36 |
> |
#include "hilbert.h" |
37 |
|
|
38 |
|
|
39 |
|
#define RFTEMPLATE "rfXXXXXX" |
167 |
|
static void |
168 |
|
report(int dummy) /* report progress */ |
169 |
|
{ |
170 |
< |
double u, s; |
170 |
> |
double u, s; |
171 |
|
#ifdef BSD |
172 |
< |
struct rusage rubuf; |
172 |
> |
struct rusage rubuf; |
173 |
|
#else |
174 |
< |
struct tms tbuf; |
175 |
< |
double period; |
174 |
> |
double period = 1.0 / 60.0; |
175 |
> |
struct tms tbuf; |
176 |
|
#endif |
177 |
|
|
178 |
|
tlastrept = time((time_t *)NULL); |
179 |
|
#ifdef BSD |
180 |
|
getrusage(RUSAGE_SELF, &rubuf); |
181 |
< |
u = rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; |
182 |
< |
s = rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; |
181 |
> |
u = rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec*1e-6; |
182 |
> |
s = rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec*1e-6; |
183 |
|
getrusage(RUSAGE_CHILDREN, &rubuf); |
184 |
< |
u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; |
185 |
< |
s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; |
184 |
> |
u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec*1e-6; |
185 |
> |
s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec*1e-6; |
186 |
|
#else |
187 |
|
times(&tbuf); |
188 |
|
#ifdef _SC_CLK_TCK |
189 |
|
period = 1.0 / sysconf(_SC_CLK_TCK); |
190 |
– |
#else |
191 |
– |
period = 1.0 / 60.0; |
190 |
|
#endif |
191 |
|
u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period; |
192 |
|
s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period; |
193 |
|
#endif |
194 |
|
|
195 |
|
sprintf(errmsg, |
196 |
< |
"%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", |
197 |
< |
nrays, pctdone, u/3600., s/3600., |
198 |
< |
(tlastrept-tstart)/3600., myhostname()); |
196 |
> |
"%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s (PID %d)\n", |
197 |
> |
nrays, pctdone, u*(1./3600.), s*(1./3600.), |
198 |
> |
(tlastrept-tstart)*(1./3600.), myhostname(), getpid()); |
199 |
|
eputs(errmsg); |
200 |
|
#ifdef SIGCONT |
201 |
|
signal(SIGCONT, report); |
213 |
|
#endif |
214 |
|
|
215 |
|
|
216 |
< |
extern void |
216 |
> |
void |
217 |
|
rpict( /* generate image(s) */ |
218 |
|
int seq, |
219 |
|
char *pout, |
800 |
|
} |
801 |
|
|
802 |
|
static int |
803 |
< |
pixnumber( /* compute pixel index (brushed) */ |
803 |
> |
pixnumber( /* compute pixel index (screen door) */ |
804 |
|
int x, |
805 |
|
int y, |
806 |
|
int xres, |
807 |
|
int yres |
808 |
|
) |
809 |
|
{ |
810 |
< |
x -= y; |
811 |
< |
while (x < 0) |
812 |
< |
x += xres; |
813 |
< |
return((((x>>2)*yres + y) << 2) + (x & 3)); |
810 |
> |
unsigned nbits = 0; |
811 |
> |
bitmask_t coord[2]; |
812 |
> |
|
813 |
> |
if (xres < yres) xres = yres; |
814 |
> |
while (xres > 0) { |
815 |
> |
xres >>= 1; |
816 |
> |
++nbits; |
817 |
> |
} |
818 |
> |
coord[0] = x; coord[1] = y; |
819 |
> |
return ((int)hilbert_c2i(2, nbits, coord)); |
820 |
|
} |