ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/RcontribSimulManager.h
(Generate patch)

Comparing ray/src/rt/RcontribSimulManager.h (file contents):
Revision 2.5 by greg, Wed Nov 6 18:28:52 2024 UTC vs.
Revision 2.10 by greg, Thu Jan 2 16:16:49 2025 UTC

# Line 25 | Line 25
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)
# Line 125 | Line 121 | extern lut_free_t      FreeRcMod;
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
141   * may be recalculated.  The previous output rows are not zeroed or deleted,
142   * but are overwritten as the calculation proceeds from the new starting point.
143   * However, the output file(s) will indicate in the NROWS= line in the header
144 < * that only the newly calculated rows are present.
144 > * that only the newly calculated rows are present.  If you wish to start over
145 > * with a different set of modifiers or outputs, call ClearModifiers() instead,
146 > * which keeps the current octree in memory.  This call also returns to single
147 > * process mode if any children were running.
148   *
149   * It is not possible to write to standard output, but the output
150   * model is quite flexible thanks to the RdataShare polymorphic class.
# Line 166 | Line 167 | typedef RdataShare *   RcreateDataShareF(const char *nam
167   extern RcreateDataShareF        defDataShare;
168  
169   /// Modifiable ray-tracing flags for rcontrib
170 < #define RCmask                  (RTlimDist|RTimmIrrad)
170 > #define RCcontrib               (RTmask+1)      // compute contributions? (r.t. coefficients)
171 > #define RCmask                  (RTlimDist|RTimmIrrad|RCcontrib)
172  
173   /// rcontrib-like simulation manager (at most one such object)
174   class RcontribSimulManager : protected RtraceSimulManager {
# Line 190 | Line 192 | class RcontribSimulManager : protected RtraceSimulMana
192   public:
193          RCOutputOp              outOp;          // output operation
194          RcreateDataShareF *     cdsF;           // data share creator
195 +        int                     xres, yres;     // output (picture) size
196          uint32                  accum;          // # rays to accumulate per record
197                                  RcontribSimulManager(const char *octn = NULL)
198                                                  : RtraceSimulManager(NULL, NULL, octn) {
# Line 204 | Line 207 | class RcontribSimulManager : protected RtraceSimulMana
207                                          modLUT.freek = efree;
208                                          modLUT.freed = FreeRcMod;
209                                          kid = NULL; kidRow = NULL; nkids = 0;
207                                        rtFlags = RTtraceSources;
208                                        SetTraceCall(&RctCall, this);
210                                          outOp = RCOnew;
211                                          cdsF = &defDataShare;
212 +                                        xres = yres = 0;
213                                          accum = 1;
214 +                                        if (octname) {
215 +                                                SetTraceCall(&RctCall, this);
216 +                                                rtFlags |= RTtraceSources;
217 +                                                UpdateMode();
218 +                                        }
219                                  }
220                                  ~RcontribSimulManager() {
221 <                                        Cleanup();
221 >                                        if (nkids >= 0) ClearModifiers();
222                                  }
223                                  /// Check modifiable ray-tracing computation flag(s)
224          bool                    HasFlag(int fl) const {
# Line 226 | Line 233 | class RcontribSimulManager : protected RtraceSimulMana
233                                  }
234                                  /// Load octree and prepare renderer
235          bool                    LoadOctree(const char *octn) {
236 <                                        return RtraceSimulManager::LoadOctree(octn);
236 >                                        if (octname) Cleanup(false);
237 >                                        if (!RtraceSimulManager::LoadOctree(octn))
238 >                                                return false;
239 >                                        SetTraceCall(&RctCall, this);
240 >                                        rtFlags |= RTtraceSources;
241 >                                        return UpdateMode();
242                                  }
243                                  /// Prepare header from previous input (or clear)
244          bool                    NewHeader(const char *inspec=NULL) {
# Line 304 | Line 316 | class RcontribSimulManager : protected RtraceSimulMana
316                                                  return rowsDone.Length();
317                                          return nDone;
318                                  }
307                                /// Rewind calculation (previous results unchanged)
308        bool                    ResetRow(int r);
319                                  /// Add a ray/bundle to compute next record (n=accum)
320          int                     ComputeRecord(const FVECT orig_direc[]);
321                                  /// Finish pending rays if multi-processing
# Line 315 | Line 325 | class RcontribSimulManager : protected RtraceSimulMana
325                                                  ;
326                                          return true;
327                                  }
328 <                                /// Close octree, free data, return status
329 <        int                     Cleanup(bool everything = false) {
330 <                                        if (nkids < 0) return 0;        // skip 4 child
328 >                                /// Rewind calculation (previous results unchanged)
329 >        bool                    ResetRow(int r);
330 >                                /// Clear the modifiers and close all outputs
331 >        void                    ClearModifiers() {
332                                          if (rowsDone.Length()) {
333                                                  SetThreadCount(1);
323                                                cow_doneshare();
334                                                  rowsDone.NewBitMap(0);
335 +                                                rInPos = 0;
336                                          }
337                                          lu_done(&modLUT);
338                                          delete outList; outList = NULL;
339                                          nChan = 0;
340 +                                }
341 +                                /// Close octree, free data, return status
342 +        int                     Cleanup(bool everything = false) {
343 +                                        ClearModifiers();
344 +                                        cow_doneshare();
345 +                                        if (everything) {
346 +                                                dtyp = 'f';
347 +                                                outOp = RCOnew;
348 +                                                cdsF = &defDataShare;
349 +                                                xres = yres = 0;
350 +                                                accum = 1;
351 +                                                rtFlags &= ~RCmask;
352 +                                        }
353                                          return RtraceSimulManager::Cleanup(everything);
354                                  }
355   };
356 +
357 + extern const char *     formstr(int f);         // string from format
358  
359   #endif /* RcontribSimulManager_h */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines