25 |
|
|
26 |
|
extern char RCCONTEXT[]; // global rcontrib context |
27 |
|
|
28 |
– |
extern int contrib; // computing contributions? |
29 |
– |
|
30 |
– |
extern int xres, yres; // global resolution settings |
31 |
– |
|
28 |
|
class RcontribSimulManager; // need forward decl |
29 |
|
|
30 |
|
/// Shared data object for record output (includes header; may be write-only) |
121 |
|
* |
122 |
|
* 1) Call LoadOctree(), then alter the header as desired |
123 |
|
* 2) Set number of spectral samples (NCSAMP) and call SetDataFormat() |
124 |
< |
* 3) Call AddModifier() and AddModFile() to indicate tracked modifiers |
125 |
< |
* 4) Set outOp and cdsF according to desired output/recovery |
126 |
< |
* 5) Call PrepOutput() to open output channels |
127 |
< |
* 6) Call SetThreadCount() to fork children if desired |
128 |
< |
* 7) Set accum to the number of ray samples per record |
129 |
< |
* 8) Call ComputeRecord() with accum ray samples |
130 |
< |
* 9) Continue until GetRowMax() records have been sent |
131 |
< |
* 10) Call Cleanup() |
124 |
> |
* 3) Set xres and yres to desired dimensions (xres>0 for picture output) |
125 |
> |
* 4) Call AddModifier() and AddModFile() to indicate tracked modifiers |
126 |
> |
* 5) Set outOp and cdsF according to desired output/recovery |
127 |
> |
* 6) Set desired computation flags via SetFlag() |
128 |
> |
* 7) Call PrepOutput() to open output channels |
129 |
> |
* 8) Call SetThreadCount() to fork children if desired |
130 |
> |
* 9) Set accum to the number of ray samples per record |
131 |
> |
* 10) Call ComputeRecord() with accum ray samples |
132 |
> |
* 11) Continue until GetRowMax() records have been sent |
133 |
> |
* 12) Call Cleanup() |
134 |
|
* |
135 |
|
* The order of some of these calls may be changed. Technically, the octree |
136 |
|
* may be loaded anytime before PrepOutput() is called. Also, SetThreadCount() |
137 |
< |
* may be called anytime after PrepOutput() and interleaved with |
137 |
> |
* may be called anytime *after* PrepOutput(), and may be interleaved with |
138 |
|
* calls to ComputeRecord(). The accum setting may be changed at any time. |
139 |
|
* Finally, it is possible to restart the output using ResetRow(), and |
140 |
|
* a zero argument will rewind to the beginning, whence all records |
164 |
|
extern RcreateDataShareF defDataShare; |
165 |
|
|
166 |
|
/// Modifiable ray-tracing flags for rcontrib |
167 |
< |
#define RCmask (RTlimDist|RTimmIrrad) |
167 |
> |
#define RCcontrib (RTmask+1) // compute contributions? (r.t. coefficients) |
168 |
> |
#define RCmask (RTlimDist|RTimmIrrad|RCcontrib) |
169 |
|
|
170 |
|
/// rcontrib-like simulation manager (at most one such object) |
171 |
|
class RcontribSimulManager : protected RtraceSimulManager { |
189 |
|
public: |
190 |
|
RCOutputOp outOp; // output operation |
191 |
|
RcreateDataShareF * cdsF; // data share creator |
192 |
+ |
int xres, yres; // output (picture) size |
193 |
|
uint32 accum; // # rays to accumulate per record |
194 |
|
RcontribSimulManager(const char *octn = NULL) |
195 |
|
: RtraceSimulManager(NULL, NULL, octn) { |
208 |
|
SetTraceCall(&RctCall, this); |
209 |
|
outOp = RCOnew; |
210 |
|
cdsF = &defDataShare; |
211 |
+ |
xres = yres = 0; |
212 |
|
accum = 1; |
213 |
|
} |
214 |
|
~RcontribSimulManager() { |
318 |
|
} |
319 |
|
/// Close octree, free data, return status |
320 |
|
int Cleanup(bool everything = false) { |
321 |
+ |
if (nkids < 0) return 0; // skip 4 child |
322 |
|
if (rowsDone.Length()) { |
323 |
|
SetThreadCount(1); |
324 |
|
cow_doneshare(); |