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

Comparing ray/src/hd/rholo2.c (file contents):
Revision 3.4 by gregl, Mon Dec 1 16:34:36 1997 UTC vs.
Revision 3.7 by gregl, Fri Dec 12 19:52:32 1997 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   */
10  
11   #include "rholo.h"
12 + #include "paths.h"
13   #include "random.h"
14  
15  
# Line 61 | Line 62 | register float *rvl;
62                  rvl += 4;
63          }
64          p->nc += p->nr;
65 + }
66 +
67 +
68 + int
69 + done_rtrace()                   /* clean up and close rtrace calculation */
70 + {
71 +        int     status;
72 +                                        /* already closed? */
73 +        if (!nprocs)
74 +                return;
75 +        wputs("closing rtrace process...\n");
76 +                                        /* flush beam queue */
77 +        done_packets(flush_queue());
78 +                                        /* sync holodeck */
79 +        hdsync(NULL, 1);
80 +                                        /* close rtrace */
81 +        if ((status = end_rtrace()))
82 +                error(WARNING, "bad exit status from rtrace");
83 +        if (vdef(REPORT))               /* report time */
84 +                report(0);
85 +        return(status);                 /* return status */
86 + }
87 +
88 +
89 + new_rtrace()                    /* restart rtrace calculation */
90 + {
91 +        char    combuf[128];
92 +
93 +        if (nprocs > 0)                 /* already running? */
94 +                return;
95 +        wputs("restarting rtrace process...\n");
96 +        starttime = time(NULL);         /* reset start time and counts */
97 +        npacksdone = nraysdone = 0L;
98 +        if (vdef(TIME))                 /* reset end time */
99 +                endtime = starttime + vflt(TIME)*3600. + .5;
100 +        if (vdef(RIF)) {                /* rerun rad to update octree */
101 +                sprintf(combuf, "rad -v 0 -s -w %s", vval(RIF));
102 +                if (system(combuf))
103 +                        error(WARNING, "error running rad");
104 +        }
105 +        if (start_rtrace() < 1)         /* start rtrace */
106 +                error(WARNING, "cannot restart rtrace");
107 +        else if (vdef(REPORT))
108 +                report(0);
109 + }
110 +
111 +
112 + getradfile()                    /* run rad and get needed variables */
113 + {
114 +        static short    mvar[] = {OCTREE,-1};
115 +        static char     tf1[] = TEMPLATE;
116 +        char    tf2[64];
117 +        char    combuf[256];
118 +        char    *pippt;
119 +        register int    i;
120 +        register char   *cp;
121 +                                        /* check if rad file specified */
122 +        if (!vdef(RIF))
123 +                return;
124 +                                        /* create rad command */
125 +        mktemp(tf1);
126 +        sprintf(tf2, "%s.rif", tf1);
127 +        sprintf(combuf,
128 +                "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
129 +                        vval(RIF), tf1);
130 +        cp = combuf;
131 +        while (*cp){
132 +                if (*cp == '|') pippt = cp;
133 +                cp++;
134 +        }                               /* match unset variables */
135 +        for (i = 0; mvar[i] >= 0; i++)
136 +                if (!vdef(mvar[i])) {
137 +                        *cp++ = '|';
138 +                        strcpy(cp, vnam(mvar[i]));
139 +                        while (*cp) cp++;
140 +                        pippt = NULL;
141 +                }
142 +        if (pippt != NULL)
143 +                strcpy(pippt, "> /dev/null");   /* nothing to match */
144 +        else
145 +                sprintf(cp, ")[ \t]*=' > %s", tf2);
146 +        if (system(combuf)) {
147 +                unlink(tf2);                    /* clean up */
148 +                unlink(tf1);
149 +                error(SYSTEM, "cannot execute rad command");
150 +        }
151 +        if (pippt == NULL) {
152 +                loadvars(tf2);                  /* load variables */
153 +                unlink(tf2);
154 +        }
155 +        rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */
156 +        unlink(tf1);                    /* clean up */
157 + }
158 +
159 +
160 + report(t)                       /* report progress so far */
161 + time_t  t;
162 + {
163 +        static time_t   seconds2go = 1000000;
164 +
165 +        if (t == 0L)
166 +                t = time(NULL);
167 +        sprintf(errmsg, "%ld packets (%ld rays) done after %.2f hours\n",
168 +                        npacksdone, nraysdone, (t-starttime)/3600.);
169 +        eputs(errmsg);
170 +        if (seconds2go == 1000000)
171 +                seconds2go = vdef(REPORT) ? (long)(vflt(REPORT)*60. + .5) : 0L;
172 +        if (seconds2go)
173 +                reporttime = t + seconds2go;
174   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines