Back to index

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

Go to the source code of this file.

Classes

struct  packet
struct  PACKHEAD
struct  BEAMLIST
struct  VIEWPOINT

Defines

#define RPACKSIZ   21 /* good packet size */
#define packsiz(nr)   (sizeof(PACKHEAD)+(nr)*sizeof(RAYVAL))
#define packra(p)   ((RAYVAL *)((p)+1))
#define CACHE   0 /* amount of memory to use as cache */
#define DISKSPACE   1 /* how much disk space to use */
#define EYESEP   2 /* eye separation distance */
#define GEOMETRY   3 /* section geometry */
#define GRID   4 /* target grid size */
#define OBSTRUCTIONS   5 /* shall we track obstructions? */
#define OCTREE   6 /* octree file name */
#define PORTS   7 /* section portals */
#define RENDER   8 /* rendering options */
#define REPORT   9 /* report interval and error file */
#define RIF   10 /* rad input file */
#define SECTION   11 /* holodeck section boundaries */
#define TIME   12 /* maximum rendering time */
#define VDIST   13 /* virtual distance calculation */
#define NRHVARS   14 /* number of variables */
#define RHVINIT
#define BS_NEW   1 /* replace current set with new one */
#define BS_ADD   2 /* add to current set */
#define BS_ADJ   3 /* adjust current set quantities */
#define BS_DEL   4 /* delete from current set */
#define BS_MAX   5 /* set to max of old and new */

Typedefs

typedef struct packet PACKET

Functions

void done_packets (PACKET *pl)
void new_rtrace (void)
int done_rtrace (void)
void packrays (float *rod, PACKET *p)
void donerays (PACKET *p, float *rvl)
int getradfile (void)
void report (time_t t)
int start_rtrace (void)
int end_rtrace (void)
PACKETdo_packets (PACKET *pl)
PACKETflush_queue (void)
void init_global (void)
int next_packet (PACKET *p, int n)
void bundle_set (int op, PACKHEAD *clist, int nents)
void disp_open (char *dname)
void disp_packet (register PACKHEAD *p)
int disp_check (int block)
int disp_close (void)
int nextview (VIEW *vp, FILE *fp)
int16 * viewbeams (VIEW *vp, int hr, int vr, BEAMLIST *blp)

Variables

char * progname
char * hdkfile
char froot []
char * outdev
int readinp
int force
int nowarn
int ncprocs
int nprocs
int chunkycmp
VIEWPOINT myeye
time_t starttime
time_t endtime
time_t reporttime
long nraysdone
long npacksdone
int rtargc
char * rtargv []

Class Documentation

struct packet

Definition at line 20 of file rholo.h.

Collaboration diagram for packet:
Class Members
int32 bi
int16 hd
int32 nc
struct packet * next
int32 nr
float * offset
RAYVAL ra
struct PACKHEAD

Definition at line 30 of file rholo.h.

Class Members
int32 bi
int16 hd
int32 nc
int32 nr
struct BEAMLIST

Definition at line 40 of file rholo.h.

Collaboration diagram for BEAMLIST:
Class Members
PACKHEAD * bl
int nb
struct VIEWPOINT

Definition at line 45 of file rholo.h.

Class Members
double rng
FVECT vpt

Define Documentation

#define BS_ADD   2 /* add to current set */

Definition at line 87 of file rholo.h.

#define BS_ADJ   3 /* adjust current set quantities */

Definition at line 88 of file rholo.h.

#define BS_DEL   4 /* delete from current set */

Definition at line 89 of file rholo.h.

#define BS_MAX   5 /* set to max of old and new */

Definition at line 90 of file rholo.h.

#define BS_NEW   1 /* replace current set with new one */

Definition at line 86 of file rholo.h.

#define CACHE   0 /* amount of memory to use as cache */

Definition at line 51 of file rholo.h.

#define DISKSPACE   1 /* how much disk space to use */

Definition at line 52 of file rholo.h.

#define EYESEP   2 /* eye separation distance */

Definition at line 53 of file rholo.h.

#define GEOMETRY   3 /* section geometry */

Definition at line 54 of file rholo.h.

#define GRID   4 /* target grid size */

Definition at line 55 of file rholo.h.

#define NRHVARS   14 /* number of variables */

Definition at line 66 of file rholo.h.

#define OBSTRUCTIONS   5 /* shall we track obstructions? */

Definition at line 56 of file rholo.h.

#define OCTREE   6 /* octree file name */

Definition at line 57 of file rholo.h.

#define packra (   p)    ((RAYVAL *)((p)+1))

Definition at line 38 of file rholo.h.

#define packsiz (   nr)    (sizeof(PACKHEAD)+(nr)*sizeof(RAYVAL))

Definition at line 37 of file rholo.h.

#define PORTS   7 /* section portals */

Definition at line 58 of file rholo.h.

#define RENDER   8 /* rendering options */

Definition at line 59 of file rholo.h.

#define REPORT   9 /* report interval and error file */

Definition at line 60 of file rholo.h.

#define RHVINIT
Value:
{ \
       {"CACHE",     2,     0,     NULL,  fltvalue}, \
       {"DISKSPACE", 3,     0,     NULL,  fltvalue}, \
       {"EYESEP",    3,     0,     NULL,  fltvalue}, \
       {"geometry",  3,     0,     NULL,  NULL}, \
       {"GRID",      2,     0,     NULL,  fltvalue}, \
       {"OBSTRUCTIONS",3,   0,     NULL,  boolvalue}, \
       {"OCTREE",    3,     0,     NULL,  onevalue}, \
       {"portals",   3,     0,     NULL,  NULL}, \
       {"render",    3,     0,     NULL,  catvalues}, \
       {"REPORT",    3,     0,     NULL,  onevalue}, \
       {"RIF",              3,     0,     NULL,  onevalue}, \
       {"section",   3,     0,     NULL,  NULL}, \
       {"TIME",      2,     0,     NULL,  fltvalue}, \
       {"VDISTANCE", 2,     0,     NULL,  boolvalue}, \
}

Definition at line 68 of file rholo.h.

#define RIF   10 /* rad input file */

Definition at line 61 of file rholo.h.

#define RPACKSIZ   21 /* good packet size */

Definition at line 17 of file rholo.h.

#define SECTION   11 /* holodeck section boundaries */

Definition at line 62 of file rholo.h.

#define TIME   12 /* maximum rendering time */

Definition at line 63 of file rholo.h.

#define VDIST   13 /* virtual distance calculation */

Definition at line 64 of file rholo.h.


Typedef Documentation

typedef struct packet PACKET

Function Documentation

void bundle_set ( int  op,
PACKHEAD clist,
int  nents 
)

Definition at line 116 of file rholo3.c.

