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.1 by greg, Tue Oct 29 00:36:54 2024 UTC vs.
Revision 2.6 by greg, Wed Nov 6 19:45:59 2024 UTC

# Line 25 | Line 25
25  
26   extern char             RCCONTEXT[];            // global rcontrib context
27  
28 < extern int              xres, yres;             // global resolution settings
28 > class RcontribSimulManager;                     // need forward decl
29  
30 class RcontribSimulManager;             // need forward decl
31
30   /// Shared data object for record output (includes header; may be write-only)
31   class RcontribOutput {
34 protected:
32          RcontribOutput *        next;           // next in sorted list
33          char *                  ofname;         // output file name
34          uint32                  rowCountPos;    // row count position in header
# Line 124 | 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
# Line 153 | Line 152 | extern lut_free_t      FreeRcMod;
152   */
153  
154   /// Output channel opening options: new/exclusive, overwrite if exists, or recover data
155 < enum RCOutputOp {RCOnew, RCOforce, RCOrecover};
155 > enum RCOutputOp {RCOnew=0, RCOforce, RCOrecover};
156  
157   /// Converts above to RdataShare open flags (may be adjusted by calling program)
158   extern int      RSDOflags[];
# Line 164 | Line 163 | typedef RdataShare *   RcreateDataShareF(const char *nam
163   /// Our default data share function
164   extern RcreateDataShareF        defDataShare;
165  
166 < /// Call-back used by GetOutputs() method (cd is client data)
167 < typedef int             RoutputShareF(const RcontribOutput *op, void *cd);
166 > /// Modifiable ray-tracing flags for rcontrib
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 {
# Line 189 | Line 189 | class RcontribSimulManager : protected RtraceSimulMana
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) {
# Line 207 | Line 208 | class RcontribSimulManager : protected RtraceSimulMana
208                                          SetTraceCall(&RctCall, this);
209                                          outOp = RCOnew;
210                                          cdsF = &defDataShare;
211 +                                        xres = yres = 0;
212                                          accum = 1;
213                                  }
214                                  ~RcontribSimulManager() {
215                                          Cleanup();
216                                  }
217 +                                /// Check modifiable ray-tracing computation flag(s)
218 +        bool                    HasFlag(int fl) const {
219 +                                        return ((rtFlags & RCmask & fl) != 0);
220 +                                }
221 +                                /// Set/reset modifiable ray-tracing computation flag(s)
222 +        bool                    SetFlag(int fl, bool val = true) {
223 +                                        if (!(fl &= RCmask)) return false;
224 +                                        if (val) rtFlags |= fl;
225 +                                        else rtFlags &= ~fl;
226 +                                        return true;
227 +                                }
228                                  /// Load octree and prepare renderer
229          bool                    LoadOctree(const char *octn) {
230                                          return RtraceSimulManager::LoadOctree(octn);
# Line 255 | Line 268 | class RcontribSimulManager : protected RtraceSimulMana
268          bool                    AddModFile(const char *modfn, const char *outspec,
269                                                  const char *prms = NULL,
270                                                  const char *binval = NULL, int bincnt = 1);
271 <                                /// Run through current list of output struct's
272 <        int                     GetOutputs(RoutputShareF *osF, void *cd = NULL) const;
271 >                                /// Get named rcontrib output (or list)
272 >        const RcontribOutput *  GetOutput(const char *nm = NULL) const {
273 >                                        if (!nm) return outList;
274 >                                        const RcontribOutput *  op = outList;
275 >                                        while (op && strcmp(op->GetName(), nm))
276 >                                                op = op->next;
277 >                                        return op;
278 >                                }
279                                  /// Open output channels and return # completed rows
280          int                     PrepOutput();
281                                  /// Are we ready to compute some records?
282          bool                    Ready() const {
283 <                                        return rowsDone.Length();
283 >                                        return (rowsDone.Length() > 0) & (accum > 0);
284                                  }
285                                  /// Set number of computation threads (0 => #cores)
286          int                     SetThreadCount(int nt = 0);
# Line 299 | Line 318 | class RcontribSimulManager : protected RtraceSimulMana
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();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines