1 | // ================================================================
|
---|
2 | // $Id: environ.cpp,v 1.1 2004/02/16 14:45:59 bittner Exp $
|
---|
3 | //
|
---|
4 | // environ.cpp
|
---|
5 | // Implementation of the environment operations, ie. reading
|
---|
6 | // environment file, reading command line parameters etc.
|
---|
7 | //
|
---|
8 |
|
---|
9 | //#define _DEBUG_PARAMS
|
---|
10 |
|
---|
11 | #include <math.h>
|
---|
12 | #include <stdlib.h>
|
---|
13 | #include <stdio.h>
|
---|
14 | #include <string.h>
|
---|
15 | #include <fstream>
|
---|
16 |
|
---|
17 | #include "gzstream.h"
|
---|
18 | #include "common.h"
|
---|
19 | #include "Environment.h"
|
---|
20 | #include "Vector3.h"
|
---|
21 |
|
---|
22 | using namespace std;
|
---|
23 |
|
---|
24 | namespace GtpVisibilityPreprocessor {
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | Environment *environment = NULL;
|
---|
29 |
|
---|
30 | Environment::~Environment()
|
---|
31 | {
|
---|
32 | int i, j;
|
---|
33 |
|
---|
34 | // delete the params structure
|
---|
35 | for (i = 0; i < numParams; i++) {
|
---|
36 | for (j = 0; j < paramRows; j++)
|
---|
37 | if (params[i][j] != NULL)
|
---|
38 | delete[] params[i][j];
|
---|
39 | if (params[i] != NULL)
|
---|
40 | delete[] params[i];
|
---|
41 | }
|
---|
42 |
|
---|
43 | if (params != NULL)
|
---|
44 | delete[] params;
|
---|
45 |
|
---|
46 | // delete the options structure
|
---|
47 | if (options != NULL)
|
---|
48 | delete[] options;
|
---|
49 |
|
---|
50 | if (optionalParams != NULL)
|
---|
51 | delete optionalParams;
|
---|
52 | }
|
---|
53 |
|
---|
54 | bool
|
---|
55 | Environment::CheckForSwitch(const int argc,
|
---|
56 | char **argv,
|
---|
57 | const char swtch) const
|
---|
58 | {
|
---|
59 | for (int i = 1; i < argc; i++)
|
---|
60 | if ((argv[i][0] == '-') && (argv[i][1] == swtch))
|
---|
61 | return true;
|
---|
62 | return false;
|
---|
63 | }
|
---|
64 |
|
---|
65 | bool
|
---|
66 | Environment::CheckType(const char *value,
|
---|
67 | const EOptType type) const
|
---|
68 | {
|
---|
69 | char *s, *t, *u;
|
---|
70 |
|
---|
71 | switch (type) {
|
---|
72 | case optInt: {
|
---|
73 | strtol(value, &t, 10);
|
---|
74 | if (value + strlen(value) != t)
|
---|
75 | return false;
|
---|
76 | else
|
---|
77 | return true;
|
---|
78 | }
|
---|
79 | case optFloat: {
|
---|
80 | strtod(value, &t);
|
---|
81 | if (value + strlen(value) != t)
|
---|
82 | return false;
|
---|
83 | else
|
---|
84 | return true;
|
---|
85 | }
|
---|
86 | case optBool: {
|
---|
87 | if (!strcasecmp(value, "true") ||
|
---|
88 | !strcasecmp(value, "false") ||
|
---|
89 | !strcasecmp(value, "YES") ||
|
---|
90 | !strcasecmp(value, "NO") ||
|
---|
91 | !strcmp(value, "+") ||
|
---|
92 | !strcmp(value, "-") ||
|
---|
93 | !strcasecmp(value, "ON") ||
|
---|
94 | !strcasecmp(value, "OFF"))
|
---|
95 | return true;
|
---|
96 | return false;
|
---|
97 | }
|
---|
98 | case optVector:{
|
---|
99 | strtod(value, &s);
|
---|
100 | if (*s == ' ' || *s == '\t') {
|
---|
101 | while (*s == ' ' || *s == '\t')
|
---|
102 | s++;
|
---|
103 | if (*s != ',')
|
---|
104 | s--;
|
---|
105 | }
|
---|
106 | if ((*s != ',' && *s != ' ' && *s != '\t') || value == s)
|
---|
107 | return false;
|
---|
108 | t = s;
|
---|
109 | strtod(s + 1, &u);
|
---|
110 | if (*u == ' ' || *u == '\t') {
|
---|
111 | while (*u == ' ' || *u == '\t')
|
---|
112 | u++;
|
---|
113 | if (*u != ',')
|
---|
114 | u--;
|
---|
115 | }
|
---|
116 | if ((*u != ',' && *s != ' ' && *s != '\t') || t == u)
|
---|
117 | return false;
|
---|
118 | t = u;
|
---|
119 | strtod(u + 1, &s);
|
---|
120 | if (t == s || value + strlen(value) != s)
|
---|
121 | return false;
|
---|
122 | return true;
|
---|
123 | }
|
---|
124 | case optString: {
|
---|
125 | return true;
|
---|
126 | }
|
---|
127 | default: {
|
---|
128 | Debug << "Internal error: Unknown type of option.\n" << flush;
|
---|
129 | exit(1);
|
---|
130 | }
|
---|
131 | }
|
---|
132 | return false;
|
---|
133 | }
|
---|
134 |
|
---|
135 | void
|
---|
136 | Environment::ReadCmdlineParams(const int argc,
|
---|
137 | char **argv,
|
---|
138 | const char *optParams)
|
---|
139 | {
|
---|
140 | int i;
|
---|
141 |
|
---|
142 | // Make sure we are called for the first time
|
---|
143 | if (optionalParams != NULL)
|
---|
144 | return;
|
---|
145 |
|
---|
146 | numParams = (int)strlen(optParams) + 1;
|
---|
147 | optionalParams = new char[numParams];
|
---|
148 | strcpy(optionalParams, optParams);
|
---|
149 |
|
---|
150 | // First, count all non-optional parameters on the command line
|
---|
151 | for (i = 1; i < argc; i++)
|
---|
152 | if (argv[i][0] != '-')
|
---|
153 | paramRows++;
|
---|
154 |
|
---|
155 | // if there is no non-optional parameter add a default one...
|
---|
156 | if (paramRows == 0)
|
---|
157 | paramRows = 1;
|
---|
158 |
|
---|
159 | // allocate and initialize the table for parameters
|
---|
160 | params = new char **[numParams];
|
---|
161 | for (i = 0; i < numParams; i++) {
|
---|
162 | params[i] = new char *[paramRows];
|
---|
163 | for (int j = 0; j < paramRows; j++)
|
---|
164 | params[i][j] = NULL;
|
---|
165 | }
|
---|
166 | // Now read all non-optional and optional parameters into the table
|
---|
167 | curRow = -1;
|
---|
168 | for (i = 1; i < argc; i++) {
|
---|
169 | if (argv[i][0] != '-') {
|
---|
170 | // non-optional parameter encountered
|
---|
171 | curRow++;
|
---|
172 | params[0][curRow] = new char[strlen(argv[i]) + 1];
|
---|
173 | strcpy(params[0][curRow], argv[i]);
|
---|
174 | }
|
---|
175 | else {
|
---|
176 | // option encountered
|
---|
177 | char *t = strchr(optionalParams, argv[i][1]);
|
---|
178 | if (t != NULL) {
|
---|
179 | // this option is optional parameter
|
---|
180 | int index = t - optionalParams + 1;
|
---|
181 | if (curRow < 0) {
|
---|
182 | // it's a global parameter
|
---|
183 | for (int j = 0; j < paramRows; j++) {
|
---|
184 | params[index][j] = new char[strlen(argv[i] + 2) + 1];
|
---|
185 | strcpy(params[index][j], argv[i] + 2);
|
---|
186 | }
|
---|
187 | }
|
---|
188 | else {
|
---|
189 | // it's a scene parameter
|
---|
190 | if (params[index][curRow] != NULL) {
|
---|
191 | delete[] params[index][curRow];
|
---|
192 | }
|
---|
193 | params[index][curRow] = new char[strlen(argv[i] + 2) + 1];
|
---|
194 | strcpy(params[index][curRow], argv[i] + 2);
|
---|
195 | }
|
---|
196 | }
|
---|
197 | }
|
---|
198 | }
|
---|
199 | curRow = 0;
|
---|
200 |
|
---|
201 | #ifdef _DEBUG_PARAMS
|
---|
202 | // write out the parameter table
|
---|
203 | cerr << "Parameter table for " << numParams << " columns and "
|
---|
204 | << paramRows << " rows:\n";
|
---|
205 | for (int j = 0; j < paramRows; j++) {
|
---|
206 | for (i = 0; i < numParams; i++) {
|
---|
207 | if (params[i][j] != NULL)
|
---|
208 | cerr << params[i][j];
|
---|
209 | else
|
---|
210 | cerr << "NULL";
|
---|
211 | cerr << "\t";
|
---|
212 | }
|
---|
213 | cerr << "\n";
|
---|
214 | }
|
---|
215 | cerr << "Params done.\n" << flush;
|
---|
216 | #endif // _DEBUG_PARAMS
|
---|
217 | }
|
---|
218 |
|
---|
219 | bool
|
---|
220 | Environment::GetParam(const char name,
|
---|
221 | const int index,
|
---|
222 | char *value) const
|
---|
223 | {
|
---|
224 | int column;
|
---|
225 |
|
---|
226 | if (index >= paramRows || index < 0)
|
---|
227 | return false;
|
---|
228 | if (name == ' ')
|
---|
229 | column = 0;
|
---|
230 | else {
|
---|
231 | char *t = strchr(optionalParams, name);
|
---|
232 |
|
---|
233 | if (t == NULL)
|
---|
234 | return false;
|
---|
235 | column = t - optionalParams + 1;
|
---|
236 | }
|
---|
237 |
|
---|
238 | if (params[column][index] == NULL)
|
---|
239 | return false;
|
---|
240 | // value = new char[strlen(params[column][index]) + 1];
|
---|
241 | strcpy(value, params[column][index]);
|
---|
242 | return true;
|
---|
243 | }
|
---|
244 |
|
---|
245 | void
|
---|
246 | Environment::RegisterOption(const char *name,
|
---|
247 | const EOptType type,
|
---|
248 | const char *abbrev,
|
---|
249 | const char *defValue)
|
---|
250 | {
|
---|
251 | int i;
|
---|
252 |
|
---|
253 | // make sure this option was not yet registered
|
---|
254 | for (i = 0; i < numOptions; i++)
|
---|
255 | if (!strcmp(name, options[i].name)) {
|
---|
256 | Debug << "Error: Option " << name << " registered twice.\n";
|
---|
257 | exit(1);
|
---|
258 | }
|
---|
259 | // make sure we have enough room in memory
|
---|
260 | if (numOptions >= maxOptions) {
|
---|
261 | Debug << "Error: Too many options. Try enlarge the maxOptions "
|
---|
262 | << "definition.\n";
|
---|
263 | exit(1);
|
---|
264 | }
|
---|
265 |
|
---|
266 | // make sure the abbreviation doesn't start with 'D'
|
---|
267 | if (abbrev != NULL && (abbrev[0] == 'D' )) {
|
---|
268 | Debug << "Internal error: reserved switch " << abbrev
|
---|
269 | << " used as an abbreviation.\n";
|
---|
270 | exit(1);
|
---|
271 | }
|
---|
272 | // new option
|
---|
273 | options[numOptions].type = type;
|
---|
274 | options[numOptions].name = ::strdup(name);
|
---|
275 | // assign abbreviation, if requested
|
---|
276 | if (abbrev != NULL) {
|
---|
277 | options[numOptions].abbrev = ::strdup(abbrev);
|
---|
278 | }
|
---|
279 | // assign default value, if requested
|
---|
280 | if (defValue != NULL) {
|
---|
281 | options[numOptions].defaultValue = ::strdup(defValue);
|
---|
282 | if (!CheckType(defValue, type)) {
|
---|
283 | Debug << "Internal error: Inconsistent type and default value in option "
|
---|
284 | << name << ".\n";
|
---|
285 | exit(1);
|
---|
286 | }
|
---|
287 | }
|
---|
288 | // new option registered
|
---|
289 | numOptions++;
|
---|
290 | }
|
---|
291 |
|
---|
292 | bool
|
---|
293 | Environment::OptionPresent(const char *name) const
|
---|
294 | {
|
---|
295 | bool found = false;
|
---|
296 | int i;
|
---|
297 |
|
---|
298 | for (i = 0; i < numOptions; i++)
|
---|
299 | if (!strcmp(options[i].name, name)) {
|
---|
300 | found = true;
|
---|
301 | break;
|
---|
302 | }
|
---|
303 | if (!found) {
|
---|
304 | Debug << "Internal error: Option " << name << " not registered.\n" << flush;
|
---|
305 | exit(1);
|
---|
306 | }
|
---|
307 | if (options[i].value != NULL || options[i].defaultValue != NULL)
|
---|
308 | return true;
|
---|
309 | else
|
---|
310 | return false;
|
---|
311 | }
|
---|
312 |
|
---|
313 | int
|
---|
314 | Environment::FindOption(const char *name,
|
---|
315 | const bool isFatal) const
|
---|
316 | {
|
---|
317 | int i;
|
---|
318 | bool found = false;
|
---|
319 | // is this option registered ?
|
---|
320 | for (i = 0; i < numOptions; i++)
|
---|
321 | if (!strcmp(options[i].name, name)) {
|
---|
322 | found = true;
|
---|
323 | break;
|
---|
324 | }
|
---|
325 | if (!found) {
|
---|
326 | // no registration found
|
---|
327 | Debug << "Internal error: Required option " << name
|
---|
328 | << " not registered.\n" << flush;
|
---|
329 | exit(1);
|
---|
330 | }
|
---|
331 | if (options[i].value == NULL && options[i].defaultValue == NULL)
|
---|
332 | // this option was not initialised to some value
|
---|
333 | if (isFatal) {
|
---|
334 | Debug << "Error: Required option " << name << " not found.\n" << flush;
|
---|
335 | exit(1);
|
---|
336 | }
|
---|
337 | else {
|
---|
338 | Debug << "Error: Required option " << name << " not found.\n" << flush;
|
---|
339 | return -1;
|
---|
340 | }
|
---|
341 | return i;
|
---|
342 | }
|
---|
343 |
|
---|
344 | bool
|
---|
345 | Environment::GetIntValue(const char *name,
|
---|
346 | int &value,
|
---|
347 | const bool isFatal) const
|
---|
348 | {
|
---|
349 | int i = FindOption(name, isFatal);
|
---|
350 |
|
---|
351 | if (i<0)
|
---|
352 | return false;
|
---|
353 |
|
---|
354 | if (options[i].value != NULL) {
|
---|
355 | // option was explicitly specified
|
---|
356 | value = strtol(options[i].value, NULL, 10);
|
---|
357 | } else {
|
---|
358 | // option was not read, so use the default
|
---|
359 | value = strtol(options[i].defaultValue, NULL, 10);
|
---|
360 | }
|
---|
361 |
|
---|
362 | return true;
|
---|
363 | }
|
---|
364 |
|
---|
365 | bool
|
---|
366 | Environment::GetDoubleValue(const char *name,
|
---|
367 | double &value,
|
---|
368 | const bool isFatal) const
|
---|
369 | {
|
---|
370 | int i = FindOption(name, isFatal);
|
---|
371 |
|
---|
372 | if (i<0)
|
---|
373 | return false;
|
---|
374 |
|
---|
375 | if (options[i].value != NULL) {
|
---|
376 | // option was explicitly specified
|
---|
377 | value = strtod(options[i].value, NULL);
|
---|
378 | } else {
|
---|
379 | // option was not read, so use the default
|
---|
380 | value = strtod(options[i].defaultValue, NULL);
|
---|
381 | }
|
---|
382 | return true;
|
---|
383 | }
|
---|
384 |
|
---|
385 | bool
|
---|
386 | Environment::GetRealValue(const char *name,
|
---|
387 | Real &value,
|
---|
388 | const bool isFatal) const
|
---|
389 | {
|
---|
390 | int i = FindOption(name, isFatal);
|
---|
391 |
|
---|
392 | if (i<0)
|
---|
393 | return false;
|
---|
394 |
|
---|
395 | if (options[i].value != NULL) {
|
---|
396 | // option was explicitly specified
|
---|
397 | value = (Real)strtod(options[i].value, NULL);
|
---|
398 | } else {
|
---|
399 | // option was not read, so use the default
|
---|
400 | value = (Real)strtod(options[i].defaultValue, NULL);
|
---|
401 | }
|
---|
402 | return true;
|
---|
403 | }
|
---|
404 |
|
---|
405 | bool
|
---|
406 | Environment::GetFloatValue(const char *name,
|
---|
407 | float &value,
|
---|
408 | const bool isFatal) const
|
---|
409 | {
|
---|
410 | int i = FindOption(name, isFatal);
|
---|
411 |
|
---|
412 | if (i<0)
|
---|
413 | return false;
|
---|
414 |
|
---|
415 | if (options[i].value != NULL) {
|
---|
416 | // option was explicitly specified
|
---|
417 | value = (float)strtod(options[i].value, NULL);
|
---|
418 | } else {
|
---|
419 | // option was not read, so use the default
|
---|
420 | value = (float)strtod(options[i].defaultValue, NULL);
|
---|
421 | }
|
---|
422 | return true;
|
---|
423 | }
|
---|
424 |
|
---|
425 | bool
|
---|
426 | Environment::GetBool(const char *name,
|
---|
427 | const bool isFatal) const
|
---|
428 | {
|
---|
429 | bool ret;
|
---|
430 | if (GetBoolValue(name, ret, isFatal))
|
---|
431 | return ret;
|
---|
432 | else
|
---|
433 | return false;
|
---|
434 | }
|
---|
435 |
|
---|
436 | bool
|
---|
437 | Environment::ParseBool(const char *name) const
|
---|
438 | {
|
---|
439 |
|
---|
440 | bool value = true;
|
---|
441 |
|
---|
442 | if (!strcasecmp(name, "false") ||
|
---|
443 | !strcasecmp(name, "NO") ||
|
---|
444 | !strcmp(name, "-") ||
|
---|
445 | !strcasecmp(name, "OFF"))
|
---|
446 | value = false;
|
---|
447 |
|
---|
448 | return value;
|
---|
449 | }
|
---|
450 |
|
---|
451 | void
|
---|
452 | Environment::ParseVector(const char *name, Vector3 &v) const
|
---|
453 | {
|
---|
454 | // option was not read, so use the default
|
---|
455 | char *s, *t;
|
---|
456 |
|
---|
457 | v.x = (Real)strtod(name, &s);
|
---|
458 | v.y = (Real)strtod(s + 1, &t);
|
---|
459 | v.z = (Real)strtod(t + 1, NULL);
|
---|
460 |
|
---|
461 | }
|
---|
462 |
|
---|
463 | bool
|
---|
464 | Environment::GetBoolValue(const char *name,
|
---|
465 | bool &value,
|
---|
466 | const bool isFatal) const
|
---|
467 | {
|
---|
468 | int i = FindOption(name, isFatal);
|
---|
469 |
|
---|
470 | if (i<0)
|
---|
471 | return false;
|
---|
472 |
|
---|
473 |
|
---|
474 | if (options[i].value != NULL)
|
---|
475 | value = ParseBool(options[i].value);
|
---|
476 | else
|
---|
477 | value = ParseBool(options[i].defaultValue);
|
---|
478 |
|
---|
479 | return true;
|
---|
480 | }
|
---|
481 |
|
---|
482 | bool
|
---|
483 | Environment::GetVectorValue(const char *name,
|
---|
484 | Vector3 &v,
|
---|
485 | const bool isFatal) const
|
---|
486 | {
|
---|
487 | int i = FindOption(name, isFatal);
|
---|
488 | if (i<0)
|
---|
489 | return false;
|
---|
490 |
|
---|
491 | if (options[i].value != NULL)
|
---|
492 |
|
---|
493 |
|
---|
494 | if (options[i].value != NULL) {
|
---|
495 | ParseVector(options[i].value, v);
|
---|
496 | }
|
---|
497 | else {
|
---|
498 | ParseVector(options[i].defaultValue, v);
|
---|
499 | }
|
---|
500 | return true;
|
---|
501 | }
|
---|
502 |
|
---|
503 | bool
|
---|
504 | Environment::GetStringValue(const char *name,
|
---|
505 | char *value,
|
---|
506 | const bool isFatal) const
|
---|
507 | {
|
---|
508 | int i = FindOption(name, isFatal);
|
---|
509 |
|
---|
510 | if (i<0)
|
---|
511 | return false;
|
---|
512 |
|
---|
513 |
|
---|
514 | if (options[i].value != NULL) {
|
---|
515 | // option was not read, so use the default
|
---|
516 | strcpy(value, options[i].value);
|
---|
517 | }
|
---|
518 | else {
|
---|
519 | // option was explicitly specified
|
---|
520 | strcpy(value, options[i].defaultValue);
|
---|
521 | }
|
---|
522 | return true;
|
---|
523 | }
|
---|
524 |
|
---|
525 | void
|
---|
526 | Environment::SetInt(const char *name, const int value)
|
---|
527 | {
|
---|
528 |
|
---|
529 | int i = FindOption(name);
|
---|
530 | if (i<0)
|
---|
531 | return;
|
---|
532 |
|
---|
533 | if (options[i].type == optInt) {
|
---|
534 | delete options[i].value;
|
---|
535 | options[i].value = new char[16];
|
---|
536 | sprintf(options[i].value, "%.15d", value);
|
---|
537 | }
|
---|
538 | else {
|
---|
539 | Debug << "Internal error: Trying to set non-integer option " << name
|
---|
540 | << " to integral value.\n" << flush;
|
---|
541 | exit(1);
|
---|
542 | }
|
---|
543 | }
|
---|
544 |
|
---|
545 | void
|
---|
546 | Environment::SetFloat(const char *name, const Real value)
|
---|
547 | {
|
---|
548 | int i = FindOption(name);
|
---|
549 | if (i<0)
|
---|
550 | return;
|
---|
551 |
|
---|
552 | if (options[i].type == optFloat) {
|
---|
553 | delete options[i].value;
|
---|
554 | options[i].value = new char[25];
|
---|
555 | sprintf(options[i].value, "%.15e", value);
|
---|
556 | }
|
---|
557 | else {
|
---|
558 | Debug << "Internal error: Trying to set non-Real option " << name
|
---|
559 | << " to Real value.\n" << flush;
|
---|
560 | exit(1);
|
---|
561 | }
|
---|
562 | }
|
---|
563 |
|
---|
564 | void
|
---|
565 | Environment::SetBool(const char *name, const bool value)
|
---|
566 | {
|
---|
567 | int i = FindOption(name);
|
---|
568 | if (i<0)
|
---|
569 | return;
|
---|
570 |
|
---|
571 | if (options[i].type == optBool) {
|
---|
572 | delete options[i].value;
|
---|
573 | options[i].value = new char[6];
|
---|
574 | if (value)
|
---|
575 | sprintf(options[i].value, "true");
|
---|
576 | else
|
---|
577 | sprintf(options[i].value, "false");
|
---|
578 | }
|
---|
579 | else {
|
---|
580 | Debug << "Internal error: Trying to set non-bool option " << name
|
---|
581 | << " to boolean value.\n" << flush;
|
---|
582 | exit(1);
|
---|
583 | }
|
---|
584 | }
|
---|
585 |
|
---|
586 | void
|
---|
587 | Environment::SetVector(const char *name,
|
---|
588 | const Vector3 &v)
|
---|
589 | {
|
---|
590 | int i = FindOption(name);
|
---|
591 | if (i<0)
|
---|
592 | return;
|
---|
593 |
|
---|
594 | if (options[i].type == optVector) {
|
---|
595 | delete options[i].value;
|
---|
596 | options[i].value = new char[128];
|
---|
597 | sprintf(options[i].value, "%.15e,%.15e,%.15e", v.x, v.y, v.z);
|
---|
598 | }
|
---|
599 | else {
|
---|
600 | Debug << "Internal error: Trying to set non-vector option " << name
|
---|
601 | << " to vector value.\n" << flush;
|
---|
602 | exit(1);
|
---|
603 | }
|
---|
604 | }
|
---|
605 |
|
---|
606 | void
|
---|
607 | Environment::SetString(const char *name, const char *value)
|
---|
608 | {
|
---|
609 | int i = FindOption(name);
|
---|
610 | if (i<0)
|
---|
611 | return;
|
---|
612 |
|
---|
613 | if (options[i].type == optString) {
|
---|
614 | delete options[i].value;
|
---|
615 | options[i].value = ::strdup(value);
|
---|
616 | }
|
---|
617 | else {
|
---|
618 | Debug << "Internal error: Trying to set non-string option " << name
|
---|
619 | << " to string value.\n" << flush;
|
---|
620 | exit(1);
|
---|
621 | }
|
---|
622 | }
|
---|
623 |
|
---|
624 | void
|
---|
625 | Environment::ParseCmdline(const int argc,
|
---|
626 | char **argv,
|
---|
627 | const int index)
|
---|
628 | {
|
---|
629 | int curIndex = -1;
|
---|
630 |
|
---|
631 | for (int i = 1; i < argc; i++) {
|
---|
632 | // if this parameter is non-optional, skip it and increment the counter
|
---|
633 | if (argv[i][0] != '-') {
|
---|
634 | curIndex++;
|
---|
635 | continue;
|
---|
636 | }
|
---|
637 | // make sure to skip all non-optional parameters
|
---|
638 | char *t = strchr(optionalParams, argv[i][1]);
|
---|
639 | if (t != NULL)
|
---|
640 | continue;
|
---|
641 |
|
---|
642 | // if we are in the scope of the current parameter, parse it
|
---|
643 | if (curIndex == -1 || curIndex == index) {
|
---|
644 | if (argv[i][1] == 'D') {
|
---|
645 | // it's a full name definition
|
---|
646 | bool found = false;
|
---|
647 | int j;
|
---|
648 |
|
---|
649 | char *t = strchr(argv[i] + 2, '=');
|
---|
650 | if (t == NULL) {
|
---|
651 | Debug << "Error: Missing '=' in option. "
|
---|
652 | << "Syntax is -D<name>=<value>.\n" << flush;
|
---|
653 | exit(1);
|
---|
654 | }
|
---|
655 | for (j = 0; j < numOptions; j++)
|
---|
656 | if (!strncmp(options[j].name, argv[i] + 2, t - argv[i] - 2) &&
|
---|
657 | (unsigned)(t - argv[i] - 2) == strlen(options[j].name)) {
|
---|
658 | found = true;
|
---|
659 | break;
|
---|
660 | }
|
---|
661 | if (!found) {
|
---|
662 | Debug << "Warning: Unregistered option " << argv[i] << ".\n" << flush;
|
---|
663 | // exit(1);
|
---|
664 | }
|
---|
665 | if (found) {
|
---|
666 | if (!CheckType(t + 1, options[j].type)) {
|
---|
667 | Debug << "Error: invalid type of value " << t + 1 << " in option "
|
---|
668 | << options[j].name << ".\n";
|
---|
669 | exit(1);
|
---|
670 | }
|
---|
671 | if (options[j].value != NULL)
|
---|
672 | delete options[j].value;
|
---|
673 | options[j].value = strdup(t + 1);
|
---|
674 | }
|
---|
675 | }
|
---|
676 | else {
|
---|
677 | // it's an abbreviation
|
---|
678 | bool found = false;
|
---|
679 | int j;
|
---|
680 |
|
---|
681 | for (j = 0; j < numOptions; j++)
|
---|
682 | if (options[j].abbrev != NULL &&
|
---|
683 | !strncmp(options[j].abbrev, argv[i] + 1, strlen(options[j].abbrev))) {
|
---|
684 | found = true;
|
---|
685 | break;
|
---|
686 | }
|
---|
687 | if (!found) {
|
---|
688 | Debug << "Warning: Unregistered option " << argv[i] << ".\n" << flush;
|
---|
689 | // exit(1);
|
---|
690 | }
|
---|
691 | if (found) {
|
---|
692 | if (!CheckType(argv[i] + 1 + strlen(options[j].abbrev), options[j].type)) {
|
---|
693 | Debug << "Error: invalid type of value "
|
---|
694 | << argv[i] + 1 + strlen(options[j].abbrev) << "in option "
|
---|
695 | << options[j].name << ".\n";
|
---|
696 | exit(1);
|
---|
697 | }
|
---|
698 | if (options[j].value != NULL)
|
---|
699 | delete options[j].value;
|
---|
700 | options[j].value = strdup(argv[i] + 1 + strlen(options[j].abbrev));
|
---|
701 | }
|
---|
702 | }
|
---|
703 | }
|
---|
704 | }
|
---|
705 | #ifdef _DEBUG_PARAMS
|
---|
706 | // write out the options table
|
---|
707 | cerr << "Options table for " << numOptions << " options:\n";
|
---|
708 | for (int j = 0; j < numOptions; j++) {
|
---|
709 | cerr << options[j];
|
---|
710 | cerr << "\n";
|
---|
711 | }
|
---|
712 | cerr << "Options done.\n" << flush;
|
---|
713 | #endif // _DEBUG_PARAMS
|
---|
714 | }
|
---|
715 |
|
---|
716 |
|
---|
717 | char *
|
---|
718 | Environment::ParseString(char *buffer, char *string) const
|
---|
719 | {
|
---|
720 | char *s = buffer;
|
---|
721 | char *t = string + strlen(string);
|
---|
722 |
|
---|
723 | // skip leading whitespaces
|
---|
724 | while (*s == ' ' || *s == '\t')
|
---|
725 | s++;
|
---|
726 | if (*s == '\0')
|
---|
727 | return NULL;
|
---|
728 | while ((*s >= 'a' && *s <= 'z') ||
|
---|
729 | (*s >= 'A' && *s <= 'Z') ||
|
---|
730 | (*s >= '0' && *s <= '9') ||
|
---|
731 | *s == '_')
|
---|
732 | *t++ = *s++;
|
---|
733 | *t = '\0';
|
---|
734 | // skip trailing whitespaces
|
---|
735 | while (*s == ' ' || *s == '\t')
|
---|
736 | s++;
|
---|
737 | return s;
|
---|
738 | }
|
---|
739 |
|
---|
740 | const char code[] = "JIDHipewhfdhyd74387hHO&{WK:DOKQEIDKJPQ*H#@USX:#FWCQ*EJMQAHPQP(@G#RD";
|
---|
741 |
|
---|
742 | void
|
---|
743 | Environment::DecodeString(char *buff, int max)
|
---|
744 | {
|
---|
745 | buff[max] = 0;
|
---|
746 | char *p = buff;
|
---|
747 | const char *cp = code;
|
---|
748 | for (; *p; p++) {
|
---|
749 | if (*p != '\n')
|
---|
750 | *p = *p ^ *cp;
|
---|
751 | ++cp;
|
---|
752 | if (*cp == 0)
|
---|
753 | cp = code;
|
---|
754 | }
|
---|
755 | }
|
---|
756 |
|
---|
757 | void
|
---|
758 | Environment::CodeString(char *buff, int max)
|
---|
759 | {
|
---|
760 | buff[max] = 0;
|
---|
761 | char *p = buff;
|
---|
762 | const char *cp = code;
|
---|
763 | for (; *p; p++) {
|
---|
764 | if (*p != '\n')
|
---|
765 | *p = *p ^ *cp;
|
---|
766 | ++cp;
|
---|
767 | if (*cp == 0)
|
---|
768 | cp = code;
|
---|
769 | }
|
---|
770 | }
|
---|
771 |
|
---|
772 | void
|
---|
773 | Environment::SaveCodedFile(char *filenameText,
|
---|
774 | char *filenameCoded)
|
---|
775 | {
|
---|
776 | ifstream envStream(filenameText);
|
---|
777 |
|
---|
778 | // some error had occured
|
---|
779 | if (envStream.fail()) {
|
---|
780 | cerr << "Error: Can't open file " << filenameText << " for reading (err. "
|
---|
781 | << envStream.rdstate() << ").\n";
|
---|
782 | return;
|
---|
783 | }
|
---|
784 | char buff[256];
|
---|
785 | envStream.getline(buff, 255);
|
---|
786 | buff[8] = 0;
|
---|
787 | if (strcmp(buff, "CGX_CF10") == 0)
|
---|
788 | return;
|
---|
789 |
|
---|
790 | ofstream cStream(filenameCoded);
|
---|
791 | cStream<<"CGX_CF10";
|
---|
792 |
|
---|
793 | // main loop
|
---|
794 | for (;;) {
|
---|
795 | // read in one line
|
---|
796 | envStream.getline(buff, 255);
|
---|
797 | if (!envStream)
|
---|
798 | break;
|
---|
799 | CodeString(buff, 255);
|
---|
800 | cStream<<buff;
|
---|
801 | }
|
---|
802 |
|
---|
803 | }
|
---|
804 |
|
---|
805 | bool
|
---|
806 | Environment::ReadEnvFile(const char *envFilename)
|
---|
807 | {
|
---|
808 | char buff[MaxStringLength], name[MaxStringLength];
|
---|
809 | char *s, *t;
|
---|
810 | int i, line = 0;
|
---|
811 | bool found;
|
---|
812 | igzstream envStream(envFilename);
|
---|
813 |
|
---|
814 | // some error had occured
|
---|
815 | if (envStream.fail()) {
|
---|
816 | cerr << "Error: Can't open file " << envFilename << " for reading (err. "
|
---|
817 | << envStream.rdstate() << ").\n";
|
---|
818 | return false;
|
---|
819 | }
|
---|
820 |
|
---|
821 | name[0] = '\0';
|
---|
822 |
|
---|
823 | // bool coded;
|
---|
824 | // envStream.getline(buff, 255);
|
---|
825 | // buff[8] = 0;
|
---|
826 | // if (strcmp(buff, "CGX_CF10") == 0)
|
---|
827 | // coded = true;
|
---|
828 | // else {
|
---|
829 | // coded = false;
|
---|
830 | // envStream.Rewind();
|
---|
831 | // }
|
---|
832 |
|
---|
833 | // main loop
|
---|
834 | for (;;) {
|
---|
835 | // read in one line
|
---|
836 | envStream.getline(buff, 255);
|
---|
837 |
|
---|
838 | if (!envStream)
|
---|
839 | break;
|
---|
840 |
|
---|
841 | // if (coded)
|
---|
842 | // DecodeString(buff, 255);
|
---|
843 |
|
---|
844 | line++;
|
---|
845 | // get rid of comments
|
---|
846 | s = strchr(buff, '#');
|
---|
847 | if (s != NULL)
|
---|
848 | *s = '\0';
|
---|
849 |
|
---|
850 | // get one identifier
|
---|
851 | s = ParseString(buff, name);
|
---|
852 | // parse line
|
---|
853 | while (s != NULL) {
|
---|
854 | // it's a group name - make the full name
|
---|
855 | if (*s == '{') {
|
---|
856 | strcat(name, ".");
|
---|
857 | s++;
|
---|
858 | s = ParseString(s, name);
|
---|
859 | continue;
|
---|
860 | }
|
---|
861 | // end of group
|
---|
862 | if (*s == '}') {
|
---|
863 | if (strlen(name) == 0) {
|
---|
864 | cerr << "Error: unpaired } in " << envFilename << " (line "
|
---|
865 | << line << ").\n";
|
---|
866 | envStream.close();
|
---|
867 | return false;
|
---|
868 | }
|
---|
869 | name[strlen(name) - 1] = '\0';
|
---|
870 | t = strrchr(name, '.');
|
---|
871 | if (t == NULL)
|
---|
872 | name[0] = '\0';
|
---|
873 | else
|
---|
874 | *(t + 1) = '\0';
|
---|
875 | s++;
|
---|
876 | s = ParseString(s, name);
|
---|
877 | continue;
|
---|
878 | }
|
---|
879 | // find variable name in the table
|
---|
880 | found = false;
|
---|
881 | for (i = 0; i < numOptions; i++)
|
---|
882 | if (!strcmp(name, options[i].name)) {
|
---|
883 | found = true;
|
---|
884 | break;
|
---|
885 | }
|
---|
886 | if (!found) {
|
---|
887 | cerr << "Warning: unknown option " << name << " in environment file "
|
---|
888 | << envFilename << " (line " << line << ").\n";
|
---|
889 | } else
|
---|
890 | switch (options[i].type) {
|
---|
891 | case optInt: {
|
---|
892 | strtol(s, &t, 10);
|
---|
893 | if (t == s || (*t != ' ' && *t != '\t' &&
|
---|
894 | *t != '\0' && *t != '}')) {
|
---|
895 | cerr << "Error: Mismatch in int variable " << name << " in "
|
---|
896 | << "environment file " << envFilename << " (line "
|
---|
897 | << line << ").\n";
|
---|
898 | envStream.close();
|
---|
899 | return false;
|
---|
900 | }
|
---|
901 | if (options[i].value != NULL)
|
---|
902 | delete options[i].value;
|
---|
903 | options[i].value = new char[t - s + 1];
|
---|
904 | strncpy(options[i].value, s, t - s);
|
---|
905 | options[i].value[t - s] = '\0';
|
---|
906 | s = t;
|
---|
907 | break;
|
---|
908 | }
|
---|
909 | case optFloat: {
|
---|
910 | strtod(s, &t);
|
---|
911 | if (t == s || (*t != ' ' && *t != '\t' &&
|
---|
912 | *t != '\0' && *t != '}')) {
|
---|
913 | cerr << "Error: Mismatch in Real variable " << name << " in "
|
---|
914 | << "environment file " << envFilename << " (line "
|
---|
915 | << line << ").\n";
|
---|
916 | envStream.close();
|
---|
917 | return false;
|
---|
918 | }
|
---|
919 | if (options[i].value != NULL)
|
---|
920 | delete options[i].value;
|
---|
921 | options[i].value = new char[t - s + 1];
|
---|
922 | strncpy(options[i].value, s, t - s);
|
---|
923 | options[i].value[t - s] = '\0';
|
---|
924 | s = t;
|
---|
925 | break;
|
---|
926 | }
|
---|
927 | case optBool: {
|
---|
928 | t = s;
|
---|
929 | while ((*t >= 'a' && *t <= 'z') ||
|
---|
930 | (*t >= 'A' && *t <= 'Z') ||
|
---|
931 | *t == '+' || *t == '-')
|
---|
932 | t++;
|
---|
933 | if (((!strncasecmp(s, "true", t - s) && t - s == 4) ||
|
---|
934 | (!strncasecmp(s, "false", t - s) && t - s == 5) ||
|
---|
935 | (!strncasecmp(s, "YES", t -s) && t - s == 3) ||
|
---|
936 | (!strncasecmp(s, "NO", t - s) && t - s == 2) ||
|
---|
937 | (!strncasecmp(s, "ON", t - s) && t - s == 2) ||
|
---|
938 | (!strncasecmp(s, "OFF", t - s) && t - s == 3) ||
|
---|
939 | (t - s == 1 && (*s == '+' || *s == '-'))) &&
|
---|
940 | (*t == ' ' || *t == '\t' || *t == '\0' || *t == '}')) {
|
---|
941 | if (options[i].value != NULL)
|
---|
942 | delete options[i].value;
|
---|
943 | options[i].value = new char[t - s + 1];
|
---|
944 | strncpy(options[i].value, s, t - s);
|
---|
945 | options[i].value[t - s] = '\0';
|
---|
946 | s = t;
|
---|
947 | }
|
---|
948 | else {
|
---|
949 | cerr << "Error: Mismatch in bool variable " << name << " in "
|
---|
950 | << "environment file " << envFilename << " (line "
|
---|
951 | << line << ").\n";
|
---|
952 | envStream.close();
|
---|
953 | return false;
|
---|
954 | }
|
---|
955 | break;
|
---|
956 | }
|
---|
957 | case optVector:{
|
---|
958 | strtod(s, &t);
|
---|
959 | if (*t == ' ' || *t == '\t') {
|
---|
960 | while (*t == ' ' || *t == '\t')
|
---|
961 | t++;
|
---|
962 | if (*t != ',')
|
---|
963 | t--;
|
---|
964 | }
|
---|
965 | if (t == s || (*t != ' ' && *t != '\t' && *t != ',')) {
|
---|
966 | cerr << "Error: Mismatch in vector variable " << name << " in "
|
---|
967 | << "environment file " << envFilename << " (line "
|
---|
968 | << line << ").\n";
|
---|
969 | envStream.close();
|
---|
970 | return false;
|
---|
971 | }
|
---|
972 | char *u;
|
---|
973 | strtod(t, &u);
|
---|
974 | t = u;
|
---|
975 | if (*t == ' ' || *t == '\t') {
|
---|
976 | while (*t == ' ' || *t == '\t')
|
---|
977 | t++;
|
---|
978 | if (*t != ',')
|
---|
979 | t--;
|
---|
980 | }
|
---|
981 | if (t == s || (*t != ' ' && *t != '\t' && *t != ',')) {
|
---|
982 | cerr << "Error: Mismatch in vector variable " << name << " in "
|
---|
983 | << "environment file " << envFilename << " (line "
|
---|
984 | << line << ").\n";
|
---|
985 | envStream.close();
|
---|
986 | return false;
|
---|
987 | }
|
---|
988 | strtod(t, &u);
|
---|
989 | t = u;
|
---|
990 | if (t == s || (*t != ' ' && *t != '\t' &&
|
---|
991 | *t != '\0' && *t != '}')) {
|
---|
992 | cerr << "Error: Mismatch in vector variable " << name << " in "
|
---|
993 | << "environment file " << envFilename << " (line "
|
---|
994 | << line << ").\n";
|
---|
995 | envStream.close();
|
---|
996 | return false;
|
---|
997 | }
|
---|
998 | if (options[i].value != NULL)
|
---|
999 | delete options[i].value;
|
---|
1000 | options[i].value = new char[t - s + 1];
|
---|
1001 | strncpy(options[i].value, s, t - s);
|
---|
1002 | options[i].value[t - s] = '\0';
|
---|
1003 | s = t;
|
---|
1004 | break;
|
---|
1005 | }
|
---|
1006 | case optString: {
|
---|
1007 | if (options[i].value != NULL)
|
---|
1008 | delete options[i].value;
|
---|
1009 | options[i].value = new char[strlen(s) + 1];
|
---|
1010 | strcpy(options[i].value, s);
|
---|
1011 | s += strlen(s);
|
---|
1012 | break;
|
---|
1013 | }
|
---|
1014 | default: {
|
---|
1015 | Debug << "Internal error: Unknown type of option.\n" << flush;
|
---|
1016 | exit(1);
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 | // prepare the variable name for next pass
|
---|
1020 | t = strrchr(name, '.');
|
---|
1021 | if (t == NULL)
|
---|
1022 | name[0] = '\0';
|
---|
1023 | else
|
---|
1024 | *(t + 1) = '\0';
|
---|
1025 | // get next identifier
|
---|
1026 | s = ParseString(s, name);
|
---|
1027 | }
|
---|
1028 | }
|
---|
1029 | envStream.close();
|
---|
1030 | return true;
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | void
|
---|
1034 | Environment::PrintUsage(ostream &s) const
|
---|
1035 | {
|
---|
1036 | // Print out all environment variable names
|
---|
1037 | s << "Registered options:\n";
|
---|
1038 | for (int j = 0; j < numOptions; j++)
|
---|
1039 | s << options[j] << "\n";
|
---|
1040 | s << flush;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 | /**
|
---|
1044 | Input scene filename. Currently simplified X3D (.x3d), Unigraphics (.dat),
|
---|
1045 | and UNC (.ply) formats are supported.
|
---|
1046 | */
|
---|
1047 |
|
---|
1048 | Environment::Environment()
|
---|
1049 | {
|
---|
1050 | optionalParams = NULL;
|
---|
1051 | paramRows = 0;
|
---|
1052 | numParams = 0;
|
---|
1053 | params = NULL;
|
---|
1054 | maxOptions = 500;
|
---|
1055 |
|
---|
1056 |
|
---|
1057 | // this is maximal nuber of options.
|
---|
1058 | numOptions = 0;
|
---|
1059 |
|
---|
1060 | options = new COption[maxOptions];
|
---|
1061 |
|
---|
1062 | if (options == NULL ) {
|
---|
1063 | Debug << "Error: Memory allocation failed.\n";
|
---|
1064 | exit(1);
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | // register all basic options
|
---|
1068 |
|
---|
1069 | RegisterOption("Limits.threshold", optFloat, NULL, "0.01");
|
---|
1070 | RegisterOption("Limits.small", optFloat, NULL, "1e-6");
|
---|
1071 | RegisterOption("Limits.infinity", optFloat, NULL, "1e6");
|
---|
1072 |
|
---|
1073 | RegisterOption("Scene.filename",
|
---|
1074 | optString,
|
---|
1075 | "scene_filename=",
|
---|
1076 | "atlanta2.x3d");
|
---|
1077 |
|
---|
1078 |
|
---|
1079 | RegisterOption("Unigraphics.meshGrouping",
|
---|
1080 | optInt,
|
---|
1081 | "unigraphics_mesh_grouping=",
|
---|
1082 | "0");
|
---|
1083 |
|
---|
1084 |
|
---|
1085 | RegisterOption("KdTree.Termination.minCost",
|
---|
1086 | optInt,
|
---|
1087 | "kd_term_min_cost=",
|
---|
1088 | "10");
|
---|
1089 |
|
---|
1090 | RegisterOption("KdTree.Termination.maxNodes",
|
---|
1091 | optInt,
|
---|
1092 | "kd_term_max_nodes=",
|
---|
1093 | "200000");
|
---|
1094 |
|
---|
1095 | RegisterOption("KdTree.Termination.maxDepth",
|
---|
1096 | optInt,
|
---|
1097 | "kd_term_max_depth=",
|
---|
1098 | "20");
|
---|
1099 |
|
---|
1100 | RegisterOption("KdTree.Termination.maxCostRatio",
|
---|
1101 | optFloat,
|
---|
1102 | "kd_term_max_cost_ratio=",
|
---|
1103 | "1.5");
|
---|
1104 |
|
---|
1105 | RegisterOption("KdTree.Termination.ct_div_ci",
|
---|
1106 | optFloat,
|
---|
1107 | "kd_term_ct_div_ci=",
|
---|
1108 | "1.0");
|
---|
1109 |
|
---|
1110 | RegisterOption("KdTree.splitMethod",
|
---|
1111 | optString,
|
---|
1112 | "kd_split_method=",
|
---|
1113 | "spatialMedian");
|
---|
1114 |
|
---|
1115 | RegisterOption("KdTree.splitBorder",
|
---|
1116 | optFloat,
|
---|
1117 | "kd_split_border=",
|
---|
1118 | "0.1");
|
---|
1119 |
|
---|
1120 | RegisterOption("KdTree.sahUseFaces",
|
---|
1121 | optBool,
|
---|
1122 | "kd_sah_use_faces=",
|
---|
1123 | "true");
|
---|
1124 |
|
---|
1125 |
|
---|
1126 | RegisterOption("MeshKdTree.Termination.minCost",
|
---|
1127 | optInt,
|
---|
1128 | "kd_term_min_cost=",
|
---|
1129 | "10");
|
---|
1130 |
|
---|
1131 | RegisterOption("MeshKdTree.Termination.maxDepth",
|
---|
1132 | optInt,
|
---|
1133 | "kd_term_max_depth=",
|
---|
1134 | "20");
|
---|
1135 |
|
---|
1136 | RegisterOption("MeshKdTree.Termination.maxCostRatio",
|
---|
1137 | optFloat,
|
---|
1138 | "kd_term_max_cost_ratio=",
|
---|
1139 | "1.5");
|
---|
1140 |
|
---|
1141 | RegisterOption("MeshKdTree.Termination.ct_div_ci",
|
---|
1142 | optFloat,
|
---|
1143 | "kd_term_ct_div_ci=",
|
---|
1144 | "1.0");
|
---|
1145 |
|
---|
1146 | RegisterOption("MeshKdTree.splitMethod",
|
---|
1147 | optString,
|
---|
1148 | "kd_split_method=",
|
---|
1149 | "spatialMedian");
|
---|
1150 |
|
---|
1151 | RegisterOption("MeshKdTree.splitBorder",
|
---|
1152 | optFloat,
|
---|
1153 | "kd_split_border=",
|
---|
1154 | "0.1");
|
---|
1155 |
|
---|
1156 | RegisterOption("SamplingPreprocessor.totalSamples",
|
---|
1157 | optInt,
|
---|
1158 | "total_samples=",
|
---|
1159 | "1000000");
|
---|
1160 |
|
---|
1161 | RegisterOption("SamplingPreprocessor.samplesPerPass",
|
---|
1162 | optInt,
|
---|
1163 | "samples_per_pass=",
|
---|
1164 | "10");
|
---|
1165 |
|
---|
1166 | RegisterOption("RenderSampler.samples",
|
---|
1167 | optInt,
|
---|
1168 | "render_sampler_samples=",
|
---|
1169 | "1000");
|
---|
1170 |
|
---|
1171 | RegisterOption("VssPreprocessor.initialSamples",
|
---|
1172 | optInt,
|
---|
1173 | "initial_samples=",
|
---|
1174 | "100000");
|
---|
1175 |
|
---|
1176 | RegisterOption("VssPreprocessor.testBeamSampling", optBool, "beam_sampling", "false");
|
---|
1177 |
|
---|
1178 | RegisterOption("VssPreprocessor.vssSamples",
|
---|
1179 | optInt,
|
---|
1180 | "vss_samples=",
|
---|
1181 | "1000000");
|
---|
1182 |
|
---|
1183 | RegisterOption("VssPreprocessor.vssSamplesPerPass",
|
---|
1184 | optInt,
|
---|
1185 | "vss_samples_per_pass=",
|
---|
1186 | "1000");
|
---|
1187 |
|
---|
1188 | RegisterOption("VssPreprocessor.samplesPerPass",
|
---|
1189 | optInt,
|
---|
1190 | "samples_per_pass=",
|
---|
1191 | "100000");
|
---|
1192 |
|
---|
1193 | RegisterOption("VssPreprocessor.useImportanceSampling",
|
---|
1194 | optBool,
|
---|
1195 | "vss_use_importance=",
|
---|
1196 | "true");
|
---|
1197 |
|
---|
1198 | RegisterOption("VssPreprocessor.enlargeViewSpace",
|
---|
1199 | optBool,
|
---|
1200 | "vss_enlarge_viewspace=",
|
---|
1201 | "false");
|
---|
1202 |
|
---|
1203 | RegisterOption("VssPreprocessor.loadInitialSamples",
|
---|
1204 | optBool,
|
---|
1205 | "vss_load_loadInitialSamples=",
|
---|
1206 | "false");
|
---|
1207 |
|
---|
1208 | RegisterOption("VssPreprocessor.storeInitialSamples",
|
---|
1209 | optBool,
|
---|
1210 | "vss_store_storedInitialSamples=",
|
---|
1211 | "false");
|
---|
1212 |
|
---|
1213 |
|
---|
1214 | RegisterOption("VssPreprocessor.useViewSpaceBox",
|
---|
1215 | optBool,
|
---|
1216 | "vss_use_viewspace_box=",
|
---|
1217 | "false");
|
---|
1218 |
|
---|
1219 |
|
---|
1220 | /************************************************************************************/
|
---|
1221 | /* View cells related options */
|
---|
1222 | /************************************************************************************/
|
---|
1223 |
|
---|
1224 |
|
---|
1225 | RegisterOption("ViewCells.type",
|
---|
1226 | optString,
|
---|
1227 | "view_cells_type=",
|
---|
1228 | "vspBspTree");
|
---|
1229 |
|
---|
1230 | RegisterOption("ViewCells.samplingType",
|
---|
1231 | optString,
|
---|
1232 | "view_cells_sampling_type=",
|
---|
1233 | "box");
|
---|
1234 |
|
---|
1235 | RegisterOption("ViewCells.mergeStats",
|
---|
1236 | optString,
|
---|
1237 | "view_cells_merge_stats=",
|
---|
1238 | "mergeStats.log");
|
---|
1239 |
|
---|
1240 | RegisterOption("ViewCells.Evaluation.statsPrefix",
|
---|
1241 | optString,
|
---|
1242 | "view_cells_evaluation_stats_prefix=",
|
---|
1243 | "viewCells");
|
---|
1244 |
|
---|
1245 | RegisterOption("ViewCells.Evaluation.histogram",
|
---|
1246 | optBool,
|
---|
1247 | "view_cells_evaluation_histogram=",
|
---|
1248 | "false");
|
---|
1249 |
|
---|
1250 | RegisterOption("ViewCells.Evaluation.histoPasses",
|
---|
1251 | optInt,
|
---|
1252 | "view_cells_evaluation_histo_passes=",
|
---|
1253 | "5000");
|
---|
1254 |
|
---|
1255 | RegisterOption("ViewCells.renderCostEvaluationType",
|
---|
1256 | optString,
|
---|
1257 | "view_cells_render_cost_evaluation=",
|
---|
1258 | "perobject");
|
---|
1259 |
|
---|
1260 | RegisterOption("ViewCells.active",
|
---|
1261 | optInt,
|
---|
1262 | "view_cells_active=",
|
---|
1263 | "1000");
|
---|
1264 |
|
---|
1265 | RegisterOption("ViewCells.Construction.samples",
|
---|
1266 | optInt,
|
---|
1267 | "view_cells_construction_samples=",
|
---|
1268 | "5000000");
|
---|
1269 |
|
---|
1270 | RegisterOption("ViewCells.Construction.samplesPerPass",
|
---|
1271 | optInt,
|
---|
1272 | "view_cells_construction_samples_per_pass=",
|
---|
1273 | "500000");
|
---|
1274 |
|
---|
1275 | RegisterOption("ViewCells.PostProcess.samples",
|
---|
1276 | optInt,
|
---|
1277 | "view_cells_post_process_samples=",
|
---|
1278 | "200000");
|
---|
1279 |
|
---|
1280 | RegisterOption("ViewCells.Visualization.samples",
|
---|
1281 | optInt,
|
---|
1282 | "view_cells_visualization_samples=",
|
---|
1283 | "20000");
|
---|
1284 |
|
---|
1285 | RegisterOption("ViewCells.Filter.maxSize",
|
---|
1286 | optInt,
|
---|
1287 | "view_cells_filter_max_size=",
|
---|
1288 | "4");
|
---|
1289 |
|
---|
1290 | RegisterOption("ViewCells.Filter.width",
|
---|
1291 | optFloat,
|
---|
1292 | "view_cells_filter_width=",
|
---|
1293 | "200.0");
|
---|
1294 |
|
---|
1295 | RegisterOption("ViewCells.loadFromFile",
|
---|
1296 | optBool,
|
---|
1297 | "view_cells_load_from_file=",
|
---|
1298 | "false");
|
---|
1299 |
|
---|
1300 | RegisterOption("ViewCells.PostProcess.refine",
|
---|
1301 | optBool,
|
---|
1302 | "view_cells_refine=",
|
---|
1303 | "false");
|
---|
1304 |
|
---|
1305 | RegisterOption("ViewCells.PostProcess.compress",
|
---|
1306 | optBool,
|
---|
1307 | "view_cells_post_process_compress=",
|
---|
1308 | "false");
|
---|
1309 |
|
---|
1310 | RegisterOption("ViewCells.Evaluation.samples",
|
---|
1311 | optInt,
|
---|
1312 | "view_cells_evaluation_samples=",
|
---|
1313 | "8000000");
|
---|
1314 |
|
---|
1315 | RegisterOption("ViewCells.Evaluation.samplingType",
|
---|
1316 | optString,
|
---|
1317 | "view_cells_evaluation_sampling_type=",
|
---|
1318 | "box");
|
---|
1319 |
|
---|
1320 | RegisterOption("ViewCells.Evaluation.samplesPerPass",
|
---|
1321 | optInt,
|
---|
1322 | "view_cells_evaluation_samples_per_pass=",
|
---|
1323 | "300000");
|
---|
1324 |
|
---|
1325 | RegisterOption("ViewCells.exportToFile",
|
---|
1326 | optBool,
|
---|
1327 | "view_cells_export_to_file=",
|
---|
1328 | "false");
|
---|
1329 |
|
---|
1330 | RegisterOption("ViewCells.exportPvs",
|
---|
1331 | optBool,
|
---|
1332 | "view_cells_export_pvs=",
|
---|
1333 | "false");
|
---|
1334 |
|
---|
1335 | RegisterOption("ViewCells.exportBboxesForPvs",
|
---|
1336 | optBool,
|
---|
1337 | "view_cells_export_bounding_boxes=",
|
---|
1338 | "true");
|
---|
1339 |
|
---|
1340 | RegisterOption("ViewCells.boxesFilename",
|
---|
1341 | optString,
|
---|
1342 | "view_cells_boxes_filename=",
|
---|
1343 | "boxes.out");
|
---|
1344 |
|
---|
1345 | RegisterOption("ViewCells.PostProcess.emptyViewCellsMerge",
|
---|
1346 | optBool,
|
---|
1347 | "view_cells_merge_empty=",
|
---|
1348 | "true");
|
---|
1349 |
|
---|
1350 | RegisterOption("ViewCells.evaluateViewCells",
|
---|
1351 | optBool,
|
---|
1352 | "view_cells_evaluate=",
|
---|
1353 | "false");
|
---|
1354 |
|
---|
1355 | RegisterOption("ViewCells.maxViewCells",
|
---|
1356 | optInt,
|
---|
1357 | "view_cells_max_view_cells=",
|
---|
1358 | "0");
|
---|
1359 |
|
---|
1360 | RegisterOption("ViewCells.maxPvsRatio",
|
---|
1361 | optFloat,
|
---|
1362 | "view_cells_max_pvs_ratio=",
|
---|
1363 | "0.1");
|
---|
1364 |
|
---|
1365 | RegisterOption("ViewCells.filename",
|
---|
1366 | optString,
|
---|
1367 | "view_cells_filename=",
|
---|
1368 | "atlanta_viewcells_large.x3d");
|
---|
1369 |
|
---|
1370 | RegisterOption("ViewCells.height",
|
---|
1371 | optFloat,
|
---|
1372 | "view_cells_height=",
|
---|
1373 | "5.0");
|
---|
1374 |
|
---|
1375 | RegisterOption("ViewCells.Visualization.colorCode",
|
---|
1376 | optString,
|
---|
1377 | "view_cells_visualization_color_code=",
|
---|
1378 | "PVS");
|
---|
1379 |
|
---|
1380 | RegisterOption("ViewCells.Visualization.clipPlanePos",
|
---|
1381 | optFloat,
|
---|
1382 | "view_cells_visualization_clip_plane_pos=",
|
---|
1383 | "0.35");
|
---|
1384 |
|
---|
1385 | RegisterOption("ViewCells.Visualization.exportGeometry",
|
---|
1386 | optBool,
|
---|
1387 | "view_cells_visualization_export_geometry=",
|
---|
1388 | "false");
|
---|
1389 |
|
---|
1390 | RegisterOption("ViewCells.Visualization.exportRays",
|
---|
1391 | optBool,
|
---|
1392 | "view_cells_visualization_export_rays=",
|
---|
1393 | "false");
|
---|
1394 |
|
---|
1395 | RegisterOption("ViewCells.pruneEmptyViewCells",
|
---|
1396 | optBool,
|
---|
1397 | "view_cells_prune_empty=",
|
---|
1398 | "false");
|
---|
1399 |
|
---|
1400 | RegisterOption("ViewCells.processOnlyValidViewCells",
|
---|
1401 | optBool,
|
---|
1402 | "view_cells_process_only_valid_view_cells=",
|
---|
1403 | "false");
|
---|
1404 |
|
---|
1405 |
|
---|
1406 | RegisterOption("ViewCells.PostProcess.maxCostRatio",
|
---|
1407 | optFloat,
|
---|
1408 | "view_cells_post_process_max_cost_ratio=",
|
---|
1409 | "0.9");
|
---|
1410 |
|
---|
1411 | RegisterOption("ViewCells.PostProcess.renderCostWeight",
|
---|
1412 | optFloat,
|
---|
1413 | "view_cells_post_process_render_cost_weight",
|
---|
1414 | "0.5");
|
---|
1415 |
|
---|
1416 | RegisterOption("ViewCells.PostProcess.avgCostMaxDeviation",
|
---|
1417 | optFloat,
|
---|
1418 | "vsp_bsp_avgcost_max_deviations",
|
---|
1419 | "0.5");
|
---|
1420 |
|
---|
1421 | RegisterOption("ViewCells.PostProcess.maxMergesPerPass",
|
---|
1422 | optInt,
|
---|
1423 | "view_cells_post_process_max_merges_per_pass=",
|
---|
1424 | "500");
|
---|
1425 |
|
---|
1426 | RegisterOption("ViewCells.PostProcess.minViewCells",
|
---|
1427 | optInt,
|
---|
1428 | "view_cells_post_process_min_view_cells=",
|
---|
1429 | "1000");
|
---|
1430 |
|
---|
1431 | RegisterOption("ViewCells.PostProcess.useRaysForMerge",
|
---|
1432 | optBool,
|
---|
1433 | "view_cells_post_process_use_rays_for_merge=",
|
---|
1434 | "false");
|
---|
1435 |
|
---|
1436 | RegisterOption("ViewCells.PostProcess.merge",
|
---|
1437 | optBool,
|
---|
1438 | "view_cells_post_process_merge=",
|
---|
1439 | "true");
|
---|
1440 |
|
---|
1441 | RegisterOption("ViewCells.Visualization.exportMergedViewCells",
|
---|
1442 | optBool,
|
---|
1443 | "view_cells_viz_export_merged_viewcells=",
|
---|
1444 | "false");
|
---|
1445 |
|
---|
1446 | RegisterOption("ViewCells.maxStaticMemory",
|
---|
1447 | optFloat,
|
---|
1448 | "view_cells_max_static_mem=",
|
---|
1449 | "8.0");
|
---|
1450 |
|
---|
1451 | RegisterOption("ViewCells.Visualization.useClipPlane",
|
---|
1452 | optBool,
|
---|
1453 | "view_cells_viz_use_clip_plane=",
|
---|
1454 | "false");
|
---|
1455 |
|
---|
1456 | RegisterOption("ViewCells.showVisualization",
|
---|
1457 | optBool,
|
---|
1458 | "view_cells_show_visualization=",
|
---|
1459 | "false");
|
---|
1460 |
|
---|
1461 | RegisterOption("ViewCells.Visualization.clipPlaneAxis",
|
---|
1462 | optInt,
|
---|
1463 | "view_cells_viz_clip_plane_axis=",
|
---|
1464 | "0");
|
---|
1465 |
|
---|
1466 |
|
---|
1467 | /************************************************************************************/
|
---|
1468 | /* Render simulation related options */
|
---|
1469 | /************************************************************************************/
|
---|
1470 |
|
---|
1471 |
|
---|
1472 | RegisterOption("Simulation.objRenderCost",
|
---|
1473 | optFloat,
|
---|
1474 | "simulation_obj_render_cost",
|
---|
1475 | "1.0");
|
---|
1476 |
|
---|
1477 | RegisterOption("Simulation.vcOverhead",
|
---|
1478 | optFloat,
|
---|
1479 | "simulation_vc_overhead",
|
---|
1480 | "0.05");
|
---|
1481 |
|
---|
1482 | RegisterOption("Simulation.moveSpeed",
|
---|
1483 | optFloat,
|
---|
1484 | "simulation_moveSpeed",
|
---|
1485 | "1.0");
|
---|
1486 |
|
---|
1487 |
|
---|
1488 |
|
---|
1489 |
|
---|
1490 | /************************************************************************************/
|
---|
1491 | /* Bsp tree related options */
|
---|
1492 | /************************************************************************************/
|
---|
1493 |
|
---|
1494 |
|
---|
1495 | RegisterOption("BspTree.Construction.input",
|
---|
1496 | optString,
|
---|
1497 | "bsp_construction_input=",
|
---|
1498 | "fromViewCells");
|
---|
1499 |
|
---|
1500 | RegisterOption("BspTree.subdivisionStats",
|
---|
1501 | optString,
|
---|
1502 | "bsp_subdivision_stats=",
|
---|
1503 | "bspSubdivisionStats.log");
|
---|
1504 |
|
---|
1505 | RegisterOption("BspTree.Construction.samples",
|
---|
1506 | optInt,
|
---|
1507 | "bsp_construction_samples=",
|
---|
1508 | "100000");
|
---|
1509 |
|
---|
1510 | RegisterOption("BspTree.Construction.epsilon",
|
---|
1511 | optFloat,
|
---|
1512 | "bsp_construction_side_tolerance=",
|
---|
1513 | "0.002");
|
---|
1514 |
|
---|
1515 | RegisterOption("BspTree.Termination.minPolygons",
|
---|
1516 | optInt,
|
---|
1517 | "bsp_term_min_polygons=",
|
---|
1518 | "5");
|
---|
1519 |
|
---|
1520 | RegisterOption("BspTree.Termination.minPvs",
|
---|
1521 | optInt,
|
---|
1522 | "bsp_term_min_pvs=",
|
---|
1523 | "20");
|
---|
1524 |
|
---|
1525 | RegisterOption("BspTree.Termination.minProbability",
|
---|
1526 | optFloat,
|
---|
1527 | "bsp_term_min_probability=",
|
---|
1528 | "0.001");
|
---|
1529 |
|
---|
1530 | RegisterOption("BspTree.Termination.maxRayContribution",
|
---|
1531 | optFloat,
|
---|
1532 | "bsp_term_ray_contribution=",
|
---|
1533 | "0.005");
|
---|
1534 |
|
---|
1535 | RegisterOption("BspTree.Termination.minAccRayLenght",
|
---|
1536 | optFloat,
|
---|
1537 | "bsp_term_min_acc_ray_length=",
|
---|
1538 | "50");
|
---|
1539 |
|
---|
1540 | RegisterOption("BspTree.Termination.minRays",
|
---|
1541 | optInt,
|
---|
1542 | "bsp_term_min_rays=",
|
---|
1543 | "-1");
|
---|
1544 |
|
---|
1545 | RegisterOption("BspTree.Termination.ct_div_ci",
|
---|
1546 | optFloat,
|
---|
1547 | "bsp_term_ct_div_ci=",
|
---|
1548 | "0.0");
|
---|
1549 |
|
---|
1550 | RegisterOption("BspTree.Termination.maxDepth",
|
---|
1551 | optInt,
|
---|
1552 | "bsp_term_max_depth=",
|
---|
1553 | "100");
|
---|
1554 |
|
---|
1555 | RegisterOption("BspTree.Termination.maxCostRatio",
|
---|
1556 | optFloat,
|
---|
1557 | "bsp_term_axis_aligned_max_cost_ratio=",
|
---|
1558 | "1.5");
|
---|
1559 |
|
---|
1560 | RegisterOption("BspTree.Termination.AxisAligned.ct_div_ci",
|
---|
1561 | optFloat,
|
---|
1562 | "bsp_term_axis_aligned_ct_div_ci=",
|
---|
1563 | "0.5");
|
---|
1564 |
|
---|
1565 | RegisterOption("BspTree.AxisAligned.splitBorder",
|
---|
1566 | optFloat,
|
---|
1567 | "bsp__axis_aligned_split_border=",
|
---|
1568 | "0.1");
|
---|
1569 |
|
---|
1570 | RegisterOption("BspTree.Termination.AxisAligned.minPolys",
|
---|
1571 | optInt,
|
---|
1572 | "bsp_term_axis_aligned_max_polygons=",
|
---|
1573 | "50");
|
---|
1574 |
|
---|
1575 | RegisterOption("BspTree.Termination.AxisAligned.minObjects",
|
---|
1576 | optInt,
|
---|
1577 | "bsp_term_min_objects=",
|
---|
1578 | "3");
|
---|
1579 |
|
---|
1580 | RegisterOption("BspTree.Termination.AxisAligned.minRays",
|
---|
1581 | optInt,
|
---|
1582 | "bsp_term_axis_aligned_min_rays=",
|
---|
1583 | "-1");
|
---|
1584 |
|
---|
1585 | RegisterOption("BspTree.splitPlaneStrategy",
|
---|
1586 | optString,
|
---|
1587 | "bsp_split_method=",
|
---|
1588 | "leastSplits");
|
---|
1589 |
|
---|
1590 | RegisterOption("BspTree.maxPolyCandidates",
|
---|
1591 | optInt,
|
---|
1592 | "bsp_max_poly_candidates=",
|
---|
1593 | "20");
|
---|
1594 |
|
---|
1595 | RegisterOption("BspTree.maxRayCandidates",
|
---|
1596 | optInt,
|
---|
1597 | "bsp_max_plane_candidates=",
|
---|
1598 | "20");
|
---|
1599 |
|
---|
1600 | RegisterOption("BspTree.maxTests",
|
---|
1601 | optInt,
|
---|
1602 | "bsp_max_tests=",
|
---|
1603 | "5000");
|
---|
1604 |
|
---|
1605 | RegisterOption("BspTree.Termination.maxViewCells",
|
---|
1606 | optInt,
|
---|
1607 | "bsp_max_view_cells=",
|
---|
1608 | "5000");
|
---|
1609 |
|
---|
1610 | RegisterOption("BspTree.Visualization.exportSplits",
|
---|
1611 | optBool,
|
---|
1612 | "bsp_visualization.export_splits",
|
---|
1613 | "false");
|
---|
1614 |
|
---|
1615 | RegisterOption("BspTree.Factor.verticalSplits", optFloat, "bsp_factor_vertical=", "1.0");
|
---|
1616 | RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "bsp_factor_largest_poly=", "1.0");
|
---|
1617 | RegisterOption("BspTree.Factor.blockedRays", optFloat, "bsp_factor_blocked=", "1.0");
|
---|
1618 | RegisterOption("BspTree.Factor.leastSplits", optFloat, "bsp_factor_least_splits=", "1.0");
|
---|
1619 | RegisterOption("BspTree.Factor.balancedPolys", optFloat, "bsp_factor_balanced_polys=", "1.0");
|
---|
1620 | RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "bsp_factor_balanced_view_cells=", "1.0");
|
---|
1621 | RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "bsp_factor_least_ray_splits=", "1.0");
|
---|
1622 | RegisterOption("BspTree.Factor.balancedRays", optFloat, "bsp_factor_balanced_rays=", "1.0");
|
---|
1623 | RegisterOption("BspTree.Factor.pvs", optFloat, "bsp_factor_pvs=", "1.0");
|
---|
1624 |
|
---|
1625 | /************************************************************************************/
|
---|
1626 | /* Preprocessor related options */
|
---|
1627 | /************************************************************************************/
|
---|
1628 |
|
---|
1629 | RegisterOption("Preprocessor.type",
|
---|
1630 | optString,
|
---|
1631 | "preprocessor=",
|
---|
1632 | "sampling");
|
---|
1633 |
|
---|
1634 | RegisterOption("Preprocessor.samplesFilename",
|
---|
1635 | optString,
|
---|
1636 | "preprocessor_samples_filename=",
|
---|
1637 | "rays.out");
|
---|
1638 |
|
---|
1639 | RegisterOption("Preprocessor.loadPolygonsAsMeshes",
|
---|
1640 | optBool,
|
---|
1641 | "loadPolygonsAsMeshes=",
|
---|
1642 | "false");
|
---|
1643 |
|
---|
1644 | RegisterOption("Preprocessor.pvsRenderErrorSamples",
|
---|
1645 | optInt,
|
---|
1646 | "pvsRenderErrorSamples=",
|
---|
1647 | "10000");
|
---|
1648 |
|
---|
1649 |
|
---|
1650 | RegisterOption("Preprocessor.useGlRenderer",
|
---|
1651 | optBool,
|
---|
1652 | "preprocessor_use_gl_renderer=",
|
---|
1653 | "false");
|
---|
1654 |
|
---|
1655 | RegisterOption("Preprocessor.useGlDebugger",
|
---|
1656 | optBool,
|
---|
1657 | "preprocessor_use_gl_debugger=",
|
---|
1658 | "false");
|
---|
1659 |
|
---|
1660 | RegisterOption("Preprocessor.detectEmptyViewSpace",
|
---|
1661 | optBool,
|
---|
1662 | "preprocessor_detect_empty_viewspace=",
|
---|
1663 | "false");
|
---|
1664 |
|
---|
1665 | RegisterOption("Preprocessor.quitOnFinish",
|
---|
1666 | optBool,
|
---|
1667 | "preprocessor_quit_on_finish=",
|
---|
1668 | "true");
|
---|
1669 |
|
---|
1670 | RegisterOption("Preprocessor.computeVisibility",
|
---|
1671 | optBool,
|
---|
1672 | "preprocessor_compute_visibility=",
|
---|
1673 | "true");
|
---|
1674 |
|
---|
1675 |
|
---|
1676 | /**************************************************************************************/
|
---|
1677 | /* View space partition KD tree related options */
|
---|
1678 | /**************************************************************************************/
|
---|
1679 |
|
---|
1680 | RegisterOption("VspKdTree.Construction.samples",
|
---|
1681 | optInt,
|
---|
1682 | "vsp_kd_construction_samples=",
|
---|
1683 | "100000");
|
---|
1684 |
|
---|
1685 | RegisterOption("VspKdTree.Termination.maxDepth",
|
---|
1686 | optInt,
|
---|
1687 | "vsp_term_maxdepth=", "30");
|
---|
1688 |
|
---|
1689 | RegisterOption("VspKdTree.Termination.minPvs",
|
---|
1690 | optInt,
|
---|
1691 | "vsp_minpvs=",
|
---|
1692 | "1");
|
---|
1693 |
|
---|
1694 | RegisterOption("VspKdTree.Termination.minRays",
|
---|
1695 | optInt,
|
---|
1696 | "vsp_term_minrays=",
|
---|
1697 | "10");
|
---|
1698 |
|
---|
1699 | RegisterOption("VspKdTree.Termination.minSize",
|
---|
1700 | optFloat,
|
---|
1701 | "vsp_term_minsize=",
|
---|
1702 | "0.001");
|
---|
1703 |
|
---|
1704 | RegisterOption("VspKdTree.Termination.maxCostRatio",
|
---|
1705 | optFloat,
|
---|
1706 | "vsp_term_maxcost=",
|
---|
1707 | "0.95");
|
---|
1708 |
|
---|
1709 | RegisterOption("VspKdTree.Termination.maxRayContribution",
|
---|
1710 | optFloat,
|
---|
1711 | "vsp_term_max_ray_contrib=",
|
---|
1712 | "0.5");
|
---|
1713 |
|
---|
1714 | RegisterOption("VspKdTree.epsilon",
|
---|
1715 | optFloat,
|
---|
1716 | "kd_eps=",
|
---|
1717 | "1e-6");
|
---|
1718 |
|
---|
1719 | RegisterOption("VspKdTree.ct_div_ci",
|
---|
1720 | optFloat,
|
---|
1721 | "vsp_ctdivci=", "1.0");
|
---|
1722 |
|
---|
1723 | RegisterOption("VspKdTree.splitType",
|
---|
1724 | optString,
|
---|
1725 | "split=",
|
---|
1726 | "queries");
|
---|
1727 |
|
---|
1728 | RegisterOption("VspKdTree.splitAxis",
|
---|
1729 | optString,
|
---|
1730 | "split=",
|
---|
1731 | "drivingAxis");
|
---|
1732 |
|
---|
1733 | RegisterOption("VspKdTree.splitUseOnlyDrivingAxis",
|
---|
1734 | optBool,
|
---|
1735 | "vsp_kd_splitdriving=",
|
---|
1736 | "false");
|
---|
1737 |
|
---|
1738 | RegisterOption("VspKdTree.numberOfEndPointDomains",
|
---|
1739 | optInt,
|
---|
1740 | "endpoints=",
|
---|
1741 | "10000");
|
---|
1742 |
|
---|
1743 | RegisterOption("VspKdTree.maxTotalMemory",
|
---|
1744 | optFloat,
|
---|
1745 | "vsp_max_total_mem=",
|
---|
1746 | "60.0");
|
---|
1747 |
|
---|
1748 | RegisterOption("VspKdTree.maxStaticMemory",
|
---|
1749 | optFloat,
|
---|
1750 | "vsp_max_static_mem=",
|
---|
1751 | "8.0");
|
---|
1752 |
|
---|
1753 | RegisterOption("VspKdTree.queryType",
|
---|
1754 | optString,
|
---|
1755 | "qtype=",
|
---|
1756 | "static");
|
---|
1757 |
|
---|
1758 | RegisterOption("VspKdTree.queryPosWeight",
|
---|
1759 | optFloat,
|
---|
1760 | "vsp_kd_qposweight=",
|
---|
1761 | "0.0");
|
---|
1762 |
|
---|
1763 | RegisterOption("VspKdTree.accessTimeThreshold",
|
---|
1764 | optInt,
|
---|
1765 | "vsp_kd_accesstime=",
|
---|
1766 | "1000");
|
---|
1767 |
|
---|
1768 | RegisterOption("VspKdTree.minCollapseDepth",
|
---|
1769 | optInt,
|
---|
1770 | "vsp_kd_min_colldepth=",
|
---|
1771 | "4");
|
---|
1772 |
|
---|
1773 | RegisterOption("VspKdTree.PostProcess.maxCostRatio",
|
---|
1774 | optFloat,
|
---|
1775 | "vsp_kd_post_process_max_cost_ratio=",
|
---|
1776 | "0.9");
|
---|
1777 |
|
---|
1778 | RegisterOption("VspKdTree.PostProcess.minViewCells",
|
---|
1779 | optInt,
|
---|
1780 | "vsp_kd_term_post_process_min_view_cells=",
|
---|
1781 | "1000");
|
---|
1782 |
|
---|
1783 | RegisterOption("VspKdTree.Termination.maxViewCells",
|
---|
1784 | optInt,
|
---|
1785 | "vsp_kd_term_post_process_min_view_cells=",
|
---|
1786 | "300");
|
---|
1787 |
|
---|
1788 | RegisterOption("VspKdTree.PostProcess.maxPvsSize",
|
---|
1789 | optInt,
|
---|
1790 | "vsp_kd_term_post_process_max_pvs_size=",
|
---|
1791 | "100");
|
---|
1792 |
|
---|
1793 | RegisterOption("VspKdTree.Termination.missTolerance",
|
---|
1794 | optInt,
|
---|
1795 | "vsp_kd_term_miss_tolerance=",
|
---|
1796 | "4");
|
---|
1797 |
|
---|
1798 | /************************************************************************************/
|
---|
1799 | /* VSS Preprocessor cells related options */
|
---|
1800 | /************************************************************************************/
|
---|
1801 |
|
---|
1802 | RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12");
|
---|
1803 | RegisterOption("VssTree.minPvs", optInt, "kd_minpvs=", "1");
|
---|
1804 | RegisterOption("VssTree.minRays", optInt, "kd_minrays=", "10");
|
---|
1805 | RegisterOption("VssTree.maxCostRatio", optFloat, "maxcost=", "0.95");
|
---|
1806 | RegisterOption("VssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5");
|
---|
1807 |
|
---|
1808 | RegisterOption("VssTree.epsilon", optFloat, "kd_eps=", "1e-6");
|
---|
1809 | RegisterOption("VssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0");
|
---|
1810 | RegisterOption("VssTree.randomize", optBool, "randomize", "false");
|
---|
1811 | RegisterOption("VssTree.splitType", optString, "split=", "queries");
|
---|
1812 | RegisterOption("VssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false");
|
---|
1813 | RegisterOption("VssTree.useRss", optBool, "rss=", "false");
|
---|
1814 | RegisterOption("VssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000");
|
---|
1815 |
|
---|
1816 | RegisterOption("VssTree.minSize", optFloat, "minsize=", "0.001");
|
---|
1817 |
|
---|
1818 | RegisterOption("VssTree.maxTotalMemory", optFloat, "mem=", "60.0");
|
---|
1819 | RegisterOption("VssTree.maxStaticMemory", optFloat, "statmem=", "8.0");
|
---|
1820 |
|
---|
1821 | RegisterOption("VssTree.queryType", optString, "qtype=", "static");
|
---|
1822 |
|
---|
1823 |
|
---|
1824 |
|
---|
1825 | RegisterOption("VssTree.queryPosWeight", optFloat, "qposweight=", "0.0");
|
---|
1826 | RegisterOption("VssTree.useRefDirSplits", optBool, "refdir", "false");
|
---|
1827 | RegisterOption("VssTree.refDirAngle", optFloat, "refangle=", "10");
|
---|
1828 | RegisterOption("VssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1");
|
---|
1829 | RegisterOption("VssTree.accessTimeThreshold", optInt, "accesstime=", "1000");
|
---|
1830 | RegisterOption("VssTree.minCollapseDepth", optInt, "colldepth=", "4");
|
---|
1831 |
|
---|
1832 | RegisterOption("VssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true");
|
---|
1833 | RegisterOption("VssTree.dirSplitDepth", optInt, "dirsplidepth=", "10");
|
---|
1834 |
|
---|
1835 |
|
---|
1836 | RegisterOption("RssPreprocessor.initialSamples",
|
---|
1837 | optInt,
|
---|
1838 | "initial_samples=",
|
---|
1839 | "100000");
|
---|
1840 |
|
---|
1841 | RegisterOption("RssPreprocessor.vssSamples",
|
---|
1842 | optInt,
|
---|
1843 | "rss_vss_samples=",
|
---|
1844 | "1000000");
|
---|
1845 |
|
---|
1846 | RegisterOption("RssPreprocessor.vssSamplesPerPass",
|
---|
1847 | optInt,
|
---|
1848 | "rss_vss_samples_per_pass=",
|
---|
1849 | "1000");
|
---|
1850 |
|
---|
1851 | RegisterOption("RssPreprocessor.samplesPerPass",
|
---|
1852 | optInt,
|
---|
1853 | "rss_samples_per_pass=",
|
---|
1854 | "100000");
|
---|
1855 |
|
---|
1856 | RegisterOption("RssPreprocessor.useImportanceSampling",
|
---|
1857 | optBool,
|
---|
1858 | "rss_use_importance",
|
---|
1859 | "true");
|
---|
1860 |
|
---|
1861 | RegisterOption("RssPreprocessor.objectBasedSampling",
|
---|
1862 | optBool,
|
---|
1863 | "rss_object_based_sampling",
|
---|
1864 | "true");
|
---|
1865 |
|
---|
1866 | RegisterOption("RssPreprocessor.directionalSampling",
|
---|
1867 | optBool,
|
---|
1868 | "rss_directional_sampling",
|
---|
1869 | "false");
|
---|
1870 |
|
---|
1871 | RegisterOption("RssTree.maxDepth", optInt, "kd_depth=", "12");
|
---|
1872 | RegisterOption("RssTree.minPvs", optInt, "kd_minpvs=", "1");
|
---|
1873 | RegisterOption("RssTree.minRays", optInt, "kd_minrays=", "10");
|
---|
1874 | RegisterOption("RssTree.maxCostRatio", optFloat, "maxcost=", "0.95");
|
---|
1875 | RegisterOption("RssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5");
|
---|
1876 |
|
---|
1877 | RegisterOption("RssTree.epsilon", optFloat, "kd_eps=", "1e-6");
|
---|
1878 | RegisterOption("RssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0");
|
---|
1879 | RegisterOption("RssTree.randomize", optBool, "randomize", "false");
|
---|
1880 | RegisterOption("RssTree.splitType", optString, "split=", "queries");
|
---|
1881 | RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false");
|
---|
1882 |
|
---|
1883 | RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000");
|
---|
1884 |
|
---|
1885 | RegisterOption("RssTree.minSize", optFloat, "minsize=", "0.001");
|
---|
1886 |
|
---|
1887 | RegisterOption("RssTree.maxTotalMemory", optFloat, "mem=", "60.0");
|
---|
1888 | RegisterOption("RssTree.maxStaticMemory", optFloat, "statmem=", "8.0");
|
---|
1889 |
|
---|
1890 | RegisterOption("RssTree.queryType", optString, "qtype=", "static");
|
---|
1891 |
|
---|
1892 | RegisterOption("RssTree.queryPosWeight", optFloat, "qposweight=", "0.0");
|
---|
1893 | RegisterOption("RssTree.useRefDirSplits", optBool, "refdir", "false");
|
---|
1894 | RegisterOption("RssTree.refDirAngle", optFloat, "refangle=", "10");
|
---|
1895 | RegisterOption("RssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1");
|
---|
1896 | RegisterOption("RssTree.accessTimeThreshold", optInt, "accesstime=", "1000");
|
---|
1897 | RegisterOption("RssTree.minCollapseDepth", optInt, "colldepth=", "4");
|
---|
1898 |
|
---|
1899 | RegisterOption("RssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true");
|
---|
1900 | RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10");
|
---|
1901 | RegisterOption("RssTree.importanceBasedCost", optBool, "importance_based_cost", "true");
|
---|
1902 | RegisterOption("RssTree.maxRays", optInt, "rss_max_rays=", "2000000");
|
---|
1903 |
|
---|
1904 | RegisterOption("RssTree.perObjectTree", optBool, "rss_per_object_tree", "false");
|
---|
1905 |
|
---|
1906 | RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false");
|
---|
1907 | RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false");
|
---|
1908 | RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays", "false");
|
---|
1909 | RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000");
|
---|
1910 | RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false");
|
---|
1911 | RegisterOption("RssPreprocessor.updateSubdivision",
|
---|
1912 | optBool,
|
---|
1913 | "rss_update_subdivision",
|
---|
1914 | "false");
|
---|
1915 |
|
---|
1916 |
|
---|
1917 | /************************************************************************************/
|
---|
1918 | /* View space partition BSP tree related options */
|
---|
1919 | /************************************************************************************/
|
---|
1920 |
|
---|
1921 |
|
---|
1922 | RegisterOption("RssPreprocessor.loadInitialSamples",
|
---|
1923 | optBool,
|
---|
1924 | "vss_load_loadInitialSamples=",
|
---|
1925 | "false");
|
---|
1926 |
|
---|
1927 | RegisterOption("RssPreprocessor.storeInitialSamples",
|
---|
1928 | optBool,
|
---|
1929 | "vss_store_storeInitialSamples=",
|
---|
1930 | "false");
|
---|
1931 |
|
---|
1932 |
|
---|
1933 | /************************************************************************************/
|
---|
1934 | /* View space partition BSP tree related options */
|
---|
1935 | /************************************************************************************/
|
---|
1936 |
|
---|
1937 | RegisterOption("VspBspTree.Termination.minGlobalCostRatio",
|
---|
1938 | optFloat,
|
---|
1939 | "vsp_bsp_term_min_global_cost_ratio",
|
---|
1940 | "0.0001");
|
---|
1941 |
|
---|
1942 | RegisterOption("VspBspTree.useSplitCostQueue",
|
---|
1943 | optBool,
|
---|
1944 | "vsp_bsp_use_split_cost_queue=",
|
---|
1945 | "true");
|
---|
1946 |
|
---|
1947 | RegisterOption("VspBspTree.Termination.globalCostMissTolerance",
|
---|
1948 | optInt,
|
---|
1949 | "vsp_bsp_term_global_cost_miss_tolerance",
|
---|
1950 | "4");
|
---|
1951 |
|
---|
1952 | RegisterOption("VspBspTree.Termination.minPolygons",
|
---|
1953 | optInt,
|
---|
1954 | "vsp_bsp_term_min_polygons=",
|
---|
1955 | "5");
|
---|
1956 |
|
---|
1957 | RegisterOption("VspBspTree.Termination.minPvs",
|
---|
1958 | optInt,
|
---|
1959 | "vsp_bsp_term_min_pvs=",
|
---|
1960 | "20");
|
---|
1961 |
|
---|
1962 | RegisterOption("VspBspTree.Termination.minProbability",
|
---|
1963 | optFloat,
|
---|
1964 | "vsp_bsp_term_min_probability=",
|
---|
1965 | "0.001");
|
---|
1966 |
|
---|
1967 | RegisterOption("VspBspTree.subdivisionStats",
|
---|
1968 | optString,
|
---|
1969 | "vsp_bsp_subdivision_stats=",
|
---|
1970 | "vspBspSubdivisionStats.log");
|
---|
1971 |
|
---|
1972 | RegisterOption("VspBspTree.Termination.maxRayContribution",
|
---|
1973 | optFloat,
|
---|
1974 | "vsp_bsp_term_ray_contribution=",
|
---|
1975 | "0.005");
|
---|
1976 |
|
---|
1977 | RegisterOption("VspBspTree.Termination.minAccRayLenght",
|
---|
1978 | optFloat,
|
---|
1979 | "vsp_bsp_term_min_acc_ray_length=",
|
---|
1980 | "50");
|
---|
1981 |
|
---|
1982 | RegisterOption("VspBspTree.Termination.minRays",
|
---|
1983 | optInt,
|
---|
1984 | "vsp_bsp_term_min_rays=",
|
---|
1985 | "-1");
|
---|
1986 |
|
---|
1987 | RegisterOption("VspBspTree.Termination.ct_div_ci",
|
---|
1988 | optFloat,
|
---|
1989 | "vsp_bsp_term_ct_div_ci=",
|
---|
1990 | "0.0");
|
---|
1991 |
|
---|
1992 | RegisterOption("VspBspTree.Termination.maxDepth",
|
---|
1993 | optInt,
|
---|
1994 | "vsp_bsp_term_max_depth=",
|
---|
1995 | "100");
|
---|
1996 |
|
---|
1997 | RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio",
|
---|
1998 | optFloat,
|
---|
1999 | "vsp_bsp_term_axis_aligned_max_cost_ratio=",
|
---|
2000 | "1.5");
|
---|
2001 |
|
---|
2002 | RegisterOption("VspBspTree.useCostHeuristics",
|
---|
2003 | optBool,
|
---|
2004 | "vsp_bsp_use_cost_heuristics=",
|
---|
2005 | "false");
|
---|
2006 |
|
---|
2007 | RegisterOption("VspBspTree.Termination.maxViewCells",
|
---|
2008 | optInt,
|
---|
2009 | "vsp_bsp_term_max_view_cells=",
|
---|
2010 | "10000");
|
---|
2011 |
|
---|
2012 | RegisterOption("VspBspTree.Termination.maxCostRatio",
|
---|
2013 | optFloat,
|
---|
2014 | "vsp_bsp_term_max_cost_ratio=",
|
---|
2015 | "1.5");
|
---|
2016 |
|
---|
2017 | RegisterOption("VspBspTree.Termination.missTolerance",
|
---|
2018 | optInt,
|
---|
2019 | "vsp_bsp_term_miss_tolerance=",
|
---|
2020 | "4");
|
---|
2021 | RegisterOption("VspBspTree.splitPlaneStrategy",
|
---|
2022 | optString,
|
---|
2023 | "vsp_bsp_split_method=",
|
---|
2024 | "leastSplits");
|
---|
2025 |
|
---|
2026 | RegisterOption("VspBspTree.maxPolyCandidates",
|
---|
2027 | optInt,
|
---|
2028 | "vsp_bsp_max_poly_candidates=",
|
---|
2029 | "20");
|
---|
2030 | RegisterOption("VspBspTree.maxRayCandidates",
|
---|
2031 | optInt,
|
---|
2032 | "vsp_bsp_max_plane_candidates=",
|
---|
2033 | "20");
|
---|
2034 |
|
---|
2035 | RegisterOption("VspBspTree.maxTests",
|
---|
2036 | optInt,
|
---|
2037 | "vsp_bsp_max_tests=",
|
---|
2038 | "5000");
|
---|
2039 |
|
---|
2040 | RegisterOption("VspBspTree.Construction.samples",
|
---|
2041 | optInt,
|
---|
2042 | "vsp_bsp_construction_samples=",
|
---|
2043 | "100000");
|
---|
2044 |
|
---|
2045 | RegisterOption("VspBspTree.Construction.minBand",
|
---|
2046 | optFloat,
|
---|
2047 | "vsp_bsp_construction_min_band=",
|
---|
2048 | "0.1");
|
---|
2049 |
|
---|
2050 | RegisterOption("VspBspTree.Construction.maxBand",
|
---|
2051 | optFloat,
|
---|
2052 | "vsp_bsp_construction_min_band=",
|
---|
2053 | "0.9");
|
---|
2054 |
|
---|
2055 | RegisterOption("VspBspTree.Construction.useDrivingAxisForMaxCost",
|
---|
2056 | optBool,
|
---|
2057 | "vsp_bsp_construction_use_drivingaxis_for_maxcost=",
|
---|
2058 | "false");
|
---|
2059 |
|
---|
2060 | RegisterOption("VspBspTree.Construction.epsilon",
|
---|
2061 | optFloat,
|
---|
2062 | "vsp_bsp_construction_side_tolerance=",
|
---|
2063 | "0.002");
|
---|
2064 |
|
---|
2065 | RegisterOption("VspBspTree.Visualization.exportSplits",
|
---|
2066 | optBool,
|
---|
2067 | "vsp_bsp_visualization.export_splits",
|
---|
2068 | "false");
|
---|
2069 |
|
---|
2070 | RegisterOption("VspBspTree.splitUseOnlyDrivingAxis",
|
---|
2071 | optBool,
|
---|
2072 | "vsp_bsp_split_only_driving_axis=",
|
---|
2073 | "false");
|
---|
2074 |
|
---|
2075 | RegisterOption("VspBspTree.usePolygonSplitIfAvailable",
|
---|
2076 | optBool,
|
---|
2077 | "vsp_bsp_usePolygonSplitIfAvailable=",
|
---|
2078 | "false");
|
---|
2079 |
|
---|
2080 | RegisterOption("VspBspTree.Termination.AxisAligned.minRays",
|
---|
2081 | optInt,
|
---|
2082 | "bsp_term_axis_aligned_min_rays=",
|
---|
2083 | "100");
|
---|
2084 |
|
---|
2085 | RegisterOption("VspBspTree.Termination.AxisAligned.maxRayContribution",
|
---|
2086 | optFloat,
|
---|
2087 | "bsp_term_axis_aligned_min_rays=",
|
---|
2088 | "0.1");
|
---|
2089 |
|
---|
2090 | RegisterOption("VspBspTree.Factor.leastRaySplits",
|
---|
2091 | optFloat,
|
---|
2092 | "vsp_bsp_factor_least_ray_splits=",
|
---|
2093 | "1.0");
|
---|
2094 |
|
---|
2095 | RegisterOption("VspBspTree.Factor.balancedRays",
|
---|
2096 | optFloat,
|
---|
2097 | "vsp_bsp_factor_balanced_rays=",
|
---|
2098 | "1.0");
|
---|
2099 |
|
---|
2100 | RegisterOption("VspBspTree.Factor.pvs",
|
---|
2101 | optFloat,
|
---|
2102 | "vsp_bsp_factor_pvs=",
|
---|
2103 | "1.0");
|
---|
2104 |
|
---|
2105 | RegisterOption("VspBspTree.Construction.renderCostWeight",
|
---|
2106 | optFloat,
|
---|
2107 | "-vsp_bsp_post_process_render_cost_weight",
|
---|
2108 | "0.5");
|
---|
2109 |
|
---|
2110 | RegisterOption("VspBspTree.Construction.randomize",
|
---|
2111 | optBool,
|
---|
2112 | "vsp_bsp_construction_randomize=",
|
---|
2113 | "false");
|
---|
2114 |
|
---|
2115 | RegisterOption("VspBspTree.simulateOctree",
|
---|
2116 | optBool,
|
---|
2117 | "vsp_bsp_simulate_octree=",
|
---|
2118 | "false");
|
---|
2119 |
|
---|
2120 | RegisterOption("VspBspTree.nodePriorityQueueType",
|
---|
2121 | optInt,
|
---|
2122 | "vsp_bsp_node_queue_type=",
|
---|
2123 | "0");
|
---|
2124 |
|
---|
2125 | RegisterOption("VspBspTree.useRandomAxis",
|
---|
2126 | optBool,
|
---|
2127 | "-vsp_bsp_use_random_axis=",
|
---|
2128 | "false");
|
---|
2129 |
|
---|
2130 | RegisterOption("VspBspTree.maxTotalMemory",
|
---|
2131 | optFloat,
|
---|
2132 | "vsp_bsp_max_total_mem=",
|
---|
2133 | "60.0");
|
---|
2134 |
|
---|
2135 | RegisterOption("VspBspTree.maxStaticMemory",
|
---|
2136 | optFloat,
|
---|
2137 | "vsp_bsp_max_static_mem=",
|
---|
2138 | "8.0");
|
---|
2139 |
|
---|
2140 |
|
---|
2141 |
|
---|
2142 |
|
---|
2143 | //////////////////////////////////////////////////////////////////////////////////
|
---|
2144 | }
|
---|
2145 |
|
---|
2146 | void
|
---|
2147 | Environment::SetStaticOptions()
|
---|
2148 | {
|
---|
2149 |
|
---|
2150 | // get Global option values
|
---|
2151 | GetRealValue("Limits.threshold", Limits::Threshold);
|
---|
2152 | GetRealValue("Limits.small", Limits::Small);
|
---|
2153 | GetRealValue("Limits.infinity", Limits::Infinity);
|
---|
2154 |
|
---|
2155 |
|
---|
2156 | }
|
---|
2157 |
|
---|
2158 | void
|
---|
2159 | Environment::Parse(const int argc, char **argv, bool useExePath)
|
---|
2160 | {
|
---|
2161 |
|
---|
2162 | // Read the names of the scene, environment and output files
|
---|
2163 | ReadCmdlineParams(argc, argv, "");
|
---|
2164 |
|
---|
2165 | char *envFilename = new char[128];
|
---|
2166 |
|
---|
2167 | char filename[64];
|
---|
2168 |
|
---|
2169 | // Get the environment file name
|
---|
2170 | if (!GetParam(' ', 0, filename)) {
|
---|
2171 | // user didn't specified environment file explicitly, so
|
---|
2172 | strcpy(filename, "default.env");
|
---|
2173 | }
|
---|
2174 |
|
---|
2175 | if (useExePath) {
|
---|
2176 | char *path = GetPath(argv[0]);
|
---|
2177 | if (*path != 0)
|
---|
2178 | sprintf(envFilename, "%s/%s", path, filename);
|
---|
2179 | else
|
---|
2180 | strcpy(envFilename, filename);
|
---|
2181 |
|
---|
2182 | delete path;
|
---|
2183 | }
|
---|
2184 | else
|
---|
2185 | strcpy(envFilename, filename);
|
---|
2186 |
|
---|
2187 |
|
---|
2188 | // Now it's time to read in environment file.
|
---|
2189 | if (!ReadEnvFile(envFilename)) {
|
---|
2190 | // error - bad input file name specified ?
|
---|
2191 | cerr<<"Error parsing environment file "<<envFilename<<endl;
|
---|
2192 | }
|
---|
2193 | delete envFilename;
|
---|
2194 |
|
---|
2195 | // Parse the command line; options given on the command line subsume
|
---|
2196 | // stuff specified in the input environment file.
|
---|
2197 | ParseCmdline(argc, argv, 0);
|
---|
2198 |
|
---|
2199 | SetStaticOptions();
|
---|
2200 |
|
---|
2201 | // Check for request for help
|
---|
2202 | if (CheckForSwitch(argc, argv, '?')) {
|
---|
2203 | PrintUsage(cout);
|
---|
2204 | exit(0);
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 | }
|
---|
2208 |
|
---|
2209 | } |
---|