{
       int    oldnr, n;
       HDBEAMI       *hbarr;
       register PACKHEAD    *csm;
       register int  i;
                                   /* search for common members */
       for (csm = clist+nents; csm-- > clist; )
              csm->nc = -1;
       qsort((void *)clist, nents, sizeof(PACKHEAD), beamidcmp);
       for (i = 0; i < complen; i++) {
              csm = (PACKHEAD *)bsearch((void *)(complist+i), (void *)clist,
                            nents, sizeof(PACKHEAD), beamidcmp);
              if (csm == NULL)
                     continue;
              oldnr = complist[i].nr;
              csm->nc = complist[i].nc;
              switch (op) {
              case BS_ADD:         /* add to count */
                     complist[i].nr += csm->nr;
                     csm->nr = 0;
                     break;
              case BS_MAX:         /* maximum of counts */
                     if (csm->nr > complist[i].nr)
                            complist[i].nr = csm->nr;
                     csm->nr = 0;
                     break;
              case BS_ADJ:         /* reset count */
                     complist[i].nr = csm->nr;
                     csm->nr = 0;
                     break;
              case BS_DEL:         /* delete count */
                     if (csm->nr == 0 || csm->nr >= complist[i].nr)
                            complist[i].nr = 0;
                     else
                            complist[i].nr -= csm->nr;
                     break;
              }
              if (complist[i].nr != oldnr)
                     lastin = -1;  /* flag sort */
       }
                            /* record computed rays for uncommon beams */
       for (csm = clist+nents; csm-- > clist; )
              if (csm->nc < 0)
                     csm->nc = bnrays(hdlist[csm->hd], csm->bi);
                            /* complete list operations */
       switch (op) {
       case BS_NEW:                /* new computation set */
              listpos = 0; lastin = -1;
              if (complen)         /* free old list */
                     free((void *)complist);
              complist = NULL;
              if (!(complen = nents))
                     return;
              complist = (PACKHEAD *)malloc(nents*sizeof(PACKHEAD));
              if (complist == NULL)
                     goto memerr;
              memcpy((void *)complist, (void *)clist, nents*sizeof(PACKHEAD));
              break;
       case BS_ADD:                /* add to computation set */
       case BS_MAX:                /* maximum of quantities */
       case BS_ADJ:                /* adjust set quantities */
              if (nents <= 0)
                     return;
              sortcomplist();             /* sort updated list & new entries */
              qsort((void *)clist, nents, sizeof(PACKHEAD), beamcmp);
                                   /* what can't we satisfy? */
              for (i = nents, csm = clist; i-- && csm->nr > csm->nc; csm++)
                     ;
              n = csm - clist;
              if (op != BS_ADD) {  /* don't regenerate adjusted beams */
                     for (++i; i-- && csm->nr > 0; csm++)
                            ;
                     nents = csm - clist;
              }
              if (n) {             /* allocate space for merged list */
                     PACKHEAD      *newlist;
                     newlist = (PACKHEAD *)malloc(
                                   (complen+n)*sizeof(PACKHEAD) );
                     if (newlist == NULL)
                            goto memerr;
                                          /* merge lists */
                     mergeclists(newlist, clist, n, complist, complen);
                     if (complen)
                            free((void *)complist);
                     complist = newlist;
                     complen += n;
              }
              listpos = 0;
              lastin = complen-1;  /* list is now sorted */
              break;
       case BS_DEL:                /* delete from computation set */
              return;                     /* already done */
       default:
              error(CONSISTENCY, "bundle_set called with unknown operation");
       }
       if (outdev == NULL || !nents)      /* nothing to display? */
              return;
                                   /* load and display beams we have */
       hbarr = (HDBEAMI *)malloc(nents*sizeof(HDBEAMI));
       for (i = nents; i--; ) {
              hbarr[i].h = hdlist[clist[i].hd];
              hbarr[i].b = clist[i].bi;
       }
       hdloadbeams(hbarr, nents, dispbeam);
       free((void *)hbarr);
       if (hdfragflags&FF_READ) {
              listpos = 0;
              lastin = -1;         /* need to re-sort list */
       }
       return;
memerr:
       error(SYSTEM, "out of memory in bundle_set");
}

Here is the call graph for this function:

Here is the caller graph for this function:

int disp_check ( int  block)

Definition at line 111 of file rholo4.c.

{
       MSGHEAD       msg;
       int    n;
       char   *buf = NULL;

       if (dpout == NULL)
              return(-1);
                                   /* flush display output */
       disp_flush();
                                   /* check read blocking */
       if (block != (inp_flags == 0)) {
              inp_flags = block ? 0 : FNONBLK;
              if (fcntl(dpd.r, F_SETFL, inp_flags) < 0)
                     goto fcntlerr;
       }
                                   /* read message header */
       n = read(dpd.r, (char *)&msg, sizeof(MSGHEAD));
       if (n != sizeof(MSGHEAD)) {
              if (n >= 0) {
                     dpout = NULL;
                     error(USER, "display process died");
              }
              if ((errno != EAGAIN) & (errno != EINTR))
                     goto readerr;
              return(2);           /* acceptable failure */
       }
       if (msg.nbytes) {           /* get the message body */
              if (msg.nbytes < 0)
                     error(INTERNAL, "anti-message from display process");
              buf = (char *)malloc(msg.nbytes);
              if (buf == NULL)
                     error(SYSTEM, "out of memory in disp_check");
              if (inp_flags != 0 && fcntl(dpd.r, F_SETFL, inp_flags=0) < 0)
                     goto fcntlerr;
              if (readbuf(dpd.r, buf, msg.nbytes) != msg.nbytes)
                     goto readerr;
       }
       switch (msg.type) {         /* take appropriate action */
       case DR_BUNDLE:             /* new bundle to calculate */
              if (msg.nbytes != sizeof(PACKHEAD))
                     error(INTERNAL, "bad DR_BUNDLE from display process");
              bundle_set(BS_ADD, (PACKHEAD *)buf, 1);
              break;
       case DR_NEWSET:             /* new calculation set */
              if (msg.nbytes % sizeof(PACKHEAD))
                     error(INTERNAL, "bad DR_NEWSET from display process");
              if (msg.nbytes)
                     disp_result(DS_STARTIMM, 0, NULL);
              bundle_set(BS_NEW, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD));
              if (msg.nbytes) {
                     disp_result(DS_ENDIMM, 0, NULL);
                     disp_flush();
              }
              break;
       case DR_ADDSET:             /* add to calculation set */
              if (!msg.nbytes)
                     break;
              if (msg.nbytes % sizeof(PACKHEAD))
                     error(INTERNAL, "bad DR_ADDSET from display process");
              disp_result(DS_STARTIMM, 0, NULL);
              bundle_set(BS_ADD, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD));
              disp_result(DS_ENDIMM, 0, NULL);
              disp_flush();
              break;
       case DR_ADJSET:             /* adjust calculation set members */
              if (!msg.nbytes)
                     break;
              if (msg.nbytes % sizeof(PACKHEAD))
                     error(INTERNAL, "bad DR_ADJSET from display process");
              disp_result(DS_STARTIMM, 0, NULL);
              bundle_set(BS_ADJ, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD));
              disp_result(DS_ENDIMM, 0, NULL);
              disp_flush();
              break;
       case DR_DELSET:             /* delete from calculation set */
              if (!msg.nbytes)
                     break;
              if (msg.nbytes % sizeof(PACKHEAD))
                     error(INTERNAL, "bad DR_DELSET from display process");
              bundle_set(BS_DEL, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD));
              break;
       case DR_VIEWPOINT:   /* set target eye position */
              if (msg.nbytes != sizeof(VIEWPOINT))
                     error(INTERNAL, "bad DR_VIEWPOINT from display process");
              myeye = *((VIEWPOINT *)buf);
              break;
       case DR_ATTEN:              /* block for priority request */
              if (msg.nbytes)
                     error(INTERNAL, "bad DR_ATTEN from display process");
                                   /* send acknowledgement */
              disp_result(DS_ACKNOW, 0, NULL);
              return(disp_check(1));      /* block on following request */
       case DR_KILL:        /* kill computation process(es) */
              if (msg.nbytes)
                     error(INTERNAL, "bad DR_KILL from display process");
              if (nprocs > 0)
                     done_rtrace();
              else
                     error(WARNING, "no rtrace process to kill");
              break;
       case DR_RESTART:     /* restart computation process(es) */
              if (msg.nbytes)
                     error(INTERNAL, "bad DR_RESTART from display process");
              if (ncprocs > nprocs)
                     new_rtrace();
              else if (nprocs > 0)
                     error(WARNING, "rtrace already runnning");
              else
                     error(WARNING, "holodeck not open for writing");
              break;
       case DR_CLOBBER:     /* clobber holodeck */
              if (msg.nbytes)
                     error(INTERNAL, "bad DR_CLOBBER from display process");
              if ((force <= 0) | (ncprocs <= 0))
                     error(WARNING, "request to clobber holodeck denied");
              else {
                     error(WARNING, "clobbering holodeck contents");
                     hdclobber(NULL);
              }
              break;
       case DR_SHUTDOWN:    /* shut down program */
              if (msg.nbytes)
                     error(INTERNAL, "bad DR_SHUTDOWN from display process");
              return(0);           /* zero return signals shutdown */
       case DR_NOOP:        /* do nothing */
              break;
       default:
              error(INTERNAL, "unrecognized request from display process");
       }
       if (msg.nbytes)                    /* clean up */
              free(buf);
       return(1);                  /* normal return value */
fcntlerr:
       error(SYSTEM, "cannot change display blocking mode");
readerr:
       error(SYSTEM, "error reading from display process");
       return -1; /* pro forma return */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int disp_close ( void  )

Definition at line 255 of file rholo4.c.

{
       if (dpout == NULL)
              return(-1);
       myeye.rng = 0;
       disp_result(DS_SHUTDOWN, 0, NULL);
       fclose(dpout);
       dpout = NULL;
       return(dpd.running ? close_process(&dpd) : 0);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void disp_open ( char *  dname)

Definition at line 34 of file rholo4.c.

{
       char   buf[sizeof(HDGRID)+512], fd0[8], fd1[8], *cmd[5], *sfn;
       int    i, n, len;

       if (!strcmp(dname, SLAVENAME)) {
              dpd.r = 0;           /* read from stdin */
              dpout = stdout;             /* write to stdout */
              dpd.running = 0; /* we're the slave procees */
       } else {
                                   /* get full display program name */
#ifdef DEVPATH
              sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF);
#else
              sprintf(buf, "dev/%s%s", dname, HDSUF);
#endif
                                   /* dup stdin and stdout */
              if (readinp)
                     sprintf(fd0, "%d", dup(0));
              else
                     strcpy(fd0, "-1");
              sprintf(fd1, "%d", dup(1));
                                   /* start the display process */
              cmd[0] = buf;
              cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0;
              cmd[4] = NULL;
              i = open_process(&dpd, cmd);
              if (i <= 0)
                     error(USER, "cannot start display process");
              if ((dpout = fdopen(dpd.w, "w")) == NULL)
                     error(SYSTEM, "problem opening display pipe");
                                   /* close dup'ed stdin and stdout */
              if (readinp)
                     close(atoi(fd0));
              close(atoi(fd1));
       }
       dpd.w = -1;          /* causes ignored error in close_process() */
       inp_flags = 0;
                            /* check if outside */
       if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS))
              disp_result(DS_OUTSECT, 0, NULL);
                            /* send eye separation if specified */
       if (vdef(EYESEP)) {
              sprintf(buf, "%.9e", vflt(EYESEP));
              disp_result(DS_EYESEP, strlen(buf)+1, buf);
       }
                            /* write out hologram grids & octrees */
       for (i = 0; hdlist[i] != NULL; i++) {
              memcpy(buf, (void *)hdlist[i], sizeof(HDGRID));
              len = sizeof(HDGRID);
              n = vdef(GEOMETRY);
              sfn = i<n ? nvalue(GEOMETRY,i) :
                            n ? nvalue(GEOMETRY,n-1) : vval(OCTREE);
              strcpy(buf+len, sfn);
              len += strlen(sfn) + 1;
              n = vdef(PORTS);
              sfn = i<n ? nvalue(PORTS,i) : n ? nvalue(PORTS,n-1) : "";
              strcpy(buf+len, sfn);
              len += strlen(sfn) + 1;
              disp_result(DS_ADDHOLO, len, buf);
       }
       disp_flush();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void disp_packet ( register PACKHEAD p)

Definition at line 102 of file rholo4.c.

