Back to index

radiance  4R0+20100331
Classes | Defines | Typedefs | Functions | Variables
rpaint.h File Reference
#include "driver.h"
#include "view.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pnode
struct  RECT

Defines

#define DL   0 /* down left */
#define DR   1 /* down right */
#define UL   2 /* up left */
#define UR   3 /* up right */
#define newptree()   (PNODE *)calloc(4, sizeof(PNODE))

Typedefs

typedef short COORD
typedef struct pnode PNODE

Functions

void devopen (char *dname)
void devclose (void)
void printdevices (void)
void command (char *prompt)
void rsample (void)
int refine (PNODE *p, int pd)
void getframe (char *s)
void getrepaint (char *s)
void getview (char *s)
void lastview (char *s)
void saveview (char *s)
void loadview (char *s)
void getfocus (char *s)
void getaim (char *s)
void getmove (char *s)
void getrotate (char *s)
void getpivot (char *s)
void getexposure (char *s)
int getparam (char *str, char *dsc, int typ, void *p)
void setparam (char *s)
void traceray (char *s)
void writepict (char *s)
int getrect (char *s, RECT *r)
int getinterest (char *s, int direc, FVECT vec, double *mp)
float * greyof (COLOR col)
int paint (PNODE *p)
int waitrays (void)
void newimage (char *s)
void redraw (void)
void repaint (int xmin, int ymin, int xmax, int ymax)
void paintrect (PNODE *p, RECT *r)
PNODEfindrect (int x, int y, PNODE *p, int pd)
void compavg (PNODE *p)
void scalepict (PNODE *p, double sf)
void getpictcolrs (int yoff, COLR *scan, PNODE *p, int xsiz, int ysiz)
void freepkids (PNODE *p)
void newview (VIEW *vp)
void moveview (double angle, double elev, double mag, FVECT vc)
void pcopy (PNODE *p1, PNODE *p2)
void zoomview (VIEW *vp, double zf)

Variables

PNODE ptrunk
VIEW ourview
VIEW oldview
int hresolu
int vresolu
int newparam
char * dvcname
char rifname []
int psample
double maxdiff
int greyscale
int pdepth
RECT pframe
double exposure
struct driverdev
int nproc

Class Documentation

struct pnode

Definition at line 17 of file rpaint.h.

Collaboration diagram for pnode:
Class Members
struct pnode * kid
COLOR v
COORD x
COORD xmax
COORD xmin
COORD y
COORD ymax
COORD ymin
struct RECT

Definition at line 32 of file rpaint.h.

Class Members
COORD d
COORD l
COORD r
COORD u

Define Documentation

#define DL   0 /* down left */

Definition at line 25 of file rpaint.h.

#define DR   1 /* down right */

Definition at line 26 of file rpaint.h.

#define newptree ( )    (PNODE *)calloc(4, sizeof(PNODE))

Definition at line 30 of file rpaint.h.

#define UL   2 /* up left */

Definition at line 27 of file rpaint.h.

#define UR   3 /* up right */

Definition at line 28 of file rpaint.h.


Typedef Documentation

typedef short COORD

Definition at line 15 of file rpaint.h.

typedef struct pnode PNODE

Function Documentation

void command ( char *  prompt)

Definition at line 113 of file rview.c.

{
#define        badcom(s)    strncmp(s, inpbuf, args-inpbuf-1)
       char  inpbuf[256];
       char  *args;
again:
       (*dev->comin)(inpbuf, prompt);            /* get command + arguments */
       for (args = inpbuf; *args && *args != ' '; args++)
              ;
       if (*args) *args++ = '\0';
       else *++args = '\0';

       if (waitrays() < 0)                /* clear ray queue */
              quit(1);
       
       switch (inpbuf[0]) {
       case 'f':                          /* new frame (|focus|free) */
              if (badcom("frame")) {
                     if (badcom("focus")) {
                            if (badcom("free"))
                                   goto commerr;
                            free_objmem();
                            break;
                     }
                     getfocus(args);
                     break;
              }
              getframe(args);
              break;
       case 'v':                          /* view */
              if (badcom("view"))
                     goto commerr;
              getview(args);
              break;
       case 'l':                          /* last view */
              if (badcom("last"))
                     goto commerr;
              lastview(args);
              break;
       case 'V':                          /* save view */
              if (badcom("V"))
                     goto commerr;
              saveview(args);
              break;
       case 'L':                          /* load view */
              if (badcom("L"))
                     goto commerr;
              loadview(args);
              break;
       case 'e':                          /* exposure */
              if (badcom("exposure"))
                     goto commerr;
              getexposure(args);
              break;
       case 's':                          /* set a parameter */
              if (badcom("set")) {
#ifdef SIGTSTP
                     if (!badcom("stop"))
                            goto dostop;
#endif
                     goto commerr;
              }
              setparam(args);
              break;
       case 'n':                          /* new picture */
              if (badcom("new"))
                     goto commerr;
              newimage(args);
              break;
       case 't':                          /* trace a ray */
              if (badcom("trace"))
                     goto commerr;
              traceray(args);
              break;
       case 'a':                          /* aim camera */
              if (badcom("aim"))
                     goto commerr;
              getaim(args);
              break;
       case 'm':                          /* move camera (or memstats) */
              if (badcom("move"))
#ifdef MSTATS
              {
                     if (badcom("memory"))
                            goto commerr;
                     printmemstats(stderr);
                     break;
              }
#else
                     goto commerr;
#endif
              getmove(args);
              break;
       case 'r':                          /* rotate/repaint */
              if (badcom("rotate")) {
                     if (badcom("repaint")) {
                            if (badcom("redraw"))
                                   goto commerr;
                            redraw();
                            break;
                     }
                     getrepaint(args);
                     break;
              }
              getrotate(args);
              break;
       case 'p':                          /* pivot view */
              if (badcom("pivot")) {
                     if (badcom("pause"))
                            goto commerr;
                     goto again;
              }
              getpivot(args);
              break;
       case CTRL('R'):                           /* redraw */
              redraw();
              break;
       case 'w':                          /* write */
              if (badcom("write"))
                     goto commerr;
              writepict(args);
              break;
       case 'q':                          /* quit */
              if (badcom("quit"))
                     goto commerr;
              quit(0);
       case CTRL('C'):                           /* interrupt */
              goto again;
#ifdef SIGTSTP
       case CTRL('Z'):;                   /* stop */
dostop:
              devclose();
              kill(0, SIGTSTP);
              /* pc stops here */
              devopen(dvcname);
              redraw();
              break;
#endif
       case '\0':                         /* continue */
              break;
       default:;
commerr:
              if (iscntrl(inpbuf[0]))
                     sprintf(errmsg, "^%c: unknown control",
                                   inpbuf[0]|0100);
              else
                     sprintf(errmsg, "%s: unknown command", inpbuf);
              error(COMMAND, errmsg);
              break;
       }
#undef badcom
}

Here is the call graph for this function:

Here is the caller graph for this function:

void compavg ( PNODE p)

Definition at line 401 of file rv3.c.

{
       int    i, navg;
       
       if (p->kid == NULL)
              return;

       setcolor(p->v, .0, .0, .0);
       navg = 0;
       for (i = 0; i < 4; i++) {
              if (p->kid[i].xmin >= p->kid[i].xmax) continue;
              if (p->kid[i].ymin >= p->kid[i].ymax) continue;
              compavg(p->kid+i);
              addcolor(p->v, p->kid[i].v);
              navg++;
       }
       if (navg > 1)
              scalecolor(p->v, 1./navg);
}

Here is the call graph for this function:

void devclose ( void  )

Definition at line 65 of file rview.c.

{
       if (dev != NULL)
              (*dev->close)();
       dev = NULL;
}

Here is the caller graph for this function:

void devopen ( char *  dname)

Definition at line 38 of file rview.c.

{
       extern char  *progname, *octname;
       char  *id;
       int  i;

       id = octname!=NULL ? octname : progname;
                                          /* check device table */
       for (i = 0; devtable[i].name; i++)
              if (!strcmp(dname, devtable[i].name)) {
                     if ((dev = (*devtable[i].init)(dname, id)) == NULL) {
                            sprintf(errmsg, "cannot initialize %s", dname);
                            error(USER, errmsg);
                     } else
                            return;
              }
                                          /* not there, try exec */
       if ((dev = comm_init(dname, id)) == NULL) {
              sprintf(errmsg, "cannot start device \"%s\"", dname);
              error(USER, errmsg);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PNODE* findrect ( int  x,
int  y,
PNODE p,
int  pd 
)

Definition at line 368 of file rv3.c.

{
       int  mx, my;

       while (p->kid != NULL && pd--) {

              mx = (p->xmin + p->xmax) >> 1;
              my = (p->ymin + p->ymax) >> 1;

              if (x < mx) {
                     if (y < my) {
                            p = p->kid+DL;
                     } else {
                            p = p->kid+UL;
                     }
              } else {
                     if (y < my) {
                            p = p->kid+DR;
                     } else {
                            p = p->kid+UR;
                     }
              }
       }
       return(p);
}

Here is the caller graph for this function:

void freepkids ( PNODE p)

Definition at line 476 of file rv3.c.

{
       if (p->kid == NULL)
              return;
       freepkids(p->kid+DL);
       freepkids(p->kid+DR);
       freepkids(p->kid+UL);
       freepkids(p->kid+UR);
       free((void *)p->kid);
       p->kid = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getaim ( char *  s)

Definition at line 273 of file rv2.c.

{
       VIEW  nv = ourview;
       double  zfact;

       if (getinterest(s, 1, nv.vdir, &zfact) < 0)
              return;
       zoomview(&nv, zfact);
       newview(&nv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getexposure ( char *  s)

Definition at line 383 of file rv2.c.

{
       char  buf[128];
       char  *cp;
       int  x, y;
       PNODE  *p = &ptrunk;
       int  adapt = 0;
       double  e = 1.0;

       for (cp = s; isspace(*cp); cp++)
              ;
       if (*cp == '@') {
              adapt++;
              while (isspace(*++cp))
                     ;
       }
       if (*cp == '\0') {          /* normalize to point */
              if (dev->getcur == NULL)
                     return;
              (*dev->comout)("Pick point for exposure\n");
              if ((*dev->getcur)(&x, &y) == ABORT)
                     return;
              p = findrect(x, y, &ptrunk, -1);
       } else {
              if (*cp == '=') {    /* absolute setting */
                     p = NULL;
                     e = 1.0/exposure;
                     for (cp++; isspace(*cp); cp++)
                            ;
                     if (*cp == '\0') {   /* interactive */
                            sprintf(buf, "exposure (%f): ", exposure);
                            (*dev->comout)(buf);
                            (*dev->comin)(buf, NULL);
                            for (cp = buf; isspace(*cp); cp++)
                                   ;
                            if (*cp == '\0')
                                   return;
                     }
              }
              if (*cp == '+' || *cp == '-')      /* f-stops */
                     e *= pow(2.0, atof(cp));
              else                        /* multiplier */
                     e *= atof(cp);
       }
       if (p != NULL) {            /* relative setting */
              compavg(p);
              if (bright(p->v) < 1e-15) {
                     error(COMMAND, "cannot normalize to zero");
                     return;
              }
              if (adapt)
                     e *= 106./pow(1.219+pow(luminance(p->v)/exposure,.4),2.5)/exposure;
              else
                     e *= 0.5 / bright(p->v);
       }
       if (e <= FTINY || fabs(1.0 - e) <= FTINY)
              return;
       scalepict(&ptrunk, e);
       exposure *= e;
       redraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getfocus ( char *  s)

Definition at line 288 of file rv2.c.

{
       char  buf[64];
       double dist;

       if (sscanf(s, "%lf", &dist) < 1) {
              int    x, y;
              RAY    thisray;
              if (dev->getcur == NULL)
                     return;
              (*dev->comout)("Pick focus point\n");
              if ((*dev->getcur)(&x, &y) == ABORT)
                     return;
              if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
                     &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) {
                     error(COMMAND, "not on image");
                     return;
              }
              rayorigin(&thisray, PRIMARY, NULL, NULL);
              if (!localhit(&thisray, &thescene)) {
                     error(COMMAND, "not a local object");
                     return;
              }
              dist = thisray.rot;
       } else if (dist <= .0) {
              error(COMMAND, "focus distance must be positive");
              return;
       }
       ourview.vdist = dist;
       sprintf(buf, "Focus distance set to %f\n", dist);
       (*dev->comout)(buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getframe ( char *  s)

Definition at line 40 of file rv2.c.

{
       if (getrect(s, &pframe) < 0)
              return;
       pdepth = 0;
}

Here is the call graph for this function:

int getinterest ( char *  s,
int  direc,
FVECT  vec,
double *  mp 
)

Definition at line 83 of file rv3.c.

{
       int  x, y;
       RAY  thisray;
       int  i;

       if (sscanf(s, "%lf", mp) != 1)
              *mp = 1.0;
       else if (*mp < -FTINY)             /* negative zoom is reduction */
              *mp = -1.0 / *mp;
       else if (*mp <= FTINY) {    /* too small */
              error(COMMAND, "illegal magnification");
              return(-1);
       }
       if (!sscanvec(sskip(s), vec)) {
              if (dev->getcur == NULL)
                     return(-1);
              (*dev->comout)("Pick view center\n");
              if ((*dev->getcur)(&x, &y) == ABORT)
                     return(-1);
              if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
                     &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) {
                     error(COMMAND, "not on image");
                     return(-1);
              }
              if (!direc || ourview.type == VT_PAR) {
                     rayorigin(&thisray, PRIMARY, NULL, NULL);
                     if (!localhit(&thisray, &thescene)) {
                            error(COMMAND, "not a local object");
                            return(-1);
                     }
              }
              if (direc)
                     if (ourview.type == VT_PAR)
                            for (i = 0; i < 3; i++)
                                   vec[i] = thisray.rop[i] - ourview.vp[i];
                     else
                            VCOPY(vec, thisray.rdir);
              else
                     VCOPY(vec, thisray.rop);
       } else if (direc) {
              for (i = 0; i < 3; i++)
                     vec[i] -= ourview.vp[i];
              if (normalize(vec) == 0.0) {
                     error(COMMAND, "point at view origin");
                     return(-1);
              }
       }
       return(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getmove ( char *  s)

Definition at line 325 of file rv2.c.

{
       FVECT  vc;
       double  mag;

       if (getinterest(s, 0, vc, &mag) < 0)
              return;
       moveview(0.0, 0.0, mag, vc);
}

Here is the call graph for this function:

int getparam ( char *  str,
char *  dsc,
int  typ,
void *  p 
)

Definition at line 451 of file rv2.c.

{
       MyUptr  ptr = (MyUptr)p;
       int  i0;
       double  d0, d1, d2;
       char  buf[48];

       switch (typ) {
       case 'i':                   /* integer */
              if (sscanf(str, "%d", &i0) != 1) {
                     (*dev->comout)(dsc);
                     sprintf(buf, " (%d): ", ptr->i);
                     (*dev->comout)(buf);
                     (*dev->comin)(buf, NULL);
                     if (sscanf(buf, "%d", &i0) != 1)
                            return(0);
              }
              if (ptr->i == i0)
                     return(0);
              ptr->i = i0;
              break;
       case 'r':                   /* real */
              if (sscanf(str, "%lf", &d0) != 1) {
                     (*dev->comout)(dsc);
                     sprintf(buf, " (%.6g): ", ptr->d);
                     (*dev->comout)(buf);
                     (*dev->comin)(buf, NULL);
                     if (sscanf(buf, "%lf", &d0) != 1)
                            return(0);
              }
              if (FEQ(ptr->d, d0))
                     return(0);
              ptr->d = d0;
              break;
       case 'b':                   /* boolean */
              if (sscanf(str, "%1s", buf) != 1) {
                     (*dev->comout)(dsc);
                     sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n');
                     (*dev->comout)(buf);
                     (*dev->comin)(buf, NULL);
                     if (buf[0] == '\0')
                            return(0);
              }
              if (strchr("yY+1tTnN-0fF", buf[0]) == NULL)
                     return(0);
              i0 = strchr("yY+1tT", buf[0]) != NULL;
              if (ptr->i == i0)
                     return(0);
              ptr->i = i0;
              break;
       case 'C':                   /* color */
              if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
                     (*dev->comout)(dsc);
                     sprintf(buf, " (%.6g %.6g %.6g): ",
                                   colval(ptr->C,RED),
                                   colval(ptr->C,GRN),
                                   colval(ptr->C,BLU));
                     (*dev->comout)(buf);
                     (*dev->comin)(buf, NULL);
                     if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3)
                            return(0);
              }
              if (FEQ(colval(ptr->C,RED), d0) &&
                            FEQ(colval(ptr->C,GRN), d1) &&
                            FEQ(colval(ptr->C,BLU), d2))
                     return(0);
              setcolor(ptr->C, d0, d1, d2);
              break;
       default:
              return(0);           /* shouldn't happen */
       }
       newparam++;
       return(1);
}

Here is the caller graph for this function:

void getpictcolrs ( int  yoff,
COLR scan,
PNODE p,
int  xsiz,
int  ysiz 
)

Definition at line 443 of file rv3.c.

{
       int  mx;
       int  my;

       if (p->kid == NULL) {                     /* do this node */
              setcolr(scan[0], colval(p->v,RED),
                            colval(p->v,GRN),
                            colval(p->v,BLU));
              for (mx = 1; mx < xsiz; mx++)
                     copycolr(scan[mx], scan[0]);
              return;
       }
                                          /* do kids */
       mx = xsiz >> 1;
       my = ysiz >> 1;
       if (yoff < my) {
              getpictcolrs(yoff, scan, p->kid+DL, mx, my);
              getpictcolrs(yoff, scan+mx, p->kid+DR, xsiz-mx, my);
       } else {
              getpictcolrs(yoff-my, scan, p->kid+UL, mx, ysiz-my);
              getpictcolrs(yoff-my, scan+mx, p->kid+UR, xsiz-mx, ysiz-my);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getpivot ( char *  s)

Definition at line 364 of file rv2.c.

{
       FVECT  vc;
       double  angle, elev, mag;

       elev = 0.0;
       if (sscanf(s, "%lf %lf", &angle, &elev) < 1) {
              error(COMMAND, "missing angle");
              return;
       }
       if (getinterest(sskip2(s,2), 0, vc, &mag) < 0)
              return;
       moveview(angle, elev, mag, vc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int getrect ( char *  s,
RECT r 
)

Definition at line 35 of file rv3.c.

{
       int  x0, y0, x1, y1;

       if (*s && !strncmp(s, "all", strlen(s))) {
              r->l = r->d = 0;
              r->r = hresolu;
              r->u = vresolu;
              return(0);
       }
       if (sscanf(s, "%d %d %d %d", &x0, &y0, &x1, &y1) != 4) {
              if (dev->getcur == NULL)
                     return(-1);
              (*dev->comout)("Pick first corner\n");
              if ((*dev->getcur)(&x0, &y0) == ABORT)
                     return(-1);
              (*dev->comout)("Pick second corner\n");
              if ((*dev->getcur)(&x1, &y1) == ABORT)
                     return(-1);
       }
       if (x0 < x1) {
              r->l = x0;
              r->r = x1;
       } else {
              r->l = x1;
              r->r = x0;
       }
       if (y0 < y1) {
              r->d = y0;
              r->u = y1;
       } else {
              r->d = y1;
              r->u = y0;
       }
       if (r->l < 0) r->l = 0;
       if (r->d < 0) r->d = 0;
       if (r->r > hresolu) r->r = hresolu;
       if (r->u > vresolu) r->u = vresolu;
       if (r->l > r->r) r->l = r->r;
       if (r->d > r->u) r->d = r->u;
       return(0);
}

Here is the caller graph for this function:

void getrepaint ( char *  s)

Definition at line 51 of file rv2.c.

{
       RECT  box;

       if (getrect(s, &box) < 0)
              return;
       paintrect(&ptrunk, &box);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getrotate ( char *  s)

Definition at line 339 of file rv2.c.

{
       VIEW  nv = ourview;
       FVECT  v1;
       double  angle, elev, zfact;
       
       elev = 0.0; zfact = 1.0;
       if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) {
              error(COMMAND, "missing angle");
              return;
       }
       spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
       if (elev != 0.0) {
              fcross(v1, nv.vdir, ourview.vup);
              normalize(v1);
              spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
       }
       zoomview(&nv, zfact);
       newview(&nv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getview ( char *  s)

Definition at line 64 of file rv2.c.

{
       FILE  *fp;
       char  buf[128];
       char  *fname;
       int  change = 0;
       VIEW  nv = ourview;

       while (isspace(*s))
              s++;
       if (*s == '-') {                   /* command line parameters */
              if (sscanview(&nv, s))
                     newview(&nv);
              else
                     error(COMMAND, "bad view option(s)");
              return;
       }
       if (sscanf(s, "%s", buf) == 1) {   /* write parameters to a file */
              if ((fname = getpath(buf, NULL, 0)) == NULL ||
                            (fp = fopen(fname, "a")) == NULL) {
                     sprintf(errmsg, "cannot open \"%s\"", buf);
                     error(COMMAND, errmsg);
                     return;
              }
              fputs(progname, fp);
              fprintview(&ourview, fp);
              fputs(sskip(s), fp);
              putc('\n', fp);
              fclose(fp);
              return;
       }
       sprintf(buf, "view type (%c): ", ourview.type);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (buf[0] && buf[0] != ourview.type) {
              nv.type = buf[0];
              change++;
       }
       sprintf(buf, "view point (%.6g %.6g %.6g): ",
                     ourview.vp[0], ourview.vp[1], ourview.vp[2]);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (sscanvec(buf, nv.vp))
              change++;
       sprintf(buf, "view direction (%.6g %.6g %.6g): ",
                     ourview.vdir[0]*ourview.vdist,
                     ourview.vdir[1]*ourview.vdist,
                     ourview.vdir[2]*ourview.vdist);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (sscanvec(buf, nv.vdir)) {
              nv.vdist = 1.;
              change++;
       }
       sprintf(buf, "view up (%.6g %.6g %.6g): ",
                     ourview.vup[0], ourview.vup[1], ourview.vup[2]);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (sscanvec(buf, nv.vup))
              change++;
       sprintf(buf, "view horiz and vert size (%.6g %.6g): ",
                     ourview.horiz, ourview.vert);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
              change++;
       sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ",
                     ourview.vfore, ourview.vaft);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2)
              change++;
       sprintf(buf, "view shift and lift (%.6g %.6g): ",
                     ourview.hoff, ourview.voff);
       (*dev->comout)(buf);
       (*dev->comin)(buf, NULL);
       if (buf[0] == CTRL('C')) return;
       if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
              change++;
       if (change)
              newview(&nv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

float* greyof ( COLOR  col)

Definition at line 141 of file rv3.c.

{
       static COLOR  gcol;
       double  b;

       b = bright(col);
       setcolor(gcol, b, b, b);
       return(gcol);
}

Here is the caller graph for this function:

void lastview ( char *  s)

Definition at line 157 of file rv2.c.

{
       char  buf[128];
       char  *fname;
       int  success;
       VIEW  nv;

       if (sscanf(s, "%s", buf) == 1) {   /* get parameters from a file */
              nv = stdview;
              if ((fname = getpath(buf, "", R_OK)) == NULL ||
                            (success = viewfile(fname, &nv, NULL)) == -1) {
                     sprintf(errmsg, "cannot open \"%s\"", buf);
                     error(COMMAND, errmsg);
                     return;
              }
              if (!success)
                     error(COMMAND, "wrong file format");
              else
                     newview(&nv);
              return;
       }
       if (oldview.type == 0) {    /* no old view! */
              error(COMMAND, "no previous view");
              return;
       }
       nv = ourview;
       ourview = oldview;
       oldview = nv;
       newimage(NULL);
}

Here is the call graph for this function:

void loadview ( char *  s)

Definition at line 230 of file rv2.c.

{
       char  buf[512];
       char  *fname;
       FILE  *fp;
       VIEW  nv;

       strcpy(buf, "rad -n -s -V -v ");
       if (sscanf(s, "%s", buf+strlen(buf)) == 1)
              s = sskip(s);
       else
              strcat(buf, "1");
       if (*s)
              atos(rifname, sizeof(rifname), s);
       else if (rifname[0] == '\0') {
              error(COMMAND, "no previous rad file");
              return;
       }
       if ((fname = getpath(rifname, "", R_OK)) == NULL) {
              sprintf(errmsg, "cannot access \"%s\"", rifname);
              error(COMMAND, errmsg);
              return;
       }
       sprintf(buf+strlen(buf), " %s", fname);
       if ((fp = popen(buf, "r")) == NULL) {
              error(COMMAND, "cannot run rad");
              return;
       }
       buf[0] = '\0';
       fgets(buf, sizeof(buf), fp);
       pclose(fp);
       nv = stdview;
       if (!sscanview(&nv, buf)) {
              error(COMMAND, "rad error -- no such view?");
              return;
       }
       newview(&nv);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void moveview ( double  angle,
double  elev,
double  mag,
FVECT  vc 
)

Definition at line 510 of file rv3.c.

{
       double  d;
       FVECT  v1;
       VIEW  nv = ourview;
       int  i;

       spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
       if (elev != 0.0) {
              fcross(v1, ourview.vup, nv.vdir);
              normalize(v1);
              spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
       }
       if (nv.type == VT_PAR) {
              nv.horiz /= mag;
              nv.vert /= mag;
              d = 0.0;                    /* don't move closer */
              for (i = 0; i < 3; i++)
                     d += (vc[i] - ourview.vp[i])*ourview.vdir[i];
       } else {
              d = sqrt(dist2(ourview.vp, vc)) / mag;
              if (nv.vfore > FTINY) {
                     nv.vfore += d - d*mag;
                     if (nv.vfore < 0.0) nv.vfore = 0.0;
              }
              if (nv.vaft > FTINY) {
                     nv.vaft += d - d*mag;
                     if (nv.vaft <= nv.vfore) nv.vaft = 0.0;
              }
              nv.vdist /= mag;
       }
       for (i = 0; i < 3; i++)
              nv.vp[i] = vc[i] - d*nv.vdir[i];
       newview(&nv);
}

Here is the call graph for this function:

void newimage ( char *  s)

Definition at line 263 of file rv3.c.

{
       extern int    ray_pnprocs;
       int           newnp;
                                          /* change in nproc? */
       if (s != NULL && sscanf(s, "%d", &newnp) == 1 &&
                     (newnp > 0) & (newnp != nproc)) {
              if (!newparam) {
                     if (newnp == 1)
                            ray_pclose(0);
                     else if (newnp < ray_pnprocs)
                            ray_pclose(ray_pnprocs - newnp);
                     else
                            ray_popen(newnp - ray_pnprocs);
              }
              nproc = newnp;
       }
                                          /* free old image */
       freepkids(&ptrunk);
                                          /* compute resolution */
       hresolu = dev->xsiz;
       vresolu = dev->ysiz;
       normaspect(viewaspect(&ourview), &dev->pixaspect, &hresolu, &vresolu);
       ptrunk.xmin = ptrunk.ymin = pframe.l = pframe.d = 0;
       ptrunk.xmax = pframe.r = hresolu;
       ptrunk.ymax = pframe.u = vresolu;
       pdepth = 0;
                                          /* clear device */
       (*dev->clear)(hresolu, vresolu);

       if (newparam) {                           /* (re)start rendering procs */
              if (ray_pnprocs > 0)
                     ray_pclose(0);
              if (nproc > 1)
                     ray_popen(nproc);
              newparam = 0;
       }
       niflush = 0;                       /* get first value */
       paint(&ptrunk);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void newview ( VIEW vp)

Definition at line 492 of file rv3.c.

{
       char  *err;

       if ((err = setview(vp)) != NULL) {
              sprintf(errmsg, "view not set - %s", err);
              error(COMMAND, errmsg);
       } else if (memcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) {
              oldview = ourview;
              ourview = *vp;
              newimage(NULL);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int paint ( PNODE p)

Definition at line 175 of file rv3.c.

{
       static RAY  thisray;
       double  h, v;

       if ((p->xmax <= p->xmin) | (p->ymax <= p->ymin)) {      /* empty */
              p->x = p->xmin;
              p->y = p->ymin;
              setcolor(p->v, 0.0, 0.0, 0.0);
              return(0);
       }
                                          /* jitter ray direction */
       p->x = h = p->xmin + (p->xmax-p->xmin)*frandom();
       p->y = v = p->ymin + (p->ymax-p->ymin)*frandom();
       
       if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview,
                     h/hresolu, v/vresolu)) < -FTINY) {
              setcolor(thisray.rcol, 0.0, 0.0, 0.0);
       } else if (nproc == 1) {           /* immediate mode */
              ray_trace(&thisray);
       } else {                           /* queuing mode */
              int    rval;
              rayorigin(&thisray, PRIMARY, NULL, NULL);
              thisray.rno = (RNUMBER)p;
              rval = ray_pqueue(&thisray);
              if (!rval)
                     return(0);
              if (rval < 0)
                     return(-1);
              p = (PNODE *)thisray.rno;
       }

       copycolor(p->v, thisray.rcol);
       scalecolor(p->v, exposure);

       recolor(p);                        /* paint it */

       if (dev->flush != NULL) {          /* shall we check for input? */
              static RNUMBER       lastflush = 0;
              RNUMBER              counter = raynum;
              int           flushintvl;
              if (nproc == 1) {
                     counter = nrays;
                     flushintvl = WFLUSH1;
              } else if (ambounce == 0)
                     flushintvl = nproc*WFLUSH;
              else if (niflush < WFLUSH)
                     flushintvl = nproc*niflush/(ambounce+1);
              else
                     flushintvl = nproc*WFLUSH/(ambounce+1);
              if (lastflush > counter)
                     lastflush = 0;              /* counter wrapped */

              if (counter - lastflush >= flushintvl) {
                     lastflush = counter;
                     (*dev->flush)();
                     niflush++;
              }
       }
       return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void paintrect ( PNODE p,
RECT r 
)

Definition at line 335 of file rv3.c.

{
       int  mx, my;

       if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0)
              return;

       if (p->kid == NULL) {
              (*dev->paintr)(greyscale?greyof(p->v):p->v,
                     p->xmin, p->ymin, p->xmax, p->ymax);      /* do this */
              return;
       }
       mx = (p->xmin + p->xmax) >> 1;                          /* do kids */
       my = (p->ymin + p->ymax) >> 1;
       if (mx > r->l) {
              if (my > r->d)
                     paintrect(p->kid+DL, r);
              if (my < r->u)
                     paintrect(p->kid+UL, r);
       }
       if (mx < r->r) {
              if (my > r->d)
                     paintrect(p->kid+DR, r);
              if (my < r->u)
                     paintrect(p->kid+UR, r);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pcopy ( PNODE p1,
PNODE p2 
)

Definition at line 553 of file rv3.c.

{
       copycolor(p2->v, p1->v);
       p2->x = p1->x;
       p2->y = p1->y;
}

Here is the caller graph for this function:

void printdevices ( void  )

Definition at line 74 of file rview.c.

{
       int  i;

       for (i = 0; devtable[i].name; i++)
              printf("%-16s # %s\n", devtable[i].name, devtable[i].descrip);
}

Here is the caller graph for this function:

void redraw ( void  )

Definition at line 308 of file rv3.c.

{
       (*dev->clear)(hresolu, vresolu);
       (*dev->comout)("redrawing...\n");
       repaint(0, 0, hresolu, vresolu);
       (*dev->comout)("\n");
}

Here is the call graph for this function:

int refine ( PNODE p,
int  pd 
)

Definition at line 340 of file rview.c.

{
       int  growth;
       int  mx, my;
       int  i;

       if (dev->inpready)                 /* quit for input */
              return(0);

       if (pd <= 0)                       /* depth limit */
              return(0);

       mx = (p->xmin + p->xmax) >> 1;
       my = (p->ymin + p->ymax) >> 1;
       growth = 0;

       if (p->kid == NULL) {                     /* subdivide */

              if ((p->kid = newptree()) == NULL)
                     return(0);

              p->kid[UR].xmin = mx;
              p->kid[UR].ymin = my;
              p->kid[UR].xmax = p->xmax;
              p->kid[UR].ymax = p->ymax;
              p->kid[UL].xmin = p->xmin;
              p->kid[UL].ymin = my;
              p->kid[UL].xmax = mx;
              p->kid[UL].ymax = p->ymax;
              p->kid[DR].xmin = mx;
              p->kid[DR].ymin = p->ymin;
              p->kid[DR].xmax = p->xmax;
              p->kid[DR].ymax = my;
              p->kid[DL].xmin = p->xmin;
              p->kid[DL].ymin = p->ymin;
              p->kid[DL].xmax = mx;
              p->kid[DL].ymax = my;
              /*
               *  The following paint order can leave a black pixel
               *  if redraw() is called in (*dev->paintr)().
               */
              if (p->x >= mx && p->y >= my)
                     pcopy(p, p->kid+UR);
              else if (paint(p->kid+UR) < 0)
                     quit(1);
              if (p->x < mx && p->y >= my)
                     pcopy(p, p->kid+UL);
              else if (paint(p->kid+UL) < 0)
                     quit(1);
              if (p->x >= mx && p->y < my)
                     pcopy(p, p->kid+DR);
              else if (paint(p->kid+DR) < 0)
                     quit(1);
              if (p->x < mx && p->y < my)
                     pcopy(p, p->kid+DL);
              else if (paint(p->kid+DL) < 0)
                     quit(1);

              growth++;
       }
                                          /* do children */
       if (mx > pframe.l) {
              if (my > pframe.d)
                     growth += refine(p->kid+DL, pd-1);
              if (my < pframe.u)
                     growth += refine(p->kid+UL, pd-1);
       }
       if (mx < pframe.r) {
              if (my > pframe.d)
                     growth += refine(p->kid+DR, pd-1);
              if (my < pframe.u)
                     growth += refine(p->kid+UR, pd-1);
       }
       return(growth);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void repaint ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Definition at line 318 of file rv3.c.

{
       RECT  reg;

       reg.l = xmin; reg.r = xmax;
       reg.d = ymin; reg.u = ymax;

       paintrect(&ptrunk, &reg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rsample ( void  )

Definition at line 270 of file rview.c.

{
       int  xsiz, ysiz, y;
       PNODE  *p;
       PNODE  **pl;
       int  x;
       /*
        *     We initialize the bottom row in the image at our current
        * resolution.       During sampling, we check super-pixels to the
        * right and above by calling bigdiff().  If there is a significant
        * difference, we subsample the super-pixels.  The testing process
        * includes initialization of the next row.
        */
       xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
       ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
       pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
       if (pl == NULL)
              return;
       /*
        * Initialize the bottom row.
        */
       pl[0] = findrect(pframe.l, pframe.d, &ptrunk, pdepth);
       for (x = 1; x < xsiz; x++) {
              pl[x] = findrect(pframe.l+((x*hresolu)>>pdepth),
                            pframe.d, &ptrunk, pdepth);
       }
                                          /* sample the image */
       for (y = 0; /* y < ysiz */ ; y++) {
              for (x = 0; x < xsiz-1; x++) {
                     if (dev->inpready || errno == ENOMEM)
                            goto escape;
                     /*
                      * Test super-pixel to the right.
                      */
                     if (pl[x] != pl[x+1] && bigdiff(pl[x]->v,
                                   pl[x+1]->v, maxdiff)) {
                            refine(pl[x], 1);
                            refine(pl[x+1], 1);
                     }
              }
              if (y >= ysiz-1)
                     break;
              for (x = 0; x < xsiz; x++) {
                     if (dev->inpready || errno == ENOMEM)
                            goto escape;
                     /*
                      * Find super-pixel at this position in next row.
                      */
                     p = findrect(pframe.l+((x*hresolu)>>pdepth),
                            pframe.d+(((y+1)*vresolu)>>pdepth),
                                   &ptrunk, pdepth);
                     /*
                      * Test super-pixel in next row.
                      */
                     if (pl[x] != p && bigdiff(pl[x]->v, p->v, maxdiff)) {
                            refine(pl[x], 1);
                            refine(p, 1);
                     }
                     /*
                      * Copy into super-pixel array.
                      */
                     pl[x] = p;
              }
       }
escape:
       free((void *)pl);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void saveview ( char *  s)

Definition at line 192 of file rv2.c.

{
       char  view[64];
       char  *fname;
       FILE  *fp;

       if (*atos(view, sizeof(view), s)) {
              if (isint(view)) {
                     error(COMMAND, "cannot write view by number");
                     return;
              }
              s = sskip(s);
       }
       while (isspace(*s))
              s++;
       if (*s)
              atos(rifname, sizeof(rifname), s);
       else if (rifname[0] == '\0') {
              error(COMMAND, "no previous rad file");
              return;
       }
       if ((fname = getpath(rifname, NULL, 0)) == NULL ||
                     (fp = fopen(fname, "a")) == NULL) {
              sprintf(errmsg, "cannot open \"%s\"", rifname);
              error(COMMAND, errmsg);
              return;
       }
       fputs("view= ", fp);
       fputs(view, fp);
       fprintview(&ourview, fp);
       putc('\n', fp);
       fclose(fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void scalepict ( PNODE p,
double  sf 
)

Definition at line 425 of file rv3.c.

{
       scalecolor(p->v, sf);              /* do this node */

       if (p->kid == NULL)
              return;
                                   /* do children */
       scalepict(p->kid+DL, sf);
       scalepict(p->kid+DR, sf);
       scalepict(p->kid+UL, sf);
       scalepict(p->kid+UR, sf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setparam ( char *  s)

Definition at line 533 of file rv2.c.

{
       int  prev_newp = newparam;
       char  buf[128];
       
       if (s[0] == '\0') {
              (*dev->comout)(
              "aa ab ad ar as av aw b bv dc dv dj ds dt i lr lw me ma mg ms ps pt sj st u: ");
              (*dev->comin)(buf, NULL);
              s = buf;
       }
       switch (s[0]) {
       case 'u':                   /* uncorrelated sampling */
              getparam(s+1, "uncorrelated sampling", 'b',
                            (void *)&rand_samp);
              break;
       case 'l':                   /* limit */
              switch (s[1]) {
              case 'w':                   /* weight */
                     getparam(s+2, "limit weight", 'r',
                                   (void *)&minweight);
                     break;
              case 'r':                   /* reflection */
                     getparam(s+2, "limit reflection", 'i',
                                   (void *)&maxdepth);
                     break;
              default:
                     goto badparam;
              }
              break;
       case 'd':                   /* direct */
              switch (s[1]) {
              case 'j':                   /* jitter */
                     getparam(s+2, "direct jitter", 'r',
                                   (void *)&dstrsrc);
                     break;
              case 'c':                   /* certainty */
                     getparam(s+2, "direct certainty", 'r',
                                   (void *)&shadcert);
                     break;
              case 't':                   /* threshold */
                     getparam(s+2, "direct threshold", 'r',
                                   (void *)&shadthresh);
                     break;
              case 'v':                   /* visibility */
                     getparam(s+2, "direct visibility", 'b',
                                   (void *)&directvis);
                     break;
              case 's':                   /* sampling */
                     getparam(s+2, "direct sampling", 'r',
                                   (void *)&srcsizerat);
                     break;
              default:
                     goto badparam;
              }
              break;
       case 'b':                   /* back faces or black and white */
              switch (s[1]) {
              case 'v':                   /* back face visibility */
                     getparam(s+2, "back face visibility", 'b',
                                   (void *)&backvis);
                     break;
              case '\0':                  /* black and white */
              case ' ':
              case 'y': case 'Y': case 't': case 'T': case '1': case '+':
              case 'n': case 'N': case 'f': case 'F': case '0': case '-':
                     getparam(s+1, "black and white", 'b',
                                   (void *)&greyscale);
                     newparam = prev_newp;
                     break;
              default:
                     goto badparam;
              }
              break;
       case 'i':                   /* irradiance */
              getparam(s+1, "irradiance", 'b',
                            (void *)&do_irrad);
              break;
       case 'a':                   /* ambient */
              switch (s[1]) {
              case 'v':                   /* value */
                     getparam(s+2, "ambient value", 'C',
                                   (void *)ambval);
                     break;
              case 'w':                   /* weight */
                     getparam(s+2, "ambient value weight", 'i',
                                   (void *)&ambvwt);
                     break;
              case 'a':                   /* accuracy */
                     if (getparam(s+2, "ambient accuracy", 'r',
                                   (void *)&ambacc))
                            setambacc(ambacc);
                     break;
              case 'd':                   /* divisions */
                     getparam(s+2, "ambient divisions", 'i',
                                   (void *)&ambdiv);
                     break;
              case 's':                   /* samples */
                     getparam(s+2, "ambient super-samples", 'i',
                                   (void *)&ambssamp);
                     break;
              case 'b':                   /* bounces */
                     getparam(s+2, "ambient bounces", 'i',
                                   (void *)&ambounce);
                     break;
              case 'r':
                     if (getparam(s+2, "ambient resolution", 'i',
                                   (void *)&ambres))
                            setambres(ambres);
                     break;
              default:
                     goto badparam;
              }
              break;
       case 'm':                   /* medium */
              switch (s[1]) {
              case 'e':                   /* extinction coefficient */
                     getparam(s+2, "extinction coefficient", 'C',
                                   (void *)cextinction);
                     break;
              case 'a':                   /* scattering albedo */
                     getparam(s+2, "scattering albedo", 'C',
                                   (void *)salbedo);
                     break;
              case 'g':                   /* scattering eccentricity */
                     getparam(s+2, "scattering eccentricity", 'r',
                                   (void *)&seccg);
                     break;
              case 's':                   /* sampling distance */
                     getparam(s+2, "mist sampling distance", 'r',
                                   (void *)&ssampdist);
                     break;
              default:
                     goto badparam;
              }
              break;
       case 'p':                   /* pixel */
              switch (s[1]) {
              case 's':                   /* sample */
                     if (getparam(s+2, "pixel sample", 'i',
                                   (void *)&psample))
                            pdepth = 0;
                     break;
              case 't':                   /* threshold */
                     if (getparam(s+2, "pixel threshold", 'r',
                                   (void *)&maxdiff))
                            pdepth = 0;
                     break;
              default:
                     goto badparam;
              }
              newparam = prev_newp;
              break;
       case 's':                   /* specular */
              switch (s[1]) {
              case 'j':                   /* jitter */
                     getparam(s+2, "specular jitter", 'r',
                                   (void *)&specjitter);
                     break;
              case 't':                   /* threshold */
                     getparam(s+2, "specular threshold", 'r',
                                   (void *)&specthresh);
                     break;
              default:
                     goto badparam;
              }
              break;
       case '\0':                  /* nothing */
              break;
       default:;
badparam:
              *sskip(s) = '\0';
              sprintf(errmsg, "%s: unknown variable", s);
              error(COMMAND, errmsg);
              break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void traceray ( char *  s)

Definition at line 715 of file rv2.c.

{
       char  buf[128];
       int  x, y;
       OBJREC *ino;
       RAY  thisray;

       thisray.rmax = 0.0;

       if (!sscanvec(s, thisray.rorg) ||
                     !sscanvec(sskip2(s,3), thisray.rdir)) {

              if (dev->getcur == NULL)
                     return;
              (*dev->comout)("Pick ray\n");
              if ((*dev->getcur)(&x, &y) == ABORT)
                     return;

              if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
                     &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) {
                     error(COMMAND, "not on image");
                     return;
              }

       } else if (normalize(thisray.rdir) == 0.0) {
              error(COMMAND, "zero ray direction");
              return;
       }

       ray_trace(&thisray);

       if (thisray.ro == NULL)
              (*dev->comout)("ray hit nothing");
       else {
              OBJREC *mat = NULL;
              OBJREC *mod = NULL;
              char   matspec[256];
              matspec[0] = '\0';
              if (thisray.ro->omod != OVOID) {
                     mod = objptr(thisray.ro->omod);
                     mat = findmaterial(mod);
              }
              if (thisray.rod < 0.0)
                     strcpy(matspec, "back of ");
              if (mod != NULL) {
                     strcat(matspec, mod->oname);
                     if (mat != mod && mat != NULL)
                            sprintf(matspec+strlen(matspec),
                                   " (%s)", mat->oname);
              } else
                     strcat(matspec, VOIDID);
              sprintf(buf, "ray hit %s %s \"%s\"", matspec,
                            ofun[thisray.ro->otype].funame,
                            thisray.ro->oname);
              if ((ino = objptr(thisray.robj)) != thisray.ro)
                     sprintf(buf+strlen(buf), " in %s \"%s\"",
                                   ofun[ino->otype].funame, ino->oname);
              (*dev->comout)(buf);
              (*dev->comin)(buf, NULL);
              if (thisray.rot >= FHUGE)
                     (*dev->comout)("at infinity");
              else {
                     sprintf(buf, "at (%.6g %.6g %.6g) (%.6g)",
                                   thisray.rop[0], thisray.rop[1],
                                   thisray.rop[2], thisray.rt);
                     (*dev->comout)(buf);
              }
              (*dev->comin)(buf, NULL);
              sprintf(buf, "value (%.5g %.5g %.5g) (%.3gL)",
                            colval(thisray.rcol,RED),
                            colval(thisray.rcol,GRN),
                            colval(thisray.rcol,BLU),
                            luminance(thisray.rcol));
              (*dev->comout)(buf);
       }
       (*dev->comin)(buf, NULL);
}

Here is the call graph for this function:

int waitrays ( void  )

Definition at line 241 of file rv3.c.

{
       int    nwaited = 0;
       int    rval;
       RAY    raydone;

       if (nproc <= 1)                           /* immediate mode? */
              return(0);
       while ((rval = ray_presult(&raydone, 0)) > 0) {
              PNODE  *p = (PNODE *)raydone.rno;
              copycolor(p->v, raydone.rcol);
              scalecolor(p->v, exposure);
              recolor(p);
              nwaited++;
       }
       if (rval < 0)
              return(-1);
       return(nwaited);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void writepict ( char *  s)

Definition at line 797 of file rv2.c.

{
       static char  buf[128];
       char  *fname;
       FILE  *fp;
       COLR  *scanline;
       int  y;

       while (isspace(*s))
              s++;
       if (*s)
              atos(buf, sizeof(buf), s);
       else if (buf[0] == '\0') {
              error(COMMAND, "no file");
              return;
       }
       if ((fname = getpath(buf, NULL, 0)) == NULL ||
                     (fp = fopen(fname, "w")) == NULL) {
              sprintf(errmsg, "cannot open \"%s\"", buf);
              error(COMMAND, errmsg);
              return;
       }
       SET_FILE_BINARY(fp);
       (*dev->comout)("writing \"");
       (*dev->comout)(fname);
       (*dev->comout)("\"...\n");
                                          /* write header */
       newheader("RADIANCE", fp);
       fputs(progname, fp);
       fprintview(&ourview, fp);
       if (octname != NULL)
              fprintf(fp, " %s\n", octname);
       else
              putc('\n', fp);
       fprintf(fp, "SOFTWARE= %s\n", VersionID);
       fputnow(fp);
       if (exposure != 1.0)
              fputexpos(exposure, fp);
       if (dev->pixaspect != 1.0)
              fputaspect(dev->pixaspect, fp);
       fputformat(COLRFMT, fp);
       putc('\n', fp);
       fprtresolu(hresolu, vresolu, fp);

       scanline = (COLR *)malloc(hresolu*sizeof(COLR));
       if (scanline == NULL) {
              error(COMMAND, "not enough memory!");
              fclose(fp);
              unlink(fname);
              return;
       }
       for (y = vresolu-1; y >= 0; y--) {
              getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu);
              if (fwritecolrs(scanline, hresolu, fp) < 0)
                     break;
       }
       free((void *)scanline);
       if (fclose(fp) < 0)
              error(COMMAND, "write error");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void zoomview ( VIEW vp,
double  zf 
)

Definition at line 565 of file rv3.c.

{
       switch (vp->type) {
       case VT_PAR:                       /* parallel view */
              vp->horiz /= zf;
              vp->vert /= zf;
              return;
       case VT_ANG:                       /* angular fisheye */
              vp->horiz /= zf;
              if (vp->horiz > 360.)
                     vp->horiz = 360.;
              vp->vert /= zf;
              if (vp->vert > 360.)
                     vp->vert = 360.;
              return;
       case VT_PLS:                       /* planisphere fisheye */
              vp->horiz = sin((PI/180./2.)*vp->horiz) /
                            (1.0 + cos((PI/180./2.)*vp->horiz)) / zf;
              vp->horiz *= vp->horiz;
              vp->horiz = (2.*180./PI)*acos((1. - vp->horiz) /
                                          (1. + vp->horiz));
              vp->vert = sin((PI/180./2.)*vp->vert) /
                            (1.0 + cos((PI/180./2.)*vp->vert)) / zf;
              vp->vert *= vp->vert;
              vp->vert = (2.*180./PI)*acos((1. - vp->vert) /
                                          (1. + vp->vert));
              return;
       case VT_CYL:                       /* cylindrical panorama */
              vp->horiz /= zf;
              if (vp->horiz > 360.)
                     vp->horiz = 360.;
              vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) / (PI/180./2.);
              return;
       case VT_PER:                       /* perspective view */
              vp->horiz = atan(tan(vp->horiz*(PI/180./2.))/zf) /
                            (PI/180./2.);
              vp->vert = atan(tan(vp->vert*(PI/180./2.))/zf) /
                            (PI/180./2.);
              return;
       case VT_HEM:                       /* hemispherical fisheye */
              vp->horiz = sin(vp->horiz*(PI/180./2.))/zf;
              if (vp->horiz >= 1.0-FTINY)
                     vp->horiz = 180.;
              else
                     vp->horiz = asin(vp->horiz) / (PI/180./2.);
              vp->vert = sin(vp->vert*(PI/180./2.))/zf;
              if (vp->vert >= 1.0-FTINY)
                     vp->vert = 180.;
              else
                     vp->vert = asin(vp->vert) / (PI/180./2.);
              return;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct driver* dev

Definition at line 29 of file igraph.c.

char* dvcname

Definition at line 31 of file rvmain.c.

double exposure

Definition at line 31 of file pfilt.c.

int greyscale

Definition at line 36 of file ra_gif.c.

int hresolu

Definition at line 52 of file pinterp.c.

double maxdiff

Definition at line 63 of file rpict.c.

int newparam

Definition at line 35 of file rvmain.c.

int nproc

Definition at line 35 of file rtmain.c.

Definition at line 41 of file rvmain.c.

Definition at line 29 of file pcond.c.

int pdepth

Definition at line 45 of file rvmain.c.

Definition at line 44 of file rvmain.c.

int psample

Definition at line 62 of file rpict.c.

Definition at line 43 of file rvmain.c.

char rifname[]

Definition at line 39 of file rvmain.c.

int vresolu

Definition at line 53 of file pinterp.c.