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