| 23 |
|
|
| 24 |
|
/// Multi-threaded simulation manager base class |
| 25 |
|
class RadSimulManager { |
| 26 |
+ |
char * header; // header (less intro and format) |
| 27 |
+ |
int hlen; // header string length |
| 28 |
|
protected: |
| 29 |
|
// Assign ray to subthread (fails if NThreads()<2) |
| 30 |
|
bool SplitRay(RAY *r); |
| 31 |
|
public: |
| 32 |
|
RadSimulManager(const char *octn = NULL) { |
| 33 |
+ |
header = NULL; hlen = 0; |
| 34 |
|
LoadOctree(octn); |
| 35 |
|
} |
| 36 |
|
~RadSimulManager() { |
| 38 |
|
} |
| 39 |
|
/// Load octree and prepare renderer |
| 40 |
|
bool LoadOctree(const char *octn); |
| 41 |
+ |
/// Prepare header from previous input (or clear) |
| 42 |
+ |
/// Normally called during octree load |
| 43 |
+ |
bool NewHeader(const char *inspec=NULL); |
| 44 |
+ |
/// Add a line to header (adds newline if none) |
| 45 |
+ |
bool AddHeader(const char *str); |
| 46 |
+ |
/// Append program line to header |
| 47 |
+ |
bool AddHeader(int ac, const char *av[]); |
| 48 |
+ |
/// Get header lines or empty string |
| 49 |
+ |
const char * GetHeader() const { |
| 50 |
+ |
return hlen ? header : ""; |
| 51 |
+ |
} |
| 52 |
|
/// How many cores are available? |
| 53 |
|
static int GetNCores(); |
| 54 |
|
/// Set number of computation threads (0 => #cores) |
| 105 |
|
int SetThreadCount(int nt = 0) { |
| 106 |
|
if (nt <= 0) nt = castonly ? 1 : GetNCores(); |
| 107 |
|
if (nt == NThreads()) return nt; |
| 108 |
< |
if (FlushQueue() < 0) return 0; |
| 108 |
> |
if (nt < NThreads() && FlushQueue() < 0) return 0; |
| 109 |
|
return RadSimulManager::SetThreadCount(nt); |
| 110 |
|
} |
| 111 |
|
/// Add ray bundle to queue w/ optional 1st ray ID |
| 141 |
|
int FlushQueue(); |
| 142 |
|
/// Close octree, free data, return status |
| 143 |
|
int Cleanup(bool everything = false) { |
| 130 |
– |
FlushQueue(); |
| 144 |
|
SetCookedCall(NULL); |
| 145 |
|
SetTraceCall(NULL); |
| 146 |
|
rtFlags = 0; |