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