{
       disp_result(DS_BUNDLE, packsiz(p->nr), (char *)p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PACKET* do_packets ( PACKET pl)

Here is the caller graph for this function:

void done_packets ( PACKET pl)

Definition at line 570 of file rholo.c.

{
       static int    n2flush = 0;
       register PACKET      *p;

       while (pl != NULL) {
              p = pl; pl = p->next; p->next = NULL;
              if (p->nr > 0) {            /* add to holodeck */
                     memcpy( (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
                            (void *)p->ra,
                            p->nr*sizeof(RAYVAL));
                     if (outdev != NULL)  /* display it */
                            disp_packet((PACKHEAD *)p);
                     if (hdcachesize <= 0)
                            n2flush++;
                     nraysdone += p->nr;
                     npacksdone++;
                     p->nr = 0;
              }
              p->next = freepacks;        /* push onto free list */
              freepacks = p;
       }
       if (n2flush >= RTFLUSH) {
              if (outdev != NULL)
                     hdsync(NULL, 1);
              else
                     hdflush(NULL);
              n2flush = 0;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int done_rtrace ( void  )

Definition at line 290 of file rholo2.c.

{
       int    status;
                                   /* already closed? */
       if (!nprocs)
              return(0);
                                   /* flush beam queue */
       done_packets(flush_queue());
                                   /* sync holodeck */
       hdsync(NULL, 1);
                                   /* close rtrace */
       if ((status = end_rtrace()))
              error(WARNING, "bad exit status from rtrace");
       if (vdef(REPORT)) {         /* report time */
              eputs("rtrace process closed\n");
              report(0);
       }
       return(status);                    /* return status */
}

Here is the caller graph for this function:

void donerays ( PACKET p,
float *  rvl 
)

Here is the caller graph for this function:

int end_rtrace ( void  )

Definition at line 321 of file rholo2l.c.

{
       int    status = 0, rv;

       if (nprocs > 1)
              killpersist();
       while (nprocs > 0) {
              rv = close_process(&rtpd[--nprocs]);
              if (rv > 0)
                     status = rv;
       }
       free((void *)rtbuf);
       rtbuf = NULL;
       maxqlen = 0;
       return(status);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PACKET* flush_queue ( void  )

Definition at line 262 of file rholo2l.c.

{
       PACKET *rpdone = NULL;
       register PACKET      *rpl = NULL;
       float  *bp;
       register PACKET      *p;
       int    i, n, nr;

       for (i = 0; i < nprocs; i++)
              if (pqlen[i]) {
                     if (rpdone == NULL) {              /* tack on queue */
                            rpdone = rpl = pqueue[i];
                            if ((nr = rpl->nr) < RPACKSIZ) nr++;
                     } else {
                            rpl->next = pqueue[i];
                            nr = 0;
                     }
                     while (rpl->next != NULL) {
                            nr += (rpl = rpl->next)->nr;
                            if (rpl->nr < RPACKSIZ)
                                   nr++;         /* add flush block */
                     }
                     n = readbuf(rtpd[i].r, (char *)rtbuf,
                                   4*sizeof(float)*nr);
                     if (n < 0)
                            error(SYSTEM, "read failure in flush_queue");
                     bp = rtbuf;                 /* process packets */
                     for (p = pqueue[i]; p != NULL; p = p->next) {
                            if ((nr = p->nr) < RPACKSIZ)
                                   nr++;         /* add flush block */
                            n -= 4*sizeof(float)*nr;
                            if (n >= 0)
                                   donerays(p, bp);
                            else
                                   p->nr = 0;    /* short data error */
                            bp += 4*nr;
                     }
                     pqueue[i] = NULL;           /* zero this queue */
                     pqlen[i] = 0;
              }
       return(rpdone);             /* return all packets completed */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int getradfile ( void  )

Definition at line 337 of file rholo2.c.

{
       static short  mvar[] = {OCTREE,EYESEP,-1};
       static char   tf1[] = TEMPLATE;
       char   tf2[64];
       char   combuf[256];
       char   *pippt = NULL;
       register int  i;
       register char *cp;
                                   /* check if rad file specified */
       if (!vdef(RIF))
              return(0);
                                   /* create rad command */
       mktemp(tf1);
       sprintf(tf2, "%s.rif", tf1);
       sprintf(combuf,
              "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
                     vval(RIF), tf1);
       cp = combuf;
       while (*cp){
              if (*cp == '|') pippt = cp;
              cp++;
       }                           /* match unset variables */
       for (i = 0; mvar[i] >= 0; i++)
              if (!vdef(mvar[i])) {
                     *cp++ = '|';
                     strcpy(cp, vnam(mvar[i]));
                     while (*cp) cp++;
                     pippt = NULL;
              }
       if (pippt != NULL)
              strcpy(pippt, "> " NULL_DEVICE);   /* nothing to match */
       else
              sprintf(cp, ")[ \t]*=' > %s", tf2);
#ifdef DEBUG
       wputs(combuf); wputs("\n");
#endif
       system(combuf);                           /* ignore exit code */
       if (pippt == NULL) {
              loadvars(tf2);                     /* load variables */
              unlink(tf2);
       }
       rtargc += wordfile(rtargv+rtargc, tf1);   /* get rtrace options */
       unlink(tf1);                /* clean up */
       return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void init_global ( void  )

Definition at line 339 of file rholo3.c.

{
                                   /* free old list and empty queue */
       if (complen > 0) {
              free((void *)complist);
              done_packets(flush_queue());
       }
                                   /* reseed random number generator */
       srandom(time(NULL));
                                   /* allocate beam list */
       if (readinp)
              view_list(stdin);
       else
              ambient_list();
                                   /* no view vicinity */
       myeye.rng = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void new_rtrace ( void  )

Definition at line 312 of file rholo2.c.

{
       char   combuf[128];

       if (nprocs > 0)                    /* already running? */
              return;
       starttime = time(NULL);            /* reset start time and counts */
       npacksdone = nraysdone = 0L;
       if (vdef(TIME))                    /* reset end time */
              endtime = starttime + vflt(TIME)*3600. + .5;
       if (vdef(RIF)) {            /* rerun rad to update octree */
              sprintf(combuf, "rad -v 0 -s -w %s", vval(RIF));
              if (system(combuf))
                     error(WARNING, "error running rad");
       }
       if (start_rtrace() < 1)            /* start rtrace */
              error(WARNING, "cannot restart rtrace");
       else if (vdef(REPORT)) {
              eputs("rtrace process restarted\n");
              report(0);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int next_packet ( PACKET p,
int  n 
)

Here is the caller graph for this function:

int nextview ( VIEW vp,
FILE *  fp 
)

Definition at line 154 of file viewbeams.c.

{
       char   linebuf[256];

       while (fgets(linebuf, sizeof(linebuf), fp) != NULL)
              if (isview(linebuf) && sscanview(vp, linebuf) > 0)
                     return(0);
       return(EOF);
}      

Here is the call graph for this function:

Here is the caller graph for this function:

void packrays ( float *  rod,
PACKET p 
)

Here is the caller graph for this function:

void report ( time_t  t)

Definition at line 386 of file rholo2.c.

{
       static time_t seconds2go = 1000000;

       if (t == 0L)
              t = time(NULL);
       sprintf(errmsg, "%ld packets (%ld rays) done after %.2f hours\n",
                     npacksdone, nraysdone, (t-starttime)/3600.);
       eputs(errmsg);
       if (seconds2go == 1000000)
              seconds2go = vdef(REPORT) ? (long)(vflt(REPORT)*60. + .5) : 0L;
       if (seconds2go)
              reporttime = t + seconds2go;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int start_rtrace ( void  )

Definition at line 41 of file rholo2l.c.

{
       static char   buf1[8];
       int    rmaxpack = 0;
       int    psiz, n;
                                   /* get number of processes */
       if (ncprocs <= 0 || nprocs > 0)
              return(0);
       if (ncprocs > MAXPROC) {
              sprintf(errmsg,
                     "number of rtrace processes reduced from %d to %d",
                            ncprocs, MAXPROC);
              error(WARNING, errmsg);
              ncprocs = MAXPROC;
       }
       if (rtargv[rtargc-1] != vval(OCTREE)) {
                                          /* add compulsory options */
              rtargv[rtargc++] = "-i-";
              rtargv[rtargc++] = "-I-";
              rtargv[rtargc++] = "-h-";
              rtargv[rtargc++] = "-ld-";
              sprintf(buf1, "%d", RPACKSIZ);
              rtargv[rtargc++] = "-x"; rtargv[rtargc++] = buf1;
              rtargv[rtargc++] = "-y"; rtargv[rtargc++] = "0";
              rtargv[rtargc++] = "-fff";
              rtargv[rtargc++] = vbool(VDIST) ? "-ovl" : "-ovL";
              if (nowarn)
                     rtargv[rtargc++] = "-w-";
              if (ncprocs > 1) {
                     mktemp(pfile);
                     rtargv[rtargc++] = "-PP"; rtargv[rtargc++] = pfile;
              }
              rtargv[rtargc++] = vval(OCTREE);
              rtargv[rtargc] = NULL;
       }
       maxqlen = 0;
       for (nprocs = 0; nprocs < ncprocs; nprocs++) {   /* spawn children */
              psiz = open_process(&rtpd[nprocs], rtargv);
              if (psiz <= 0)
                     error(SYSTEM, "cannot start rtrace process");
              n = psiz/(RPACKSIZ*6*sizeof(float));
              if (maxqlen == 0) {
                     if (!(maxqlen = n))
                            error(INTERNAL,
                                   "bad pipe buffer size assumption");
                     sleep(2);
              } else if (n != maxqlen)
                     error(INTERNAL, "varying pipe buffer size!");
              rmaxpack += n;
       }
       rtbuf = (float *)malloc(RPACKSIZ*6*sizeof(float)*maxqlen);
       if (rtbuf == NULL)
              error(SYSTEM, "malloc failure in start_rtrace");
       return(rmaxpack);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int16* viewbeams ( VIEW vp,
int  hr,
int  vr,
BEAMLIST blp 
)

Definition at line 55 of file viewbeams.c.

{
       static int16  sectlist[HDMAX+1];
       int16  sectarr[MINRES+1][MINRES+1];
       double d0, d1, mindist;
       GCOORD gc[2];
       FVECT  rorg, rdir;
       int    shr, svr, sampquant;
       int    v;
       register int  h, hd;
                                          /* clear section flags */
       memset((char *)sectlist, '\0', sizeof(sectlist));
                                          /* identify view sections */
       for (v = 0; v <= MINRES; v++)
              for (h = 0; h <= MINRES; h++) {
                     sectarr[v][h] = -1;
                     mindist = 0.99*FHUGE;
                     if (viewray(rorg, rdir, vp, (double)h/MINRES,
                                   (double)v/MINRES) < -FTINY)
                            continue;
                     for (hd = 0; hdlist[hd] != NULL; hd++) {
                            d0 = hdinter(gc, NULL, &d1,
                                          hdlist[hd], rorg, rdir);
                            if (d0 >= 0.99*FHUGE)
                                   continue;            /* missed */
                            if (d0 <= 0. && d1 >= 0.) {
                                   sectarr[v][h] = hd;
                                   break;               /* inside */
                            }
                            if (d0 > 0. && d0 < mindist) {
                                   sectarr[v][h] = hd;
                                   mindist = d0;
                            } else if (d1 < 0. && -d1 < mindist) {
                                   sectarr[v][h] = hd;
                                   mindist = -d1;
                            }
                     }
                     if ((hd = sectarr[v][h]) >= 0)
                            sectlist[hd]++;             /* flag section */
              }
                                          /* convert flags to list */
       for (h = hd = 0; hdlist[hd] != NULL; h++, hd++) {
              while (!sectlist[hd])
                     if (hdlist[++hd] == NULL)
                            goto loopexit;
              sectlist[h] = hd;
       }
loopexit:
       sectlist[h] = -1;                  /* list terminator */
       if (blp == NULL)                   /* if no beam list... */
              return(sectlist);                  /* return early */
                                          /* else set up sampling */
       if (hr|vr && hr*vr <= NVSAMPS) {
              shr = hr; svr = vr;
              sampquant = 1;
       } else {
              shr = sqrt(NVSAMPS/viewaspect(vp)) + .5;
              svr = (NVSAMPS + shr/2)/shr;
              sampquant = (hr*vr + shr*svr/2)/(shr*svr);
       }
       blist.bl = NULL; blist.nb = 0;            /* sample view rays */
       for (v = svr; v--; )
              for (h = shr; h--; ) {
                     hd = random()>>6 & 03;             /* get section */
                     hd = sectarr[v*MINRES/svr + (hd&01)]
                                   [h*MINRES/shr + (hd>>1)];
                     if (hd < 0)
                            continue;
                                                 /* get sample ray */
                     if (viewray(rorg, rdir, vp, (h+frandom())/shr,
                                   (v+frandom())/svr) < -FTINY)
                            continue;
#ifdef OJITTER
                                                 /* jitter origin */
                     d0 = OJITTER*(frandom() - .5) / hdlist[hd]->grid[0];
                     VSUM(rorg, rorg, hdlist[hd]->xv[0], d0);
                     d0 = OJITTER*(frandom() - .5) / hdlist[hd]->grid[1];
                     VSUM(rorg, rorg, hdlist[hd]->xv[1], d0);
                     d0 = OJITTER*(frandom() - .5) / hdlist[hd]->grid[2];
                     VSUM(rorg, rorg, hdlist[hd]->xv[2], d0);
#endif
                                                 /* intersect section */
                     if (hdinter(gc, NULL, NULL, hdlist[hd], rorg, rdir)
                                   >= 0.99*FHUGE)
                            continue;
                                                 /* add samples */
                     add2blist(hd, hdbindex(hdlist[hd],gc), sampquant);
              }
       *blp = blist;        /* transfer beam list */
       return(sectlist);                  /* all done! */
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int chunkycmp

Definition at line 23 of file rholo3.c.

time_t endtime

Definition at line 52 of file rholo.c.

int force

Definition at line 49 of file rholo.c.

char froot[]

Definition at line 41 of file rholo.c.

char* hdkfile

Definition at line 40 of file rholo.c.

Definition at line 15 of file rholo2.c.

int ncprocs

Definition at line 43 of file rholo.c.

int nowarn

Definition at line 92 of file rcalc.c.

long npacksdone

Definition at line 63 of file rholo.c.

int nprocs

Definition at line 22 of file rholo2l.c.

long nraysdone

Definition at line 62 of file rholo.c.

char* outdev

Definition at line 45 of file rholo.c.

char* progname

Definition at line 21 of file histo.c.

int readinp

Definition at line 47 of file rholo.c.

time_t reporttime

Definition at line 53 of file rholo.c.

int rtargc

Definition at line 57 of file rholo.c.

char* rtargv[]

Definition at line 58 of file rholo.c.

time_t starttime

Definition at line 51 of file rholo.c.