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