source: GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp @ 1887

Revision 1887, 69.4 KB checked in by mattausch, 18 years ago (diff)
RevLine 
[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]22using namespace std;
[372]23 
[863]24namespace GtpVisibilityPreprocessor {
[860]25
[863]26
[1004]27Environment *Environment::sEnvironment = NULL;
[372]28
[1004]29
30Environment *Environment::GetSingleton()
31{
32        if (!sEnvironment)
33        {
34                sEnvironment = new Environment();
35        }
36
37        return sEnvironment;
38}
39
[1416]40
[1004]41void Environment::DelSingleton()
42{
43        DEL_PTR(sEnvironment);
44}
45
46
[372]47Environment::~Environment()
48{
49  int i, j;
50
51  // delete the params structure
52  for (i = 0; i < numParams; i++) {
53    for (j = 0; j < paramRows; j++)
54      if (params[i][j] != NULL)
55        delete[] params[i][j];
56    if (params[i] != NULL)
57      delete[] params[i];
58  }
59
60  if (params != NULL)
61    delete[] params;
62 
63  // delete the options structure
64  if (options != NULL)
65    delete[] options;
66 
67  if (optionalParams != NULL)
[938]68    DEL_PTR(optionalParams);
[372]69}
70
71bool
72Environment::CheckForSwitch(const int argc,
[492]73                                                        char **argv,
74                                                        const char swtch) const
[372]75{
76  for (int i = 1; i < argc; i++)
77    if ((argv[i][0] == '-') && (argv[i][1] == swtch))
78      return true;
79  return false;
80}
81
82bool
83Environment::CheckType(const char *value,
84                        const EOptType type) const
85{
86  char *s, *t, *u;
87
88  switch (type) {
89    case optInt: {
90      strtol(value, &t, 10);
91      if (value + strlen(value) != t)
92        return false;
93      else
94        return true;
95    }
96    case optFloat: {
97      strtod(value, &t);
98      if (value + strlen(value) != t)
99        return false;
100      else
101        return true;
102    }
103    case optBool: {
104      if (!strcasecmp(value, "true") ||
105          !strcasecmp(value, "false") ||
106          !strcasecmp(value, "YES") ||
107          !strcasecmp(value, "NO") ||
108          !strcmp(value, "+") ||
109          !strcmp(value, "-") ||
110          !strcasecmp(value, "ON") ||
111          !strcasecmp(value, "OFF"))
112        return true;
113      return false;
114    }
115    case optVector:{
116      strtod(value, &s);
117      if (*s == ' ' || *s == '\t') {
118        while (*s == ' ' || *s == '\t')
119          s++;
120        if (*s != ',')
121          s--;
122      }
123      if ((*s != ',' && *s != ' ' && *s != '\t') || value == s)
124        return false;
125      t = s;
126      strtod(s + 1, &u);
127      if (*u == ' ' || *u == '\t') {
128        while (*u == ' ' || *u == '\t')
129          u++;
130        if (*u != ',')
131          u--;
132      }
133      if ((*u != ',' && *s != ' ' && *s != '\t') || t == u)
134        return false;
135      t = u;
136      strtod(u + 1, &s);
137      if (t == s || value + strlen(value) != s)
138        return false;
139      return true;
140    }
141    case optString: {
142      return true;
143    }
144    default: {
145      Debug << "Internal error: Unknown type of option.\n" << flush;
146      exit(1);
147    }
148  }
149  return false;
150}
151
152void
153Environment::ReadCmdlineParams(const int argc,
[492]154                                                           char **argv,
155                                                           const char *optParams)
[372]156{
157  int i;
158
159  // Make sure we are called for the first time
160  if (optionalParams != NULL)
161    return;
162
[472]163  numParams = (int)strlen(optParams) + 1;
[372]164  optionalParams = new char[numParams];
165  strcpy(optionalParams, optParams);
166
167  // First, count all non-optional parameters on the command line
168  for (i = 1; i < argc; i++)
169    if (argv[i][0] != '-')
170      paramRows++;
171
172  // if there is no non-optional parameter add a default one...
173  if (paramRows == 0)
174    paramRows = 1;
175 
176  // allocate and initialize the table for parameters
177  params = new char **[numParams];
178  for (i = 0; i < numParams; i++) {
179    params[i] = new char *[paramRows];
180    for (int j = 0; j < paramRows; j++)
181      params[i][j] = NULL;
182  }
183  // Now read all non-optional and optional parameters into the table
184  curRow = -1;
185  for (i = 1; i < argc; i++) {
186    if (argv[i][0] != '-') {
187      // non-optional parameter encountered
188      curRow++;
189      params[0][curRow] = new char[strlen(argv[i]) + 1];
190      strcpy(params[0][curRow], argv[i]);
191    }
192    else {
193      // option encountered
194      char *t = strchr(optionalParams, argv[i][1]);
195      if (t != NULL) {
196        // this option is optional parameter
197        int index = t - optionalParams + 1;
198        if (curRow < 0) {
199          // it's a global parameter
200          for (int j = 0; j < paramRows; j++) {
201            params[index][j] = new char[strlen(argv[i] + 2) + 1];
202            strcpy(params[index][j], argv[i] + 2);
203          }
204        }
205        else {
206          // it's a scene parameter
207          if (params[index][curRow] != NULL) {
208            delete[] params[index][curRow];
209          }
210          params[index][curRow] = new char[strlen(argv[i] + 2) + 1];
211          strcpy(params[index][curRow], argv[i] + 2);
212        }
213      }
214    }
215  }
216  curRow = 0;
217
218#ifdef _DEBUG_PARAMS
219  // write out the parameter table
220  cerr << "Parameter table for " << numParams << " columns and "
221       << paramRows << " rows:\n";
222  for (int j = 0; j < paramRows; j++) {
223    for (i = 0; i < numParams; i++) {
224      if (params[i][j] != NULL)
225        cerr << params[i][j];
226      else
227        cerr << "NULL";
228      cerr << "\t";
229    }
230    cerr << "\n";
231  }
232  cerr << "Params done.\n" << flush;
233#endif // _DEBUG_PARAMS
234}
235
236bool
237Environment::GetParam(const char name,
[1545]238                                          const int index,
239                                          char *value) const
[372]240{
241  int column;
242
243  if (index >= paramRows || index < 0)
244    return false;
245  if (name == ' ')
246    column = 0;
247  else {
248    char *t = strchr(optionalParams, name);
249
250    if (t == NULL)
251      return false;
252    column = t - optionalParams + 1;
253  }
254
255  if (params[column][index] == NULL)
256    return false;
257  //  value = new char[strlen(params[column][index]) + 1];
258  strcpy(value, params[column][index]);
259  return true;
260}
261
262void
263Environment::RegisterOption(const char *name,
[1002]264                                                        const EOptType type,
265                                                        const char *abbrev,
266                                                        const char *defValue)
[372]267{
268  int i;
269
270  // make sure this option was not yet registered
271  for (i = 0; i < numOptions; i++)
272    if (!strcmp(name, options[i].name)) {
273      Debug << "Error: Option " << name << " registered twice.\n";
274      exit(1);
275    }
276  // make sure we have enough room in memory
277  if (numOptions >= maxOptions) {
278    Debug << "Error: Too many options. Try enlarge the maxOptions "
279          << "definition.\n";
280    exit(1);
281  }
282
283  // make sure the abbreviation doesn't start with 'D'
284  if (abbrev != NULL && (abbrev[0] == 'D' )) {
285    Debug << "Internal error: reserved switch " << abbrev
286         << " used as an abbreviation.\n";
287    exit(1);
288  }
289  // new option
290  options[numOptions].type = type;
[863]291  options[numOptions].name = ::strdup(name);
[372]292  // assign abbreviation, if requested
293  if (abbrev != NULL) {
[863]294          options[numOptions].abbrev = ::strdup(abbrev);
[372]295  }
296  // assign default value, if requested
297  if (defValue != NULL) {
[863]298          options[numOptions].defaultValue = ::strdup(defValue);
[372]299    if (!CheckType(defValue, type)) {
300      Debug << "Internal error: Inconsistent type and default value in option "
301           << name << ".\n";
302      exit(1);
303    }
304  }
305  // new option registered
306  numOptions++;
307}
308
309bool
310Environment::OptionPresent(const char *name) const
311{
312  bool found = false;
313  int i;
314
315  for (i = 0; i < numOptions; i++)
316    if (!strcmp(options[i].name, name)) {
317      found = true;
318      break;
319    }
320  if (!found) {
321    Debug << "Internal error: Option " << name << " not registered.\n" << flush;
322    exit(1);
323  }
324  if (options[i].value != NULL || options[i].defaultValue != NULL)
325    return true;
326  else
327    return false;
328}
329
330int
[938]331Environment::FindOption(const char *name, const bool isFatal) const
[372]332{
333  int i;
334  bool found = false;
335  // is this option registered ?
336  for (i = 0; i < numOptions; i++)
337    if (!strcmp(options[i].name, name)) {
338      found = true;
339      break;
340    }
341  if (!found) {
342    // no registration found
343    Debug << "Internal error: Required option " << name
344          << " not registered.\n" << flush;
345    exit(1);
346  }
347  if (options[i].value == NULL && options[i].defaultValue == NULL)
348    // this option was not initialised to some value
349    if (isFatal) {
350      Debug << "Error: Required option " << name << " not found.\n" << flush;
351      exit(1);
352    }
353    else {
354      Debug << "Error: Required option " << name << " not found.\n" << flush;
355      return -1;
356    }
357  return i;
358}
359
360bool
361Environment::GetIntValue(const char *name,
362                         int &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 = strtol(options[i].value, NULL, 10);
373  } else {
374    // option was not read, so use the default
375    value = strtol(options[i].defaultValue, NULL, 10);
376  }
377
378  return true;
379}
380
381bool
382Environment::GetDoubleValue(const char *name,
383                            double &value,
384                            const bool isFatal) const
385{
386  int i = FindOption(name, isFatal);
387
388  if (i<0)
389    return false;
390
391  if (options[i].value != NULL) {
392    // option was explicitly specified
393    value = strtod(options[i].value, NULL);
394  } else {
395    // option was not read, so use the default
396    value = strtod(options[i].defaultValue, NULL);
397  }
398  return true;
399}
400
401bool
402Environment::GetRealValue(const char *name,
403                          Real &value,
404                          const bool isFatal) const
405{
406  int i = FindOption(name, isFatal);
407 
408  if (i<0)
409    return false;
410
411  if (options[i].value != NULL) {
412    // option was explicitly specified
[472]413    value = (Real)strtod(options[i].value, NULL);
[372]414  } else {
415    // option was not read, so use the default
[472]416    value = (Real)strtod(options[i].defaultValue, NULL);
[372]417  }
418  return true;
419}
420
421bool
422Environment::GetFloatValue(const char *name,
423                           float &value,
424                           const bool isFatal) const
425{
426  int i = FindOption(name, isFatal);
427
428  if (i<0)
429    return false;
430
431  if (options[i].value != NULL) {
432    // option was explicitly specified
433    value = (float)strtod(options[i].value, NULL);
434  } else {
435    // option was not read, so use the default
436    value = (float)strtod(options[i].defaultValue, NULL);
437  }
438  return true;
439}
440
441bool
442Environment::GetBool(const char *name,
443                     const bool isFatal) const
444{
445  bool ret;
446  if (GetBoolValue(name, ret, isFatal))
447    return ret;
448  else
449    return false;
450}
451
452bool
453Environment::ParseBool(const char *name) const
454{
455
456  bool value = true;
457 
458  if (!strcasecmp(name, "false") ||
459      !strcasecmp(name, "NO") ||
460      !strcmp(name, "-") ||
461      !strcasecmp(name, "OFF"))
462    value = false;
463 
464  return value;
465}
466
467void
468Environment::ParseVector(const char *name, Vector3 &v) const
469{
470  // option was not read, so use the default
471  char *s, *t;
472 
473  v.x = (Real)strtod(name, &s);
474  v.y = (Real)strtod(s + 1, &t);
475  v.z = (Real)strtod(t + 1, NULL);
476
477}
478
479bool
480Environment::GetBoolValue(const char *name,
481                           bool &value,
482                           const bool isFatal) const
483{
484  int i = FindOption(name, isFatal);
485
486  if (i<0)
487    return false;
488
489 
490  if (options[i].value != NULL)
491    value = ParseBool(options[i].value);
492  else
493    value = ParseBool(options[i].defaultValue);
494
495  return true;
496}
497
498bool
499Environment::GetVectorValue(const char *name,
500                            Vector3 &v,
501                            const bool isFatal) const
502{
503  int i = FindOption(name, isFatal);
504  if (i<0)
505    return false;
506
507  if (options[i].value != NULL)
508
509   
510  if (options[i].value != NULL) {
511    ParseVector(options[i].value, v);
512  }
513  else {
514    ParseVector(options[i].defaultValue, v);
515  }
516  return true;
517}
518
519bool
520Environment::GetStringValue(const char *name,
[1579]521                                                        char *value,
522                                                        const bool isFatal) const
[372]523{
524  int i = FindOption(name, isFatal);
525
526  if (i<0)
527    return false;
528
529 
530  if (options[i].value != NULL) {
531    // option was not read, so use the default
532    strcpy(value, options[i].value);
533  }
534  else {
535    // option was explicitly specified
536    strcpy(value, options[i].defaultValue);
537  }
538  return true;
539}
540
541void
542Environment::SetInt(const char *name, const int value)
543{
544
545  int i = FindOption(name);
546  if (i<0)
547    return;
548
549  if (options[i].type == optInt) {
550    delete options[i].value;
551    options[i].value = new char[16];
552    sprintf(options[i].value, "%.15d", value);
553  }
554  else {
555    Debug << "Internal error: Trying to set non-integer option " << name
556          << " to integral value.\n" << flush;
557    exit(1);
558  }
559}
560
561void
562Environment::SetFloat(const char *name, const Real value)
563{
564  int i = FindOption(name);
565  if (i<0)
566    return;
567
568  if (options[i].type == optFloat) {
569    delete options[i].value;
570    options[i].value = new char[25];
571    sprintf(options[i].value, "%.15e", value);
572  }
573  else {
574    Debug << "Internal error: Trying to set non-Real option " << name
575          << " to Real value.\n" << flush;
576    exit(1);
577  }
578}
579
580void
581Environment::SetBool(const char *name, const bool value)
582{
583  int i = FindOption(name);
584  if (i<0)
585    return;
586
587  if (options[i].type == optBool) {
588    delete options[i].value;
589    options[i].value = new char[6];
590    if (value)
591      sprintf(options[i].value, "true");
592    else
593      sprintf(options[i].value, "false");
594  }
595  else {
596    Debug << "Internal error: Trying to set non-bool option " << name
597          << " to boolean value.\n" << flush;
598    exit(1);
599  }
600}
601
602void
603Environment::SetVector(const char *name,
604                       const Vector3 &v)
605{
606  int i = FindOption(name);
607  if (i<0)
608    return;
609
610  if (options[i].type == optVector) {
611    delete options[i].value;
612    options[i].value = new char[128];
613    sprintf(options[i].value, "%.15e,%.15e,%.15e", v.x, v.y, v.z);
614  }
615  else {
616    Debug << "Internal error: Trying to set non-vector option " << name
617          << " to vector value.\n" << flush;
618    exit(1);
619  }
620}
621
622void
623Environment::SetString(const char *name, const char *value)
624{
625  int i = FindOption(name);
626  if (i<0)
627    return;
628
629  if (options[i].type == optString) {
630    delete options[i].value;
[863]631        options[i].value = ::strdup(value);
[372]632  }
633  else {
634    Debug << "Internal error: Trying to set non-string option " << name
635          << " to string value.\n" << flush;
636    exit(1);
637  }
638}
639
640void
641Environment::ParseCmdline(const int argc,
[492]642                                                  char **argv,
643                                                  const int index)
[372]644{
645  int curIndex = -1;
646
647  for (int i = 1; i < argc; i++) {
648    // if this parameter is non-optional, skip it and increment the counter
649    if (argv[i][0] != '-') {
650      curIndex++;
651      continue;
652    }
653    // make sure to skip all non-optional parameters
654    char *t = strchr(optionalParams, argv[i][1]);
655    if (t != NULL)
656      continue;
657
658    // if we are in the scope of the current parameter, parse it
659    if (curIndex == -1 || curIndex == index) {
660      if (argv[i][1] == 'D') {
661        // it's a full name definition
662        bool found = false;
663        int j;
664
665        char *t = strchr(argv[i] + 2, '=');
666        if (t == NULL) {
667          Debug << "Error: Missing '=' in option. "
668                << "Syntax is -D<name>=<value>.\n" << flush;
669          exit(1);
670        }
671        for (j = 0; j < numOptions; j++)
672          if (!strncmp(options[j].name, argv[i] + 2, t - argv[i] - 2) &&
673              (unsigned)(t - argv[i] - 2) == strlen(options[j].name)) {
674            found = true;
675            break;
676          }
677        if (!found) {
678          Debug << "Warning: Unregistered option " << argv[i] << ".\n" << flush;
679          //  exit(1);
680        }
681        if (found) {
682          if (!CheckType(t + 1, options[j].type)) {
683            Debug << "Error: invalid type of value " << t + 1 << " in option "
684                  << options[j].name << ".\n";
685            exit(1);
686          }
687          if (options[j].value != NULL)
688            delete options[j].value;
689          options[j].value = strdup(t + 1);
690        }
691      }
692      else {
693        // it's an abbreviation
694        bool found = false;
695        int j;
696       
697        for (j = 0; j < numOptions; j++)
698          if (options[j].abbrev != NULL &&
699              !strncmp(options[j].abbrev, argv[i] + 1, strlen(options[j].abbrev))) {
700            found = true;
701            break;
702          }
703        if (!found) {
704          Debug << "Warning: Unregistered option " << argv[i] << ".\n" << flush;
705          //          exit(1);
706        }
707        if (found) {
708          if (!CheckType(argv[i] + 1 + strlen(options[j].abbrev), options[j].type)) {
709            Debug << "Error: invalid type of value "
710                  << argv[i] + 1 + strlen(options[j].abbrev) << "in option "
711                  << options[j].name << ".\n";
712            exit(1);
713          }
714          if (options[j].value != NULL)
715            delete options[j].value;
716          options[j].value = strdup(argv[i] + 1 + strlen(options[j].abbrev));
717        }
718      }
719    }
720  }
721#ifdef _DEBUG_PARAMS
722  // write out the options table
723  cerr << "Options table for " << numOptions << " options:\n";
724  for (int j = 0; j < numOptions; j++) {
725    cerr << options[j];
726    cerr << "\n";
727  }
728  cerr << "Options done.\n" << flush;
729#endif // _DEBUG_PARAMS
730}
731
732
733char *
734Environment::ParseString(char *buffer, char *string) const
735{
736  char *s = buffer;
737  char *t = string + strlen(string);
738
739  // skip leading whitespaces
740  while (*s == ' ' || *s == '\t')
741    s++;
742  if (*s == '\0')
743    return NULL;
744  while ((*s >= 'a' && *s <= 'z') ||
745         (*s >= 'A' && *s <= 'Z') ||
746         (*s >= '0' && *s <= '9') ||
747         *s == '_')
748    *t++ = *s++;
749  *t = '\0';
750  // skip trailing whitespaces
751  while (*s == ' ' || *s == '\t')
752    s++;
753  return s;
754}
755
756const char code[] = "JIDHipewhfdhyd74387hHO&{WK:DOKQEIDKJPQ*H#@USX:#FWCQ*EJMQAHPQP(@G#RD";
757
758void
759Environment::DecodeString(char *buff, int max)
760{
761  buff[max] = 0;
762  char *p = buff;
763  const char *cp = code;
764  for (; *p; p++) {
765    if (*p != '\n')
766      *p = *p ^ *cp;
767    ++cp;
768    if (*cp == 0)
769      cp = code;
770  }
771}
772
773void
774Environment::CodeString(char *buff, int max)
775{
776  buff[max] = 0;
777  char *p = buff;
778  const char *cp = code;
779  for (; *p; p++) {
780    if (*p != '\n')
781      *p = *p ^ *cp;
782    ++cp;
783    if (*cp == 0)
784      cp = code;
785  }
786}
787
788void
789Environment::SaveCodedFile(char *filenameText,
790                            char *filenameCoded)
791{
792  ifstream envStream(filenameText);
793 
794  // some error had occured
795  if (envStream.fail()) {
796    cerr << "Error: Can't open file " << filenameText << " for reading (err. "
797         << envStream.rdstate() << ").\n";
798    return;
799  }
[1876]800
[372]801  char buff[256];
802  envStream.getline(buff, 255);
803  buff[8] = 0;
804  if (strcmp(buff, "CGX_CF10") == 0)
805    return;
806
807  ofstream cStream(filenameCoded);
808  cStream<<"CGX_CF10";
809 
810  // main loop
811  for (;;) {
812    // read in one line
813    envStream.getline(buff, 255);
814    if (!envStream)
815      break;
816    CodeString(buff, 255);
817    cStream<<buff;
818  }
819 
820}
821
822bool
823Environment::ReadEnvFile(const char *envFilename)
[975]824{
[372]825  char buff[MaxStringLength], name[MaxStringLength];
826  char *s, *t;
827  int i, line = 0;
828  bool found;
829  igzstream envStream(envFilename);
830
831  // some error had occured
832  if (envStream.fail()) {
833    cerr << "Error: Can't open file " << envFilename << " for reading (err. "
834         << envStream.rdstate() << ").\n";
835    return false;
836  }
[971]837
[372]838  name[0] = '\0';
839
840//    bool coded;
841//    envStream.getline(buff, 255);
842//    buff[8] = 0;
843//    if (strcmp(buff, "CGX_CF10") == 0)
844//      coded = true;
845//    else {
846//      coded = false;
847//      envStream.Rewind();
848//    }
849 
850  // main loop
851  for (;;) {
852    // read in one line
[1876]853    envStream.getline(buff, MaxStringLength-1);
[372]854   
855    if (!envStream)
856      break;
857
858//      if (coded)
859//        DecodeString(buff, 255);
860
861    line++;
862    // get rid of comments
863    s = strchr(buff, '#');
864    if (s != NULL)
865      *s = '\0';
866
867    // get one identifier
868    s = ParseString(buff, name);
869    // parse line
870    while (s != NULL) {
871      // it's a group name - make the full name
872      if (*s == '{') {
873        strcat(name, ".");
874        s++;
875        s = ParseString(s, name);
876        continue;
877      }
878      // end of group
879      if (*s == '}') {
880        if (strlen(name) == 0) {
881          cerr << "Error: unpaired } in " << envFilename << " (line "
882               << line << ").\n";
883          envStream.close();
884          return false;
885        }
886        name[strlen(name) - 1] = '\0';
887        t = strrchr(name, '.');
888        if (t == NULL)
889          name[0] = '\0';
890        else
891          *(t + 1) = '\0';
892        s++;
893        s = ParseString(s, name);
894        continue;
895      }
896      // find variable name in the table
897      found = false;
898      for (i = 0; i < numOptions; i++)
899        if (!strcmp(name, options[i].name)) {
900          found = true;
901          break;
902        }
903      if (!found) {
904        cerr << "Warning: unknown option " << name << " in environment file "
905             << envFilename << " (line " << line << ").\n";
906      } else
907        switch (options[i].type) {
908        case optInt: {
909          strtol(s, &t, 10);
910          if (t == s || (*t != ' ' && *t != '\t' &&
911                         *t != '\0' && *t != '}')) {
912            cerr << "Error: Mismatch in int variable " << name << " in "
913                 << "environment file " << envFilename << " (line "
914                 << line << ").\n";
915            envStream.close();
916            return false;
917          }
918          if (options[i].value != NULL)
919            delete options[i].value;
920          options[i].value = new char[t - s + 1];
921          strncpy(options[i].value, s, t - s);
922          options[i].value[t - s] = '\0';
923          s = t;
924          break;
925        }
926        case optFloat: {
927          strtod(s, &t);
928          if (t == s || (*t != ' ' && *t != '\t' &&
929                         *t != '\0' && *t != '}')) {
930            cerr << "Error: Mismatch in Real variable " << name << " in "
931                 << "environment file " << envFilename << " (line "
932                 << line << ").\n";
933            envStream.close();
934            return false;
935          }
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          break;
943        }
944        case optBool: {
945          t = s;
946          while ((*t >= 'a' && *t <= 'z') ||
947                 (*t >= 'A' && *t <= 'Z') ||
948                 *t == '+' || *t == '-')
949            t++;
950          if (((!strncasecmp(s, "true", t - s)  && t - s == 4) ||
951               (!strncasecmp(s, "false", t - s) && t - s == 5) ||
952               (!strncasecmp(s, "YES", t -s)    && t - s == 3) ||
953               (!strncasecmp(s, "NO", t - s)    && t - s == 2) ||
954               (!strncasecmp(s, "ON", t - s)    && t - s == 2) ||
955               (!strncasecmp(s, "OFF", t - s)   && t - s == 3) ||
956               (t - s == 1 && (*s == '+' || *s == '-'))) &&
957              (*t == ' ' || *t == '\t' || *t == '\0' || *t == '}')) {
958            if (options[i].value != NULL)
959              delete options[i].value;
960            options[i].value = new char[t - s + 1];
961            strncpy(options[i].value, s, t - s);
962            options[i].value[t - s] = '\0';
963            s = t;
964          }
965          else {
966            cerr << "Error: Mismatch in bool variable " << name << " in "
967                 << "environment file " << envFilename << " (line "
968                 << line << ").\n";
969            envStream.close();
970            return false;
971          }
972          break;
973        }
974        case optVector:{
975          strtod(s, &t);
976          if (*t == ' ' || *t == '\t') {
977            while (*t == ' ' || *t == '\t')
978              t++;
979            if (*t != ',')
980              t--;
981          }
982          if (t == s || (*t != ' ' && *t != '\t' && *t != ',')) {
983            cerr << "Error: Mismatch in vector variable " << name << " in "
984                 << "environment file " << envFilename << " (line "
985                 << line << ").\n";
986            envStream.close();
987            return false;
988          }
989          char *u;
990          strtod(t, &u);
991          t = u;
992          if (*t == ' ' || *t == '\t') {
993            while (*t == ' ' || *t == '\t')
994              t++;
995            if (*t != ',')
996              t--;
997          }
998          if (t == s || (*t != ' ' && *t != '\t' && *t != ',')) {
999            cerr << "Error: Mismatch in vector variable " << name << " in "
1000                 << "environment file " << envFilename << " (line "
1001                 << line << ").\n";
1002            envStream.close();
1003            return false;
1004          }
1005          strtod(t, &u);
1006          t = u;
1007          if (t == s || (*t != ' ' && *t != '\t' &&
1008                         *t != '\0' && *t != '}')) {
1009            cerr << "Error: Mismatch in vector variable " << name << " in "
1010                 << "environment file " << envFilename << " (line "
1011                 << line << ").\n";
1012            envStream.close();
1013            return false;
1014          }
1015          if (options[i].value != NULL)
1016            delete options[i].value;
1017          options[i].value = new char[t - s + 1];
1018          strncpy(options[i].value, s, t - s);
1019          options[i].value[t - s] = '\0';
1020          s = t;
1021          break;
1022        }
1023        case optString: {
1024          if (options[i].value != NULL)
1025            delete options[i].value;
1026          options[i].value = new char[strlen(s) + 1];
1027          strcpy(options[i].value, s);
1028          s += strlen(s);
1029          break;
1030        }
1031        default: {
1032          Debug << "Internal error: Unknown type of option.\n" << flush;
1033          exit(1);
1034        }
1035      }
1036      // prepare the variable name for next pass
1037      t = strrchr(name, '.');
1038      if (t == NULL)
1039        name[0] = '\0';
1040      else
1041        *(t + 1) = '\0';
1042      // get next identifier
1043      s = ParseString(s, name);
1044    }
1045  }
1046  envStream.close();
1047  return true;
1048}
1049
1050void
1051Environment::PrintUsage(ostream &s) const
1052{
1053  // Print out all environment variable names
1054  s << "Registered options:\n";
1055  for (int j = 0; j < numOptions; j++)
1056    s << options[j] << "\n";
1057  s << flush;
1058}
1059
[859]1060  /**
1061         Input scene filename. Currently simplified X3D (.x3d), Unigraphics (.dat),
1062         and UNC (.ply) formats are supported.
1063  */
[372]1064
1065Environment::Environment()
1066{
1067  optionalParams = NULL;
1068  paramRows = 0;
1069  numParams = 0;
1070  params = NULL;
[539]1071  maxOptions = 500;
[372]1072
1073 
1074// this is maximal nuber of options.
1075  numOptions = 0;
1076
1077  options = new COption[maxOptions];
1078
1079  if (options == NULL ) {
1080    Debug << "Error: Memory allocation failed.\n";
1081    exit(1);
1082  }
1083 
1084  // register all basic options
1085
1086  RegisterOption("Limits.threshold", optFloat, NULL, "0.01");
1087  RegisterOption("Limits.small", optFloat, NULL, "1e-6");
1088  RegisterOption("Limits.infinity", optFloat, NULL, "1e6");
1089
1090  RegisterOption("Scene.filename",
[492]1091                                 optString,
1092                                 "scene_filename=",
1093                                 "atlanta2.x3d");
[372]1094
1095  RegisterOption("Unigraphics.meshGrouping",
[492]1096                                 optInt,
1097                                 "unigraphics_mesh_grouping=",
1098                                 "0");
[372]1099 
[1221]1100   RegisterOption("ObjParser.meshGrouping",
1101                                 optInt,
1102                                 "objparser_mesh_grouping=",
1103                                 "0");
[372]1104
1105  RegisterOption("KdTree.Termination.minCost",
[492]1106                                 optInt,
1107                                 "kd_term_min_cost=",
1108                                 "10");
[859]1109 
[752]1110  RegisterOption("KdTree.Termination.maxNodes",
1111                                 optInt,
1112                                 "kd_term_max_nodes=",
1113                                 "200000");
[859]1114 
[372]1115  RegisterOption("KdTree.Termination.maxDepth",
[492]1116                                 optInt,
1117                                 "kd_term_max_depth=",
1118                                 "20");
[372]1119
1120  RegisterOption("KdTree.Termination.maxCostRatio",
[492]1121                                 optFloat,
1122                                 "kd_term_max_cost_ratio=",
1123                                 "1.5");
[372]1124
1125  RegisterOption("KdTree.Termination.ct_div_ci",
[492]1126                                 optFloat,
1127                                 "kd_term_ct_div_ci=",
1128                                 "1.0");
[372]1129
1130  RegisterOption("KdTree.splitMethod",
[492]1131                                 optString,
1132                                 "kd_split_method=",
1133                                 "spatialMedian");
[372]1134
1135  RegisterOption("KdTree.splitBorder",
1136                 optFloat,
[492]1137                 "kd_split_border=",
[372]1138                 "0.1");
1139
1140  RegisterOption("KdTree.sahUseFaces",
1141                 optBool,
[492]1142                 "kd_sah_use_faces=",
[372]1143                 "true");
1144
1145  RegisterOption("MeshKdTree.Termination.minCost",
1146                 optInt,
[492]1147                 "kd_term_min_cost=",
[372]1148                 "10");
1149 
1150  RegisterOption("MeshKdTree.Termination.maxDepth",
1151                 optInt,
[492]1152                 "kd_term_max_depth=",
[372]1153                 "20");
1154
1155  RegisterOption("MeshKdTree.Termination.maxCostRatio",
1156                 optFloat,
[492]1157                 "kd_term_max_cost_ratio=",
[372]1158                 "1.5");
1159
1160  RegisterOption("MeshKdTree.Termination.ct_div_ci",
1161                 optFloat,
[492]1162                 "kd_term_ct_div_ci=",
[372]1163                 "1.0");
1164
1165  RegisterOption("MeshKdTree.splitMethod",
1166                 optString,
[492]1167                 "kd_split_method=",
[372]1168                 "spatialMedian");
1169
1170  RegisterOption("MeshKdTree.splitBorder",
1171                 optFloat,
[492]1172                 "kd_split_border=",
[372]1173                 "0.1");
1174
[508]1175  RegisterOption("SamplingPreprocessor.totalSamples",
[372]1176                 optInt,
[492]1177                 "total_samples=",
[372]1178                 "1000000");
1179
[508]1180  RegisterOption("SamplingPreprocessor.samplesPerPass",
[372]1181                 optInt,
[492]1182                 "samples_per_pass=",
[372]1183                 "10");
1184
[811]1185  RegisterOption("RenderSampler.samples",
1186                                 optInt,
1187                                 "render_sampler_samples=",
1188                                 "1000");
1189
[1001]1190  RegisterOption("RenderSampler.visibleThreshold",
1191                                 optInt,
1192                                 "render_sampler_visible_threshold=",
1193                                 "0");
1194
1195
[997]1196   RegisterOption("RenderSampler.useOcclusionQueries",
1197                                 optBool,
1198                                 "render_sampler_use_occlusion_queries=",
1199                                 "true");
1200
1201   RegisterOption("VssPreprocessor.initialSamples",
[492]1202                                 optInt,
[1486]1203                                 "vss_initial_samples=",
[492]1204                                 "100000");
1205 
[1001]1206  RegisterOption("VssPreprocessor.testBeamSampling",
1207                                optBool,
[1486]1208                                "vss_beam_sampling=",
[1001]1209                                "false");
[532]1210
[469]1211  RegisterOption("VssPreprocessor.vssSamples",
[492]1212                                 optInt,
1213                                 "vss_samples=",
1214                                 "1000000");
[376]1215       
[427]1216  RegisterOption("VssPreprocessor.vssSamplesPerPass",
[492]1217                                 optInt,
1218                                 "vss_samples_per_pass=",
1219                                 "1000");
1220 
[469]1221  RegisterOption("VssPreprocessor.samplesPerPass",
[492]1222                                 optInt,
[1486]1223                                 "vss_samples_per_pass=",
[492]1224                                 "100000");
[376]1225
[403]1226  RegisterOption("VssPreprocessor.useImportanceSampling",
[492]1227                                 optBool,
1228                                 "vss_use_importance=",
1229                                 "true");
[403]1230
[1785]1231 
[674]1232   RegisterOption("VssPreprocessor.enlargeViewSpace",
1233                                 optBool,
1234                                 "vss_enlarge_viewspace=",
[675]1235                                 "false");
[674]1236
[490]1237   RegisterOption("VssPreprocessor.loadInitialSamples",
1238          optBool,
[674]1239          "vss_load_loadInitialSamples=",
[490]1240          "false");
[445]1241
[490]1242   RegisterOption("VssPreprocessor.storeInitialSamples",
1243          optBool,
[674]1244          "vss_store_storedInitialSamples=",
[490]1245          "false");
[1723]1246 
[501]1247
[445]1248
[1486]1249   /************************************************************************************/
1250   /*                         GvsPrerpocessor related options                          */
1251   /************************************************************************************/
[445]1252
[1486]1253
1254   RegisterOption("GvsPreprocessor.totalSamples",
1255                 optInt,
1256                 "gvs_total_samples=",
1257                 "1000000");
1258   
1259   RegisterOption("GvsPreprocessor.samplesPerPass",
1260                 optInt,
1261                 "gvs_samples_per_pass=",
1262                 "100000");
1263   
1264   RegisterOption("GvsPreprocessor.initialSamples",
1265                 optInt,
1266                 "gvs_initial_samples=",
1267                 "256");
1268
1269   RegisterOption("GvsPreprocessor.epsilon",
1270                 optFloat,
[1522]1271                 "gvs_epsilon=",
[1486]1272                 "0.00001");
1273
[1500]1274    RegisterOption("GvsPreprocessor.threshold",
1275                 optFloat,
[1522]1276                 "gvs_threshold=",
[1500]1277                 "1.5");
[1486]1278
[1500]1279
[1520]1280
[1486]1281  /***********************************************************************************/
1282  /*                         View cells related options                              */
1283  /***********************************************************************************/
1284
1285
[508]1286        RegisterOption("ViewCells.type",
1287                        optString,
[664]1288                        "view_cells_type=",
[662]1289                        "vspBspTree");
[372]1290
[662]1291        RegisterOption("ViewCells.samplingType",
1292                        optString,
[664]1293                        "view_cells_sampling_type=",
[662]1294                        "box");
1295
[666]1296        RegisterOption("ViewCells.mergeStats",
[660]1297                                        optString,
[666]1298                                        "view_cells_merge_stats=",
1299                                        "mergeStats.log");
[660]1300
[664]1301        RegisterOption("ViewCells.Evaluation.statsPrefix",
[660]1302                                        optString,
[664]1303                                        "view_cells_evaluation_stats_prefix=",
[660]1304                                        "viewCells");
[1418]1305
[735]1306        RegisterOption("ViewCells.Evaluation.histogram",
1307                                        optBool,
1308                                        "view_cells_evaluation_histogram=",
1309                                        "false");
1310
[997]1311        RegisterOption("ViewCells.Evaluation.histoStepSize",
[735]1312                                        optInt,
[997]1313                                        "view_cells_evaluation_histo_step_size=",
[744]1314                                        "5000");
[735]1315
[728]1316        RegisterOption("ViewCells.renderCostEvaluationType",
1317                                        optString,
1318                                        "view_cells_render_cost_evaluation=",
1319                                        "perobject");
1320
[660]1321        RegisterOption("ViewCells.active",
1322                                        optInt,
[664]1323                                        "view_cells_active=",
[660]1324                                        "1000");
[581]1325
[574]1326        RegisterOption("ViewCells.Construction.samples",
1327                                        optInt,
1328                                        "view_cells_construction_samples=",
[1134]1329                                        "0");
[574]1330
1331        RegisterOption("ViewCells.Construction.samplesPerPass",
1332                                        optInt,
1333                                        "view_cells_construction_samples_per_pass=",
1334                                        "500000");
1335
[508]1336        RegisterOption("ViewCells.PostProcess.samples",
1337                                        optInt,
[712]1338                                        "view_cells_post_process_samples=",
[1134]1339                                        "0");
[421]1340
[508]1341        RegisterOption("ViewCells.Visualization.samples",
1342                                        optInt,
1343                                        "view_cells_visualization_samples=",
[1134]1344                                        "0");
[372]1345
[1020]1346        RegisterOption("ViewCells.Visualization.maxOutput",
1347                                        optInt,
1348                                        "view_cells_visualization_max_output=",
1349                                        "20");
1350
[697]1351        RegisterOption("ViewCells.Filter.maxSize",
1352                                        optInt,
1353                                        "view_cells_filter_max_size=",
1354                                        "4");
1355
1356        RegisterOption("ViewCells.Filter.width",
1357                                        optFloat,
1358                                        "view_cells_filter_width=",
[746]1359                                        "200.0");
[697]1360
[508]1361        RegisterOption("ViewCells.loadFromFile",
1362                                        optBool,
[664]1363                                        "view_cells_load_from_file=",
[508]1364                                        "false");
[485]1365
[586]1366        RegisterOption("ViewCells.PostProcess.refine",
1367                                        optBool,
[664]1368                                        "view_cells_refine=",
[586]1369                                        "false");
1370
1371        RegisterOption("ViewCells.PostProcess.compress",
1372                                        optBool,
[664]1373                                        "view_cells_post_process_compress=",
[586]1374                                        "false");
1375
[662]1376        RegisterOption("ViewCells.Evaluation.samples",
1377                                        optInt,
1378                                        "view_cells_evaluation_samples=",
1379                                        "8000000");
1380
[722]1381        RegisterOption("ViewCells.Evaluation.samplingType",
[837]1382                                        optString,
1383                                        "view_cells_evaluation_sampling_type=",
1384                                        "box");
[722]1385
[662]1386        RegisterOption("ViewCells.Evaluation.samplesPerPass",
1387                                        optInt,
1388                                        "view_cells_evaluation_samples_per_pass=",
1389                                        "300000");
1390
[1695]1391        RegisterOption("ViewCells.Evaluation.samplesForStats",
1392                                        optInt,
1393                                        "view_cells_evaluation_samples_for_stats=",
1394                                        "300000");
1395
[508]1396        RegisterOption("ViewCells.exportToFile",
1397                                        optBool,
[676]1398                                        "view_cells_export_to_file=",
[508]1399                                        "false");
1400
[844]1401        RegisterOption("ViewCells.exportPvs",
1402                                        optBool,
1403                                        "view_cells_export_pvs=",
1404                                        "false");
1405
[840]1406        RegisterOption("ViewCells.exportBboxesForPvs",
1407                                        optBool,
[844]1408                                        "view_cells_export_bounding_boxes=",
[840]1409                                        "true");
1410       
1411        RegisterOption("ViewCells.boxesFilename",
1412                                        optString,
1413                                        "view_cells_boxes_filename=",
1414                                        "boxes.out");
1415
[664]1416        RegisterOption("ViewCells.evaluateViewCells",
1417                                        optBool,
[670]1418                                        "view_cells_evaluate=",
[664]1419                                        "false");
1420
[508]1421        RegisterOption("ViewCells.maxViewCells",
[667]1422                                        optInt,
1423                                        "view_cells_max_view_cells=",
1424                                        "0");
[508]1425
[1713]1426        RegisterOption("ViewCells.Evaluation.stepSize",
1427                                        optInt,
1428                                        "view_cells_evaluation_step_size=",
1429                                        "100");
1430
[511]1431        RegisterOption("ViewCells.maxPvsRatio",
1432                                        optFloat,
1433                                        "view_cells_max_pvs_ratio=",
1434                                        "0.1");
[508]1435
1436        RegisterOption("ViewCells.filename",
[667]1437                                        optString,
1438                                        "view_cells_filename=",
1439                                        "atlanta_viewcells_large.x3d");
[508]1440
1441        RegisterOption("ViewCells.height",
[667]1442                                        optFloat,
1443                                        "view_cells_height=",
1444                                        "5.0");
[508]1445
1446        RegisterOption("ViewCells.Visualization.colorCode",
[667]1447                                        optString,
[708]1448                                        "view_cells_visualization_color_code=",
[667]1449                                        "PVS");
[482]1450
[667]1451        RegisterOption("ViewCells.Visualization.clipPlanePos",
1452                                        optFloat,
[708]1453                                        "view_cells_visualization_clip_plane_pos=",
[667]1454                                        "0.35");
[579]1455       
[508]1456        RegisterOption("ViewCells.Visualization.exportGeometry",
[667]1457                                        optBool,
[708]1458                                        "view_cells_visualization_export_geometry=",
[667]1459                                        "false");
[445]1460
[667]1461        RegisterOption("ViewCells.Visualization.exportRays",
1462                                        optBool,
[708]1463                                        "view_cells_visualization_export_rays=",
[667]1464                                        "false");
1465
[564]1466        RegisterOption("ViewCells.processOnlyValidViewCells",
[667]1467                                        optBool,
[1761]1468                                        "view_cells_process_only_valid_view_cells",
[667]1469                                        "false");
[660]1470
[580]1471        RegisterOption("ViewCells.PostProcess.maxCostRatio",
1472                        optFloat,
[667]1473                        "view_cells_post_process_max_cost_ratio=",
[580]1474                        "0.9");
1475       
1476        RegisterOption("ViewCells.PostProcess.renderCostWeight",
1477                        optFloat,
[667]1478                        "view_cells_post_process_render_cost_weight",
[580]1479                        "0.5");
1480       
1481        RegisterOption("ViewCells.PostProcess.avgCostMaxDeviation",
1482                        optFloat,
[1143]1483                        "view_cells_avgcost_max_deviations",
[580]1484                        "0.5");
1485
1486        RegisterOption("ViewCells.PostProcess.maxMergesPerPass",
1487                optInt,
[667]1488                "view_cells_post_process_max_merges_per_pass=",
[580]1489                "500");
1490
1491        RegisterOption("ViewCells.PostProcess.minViewCells",
1492                optInt,
[667]1493                "view_cells_post_process_min_view_cells=",
[580]1494                "1000");
1495
1496        RegisterOption("ViewCells.PostProcess.useRaysForMerge",
1497                optBool,
1498                "view_cells_post_process_use_rays_for_merge=",
1499                "false");
[591]1500       
1501        RegisterOption("ViewCells.PostProcess.merge",
1502                optBool,
[666]1503                "view_cells_post_process_merge=",
[591]1504                "true");
[580]1505
1506        RegisterOption("ViewCells.Visualization.exportMergedViewCells",
1507                optBool,
1508                "view_cells_viz_export_merged_viewcells=",
1509                "false");
1510
[582]1511        RegisterOption("ViewCells.maxStaticMemory",
1512                optFloat,
1513                "view_cells_max_static_mem=",
1514                "8.0");
[580]1515
[660]1516        RegisterOption("ViewCells.Visualization.useClipPlane",
[591]1517                optBool,
[660]1518                "view_cells_viz_use_clip_plane=",
[591]1519                "false");
1520       
[666]1521        RegisterOption("ViewCells.showVisualization",
1522                optBool,
1523                "view_cells_show_visualization=",
1524                "false");
1525
[660]1526        RegisterOption("ViewCells.Visualization.clipPlaneAxis",
[591]1527                optInt,
[660]1528                "view_cells_viz_clip_plane_axis=",
[591]1529                "0");
1530
[1545]1531        RegisterOption("ViewCells.loadGeometry",
1532                optBool,
1533                "view_cells_load_geometry=",
1534                "false");
[1159]1535       
[1545]1536        RegisterOption("ViewCells.geometryFilename",
1537                optString,
1538                "view_cells_geometry_filename=",
1539                "viewCellsGeometry.x3d");
1540
1541        RegisterOption("ViewCells.useBaseTrianglesAsGeometry",
1542                optBool,
1543                "view_cells_use_base_triangles_as_geometry=",
1544                "false");
1545
[1887]1546        RegisterOption("ViewCells.compressObjects",
1547                optBool,
1548                "view_cells_compress_objects=",
1549                "false");
[1545]1550
[1887]1551
[1418]1552        /****************************************************************************/
1553        /*                     Render simulation related options                    */
1554        /****************************************************************************/
[372]1555
[406]1556
[508]1557        RegisterOption("Simulation.objRenderCost",
1558                        optFloat,
1559                        "simulation_obj_render_cost",
1560                        "1.0");
[409]1561
[508]1562        RegisterOption("Simulation.vcOverhead",
1563                        optFloat,
1564                        "simulation_vc_overhead",
1565                        "0.05");
[445]1566
[508]1567        RegisterOption("Simulation.moveSpeed",
1568                        optFloat,
1569                        "simulation_moveSpeed",
1570                        "1.0");
[445]1571
1572
1573
[1486]1574        /******************************************************************/
1575        /*                    Bsp tree related options                    */
1576        /******************************************************************/
[445]1577
[372]1578
[508]1579        RegisterOption("BspTree.Construction.input",
1580                optString,
1581                "bsp_construction_input=",
1582                "fromViewCells");
[1867]1583       
[660]1584        RegisterOption("BspTree.subdivisionStats",
1585                                        optString,
[666]1586                                        "bsp_subdivision_stats=",
[660]1587                                        "bspSubdivisionStats.log");
1588
[508]1589        RegisterOption("BspTree.Construction.samples",
1590                optInt,
1591                "bsp_construction_samples=",
1592                "100000");
[390]1593
[508]1594        RegisterOption("BspTree.Construction.epsilon",
1595                optFloat,
[1023]1596                "bsp_construction_epsilon=",
[508]1597                "0.002");
[397]1598
[508]1599        RegisterOption("BspTree.Termination.minPolygons",
1600                        optInt,
1601                        "bsp_term_min_polygons=",
1602                        "5");
[409]1603
[508]1604        RegisterOption("BspTree.Termination.minPvs",
1605                        optInt,
1606                        "bsp_term_min_pvs=",
1607                        "20");
[372]1608
[587]1609        RegisterOption("BspTree.Termination.minProbability",
[508]1610                        optFloat,
[587]1611                        "bsp_term_min_probability=",
[508]1612                        "0.001");
[424]1613
[508]1614        RegisterOption("BspTree.Termination.maxRayContribution",
1615                        optFloat,
1616                        "bsp_term_ray_contribution=",
1617                        "0.005");
[372]1618
[508]1619        RegisterOption("BspTree.Termination.minAccRayLenght",
1620                        optFloat,
1621                        "bsp_term_min_acc_ray_length=",
1622                        "50");
[372]1623
[508]1624        RegisterOption("BspTree.Termination.minRays",
1625                        optInt,
1626                        "bsp_term_min_rays=",
1627                        "-1");
[372]1628
[508]1629        RegisterOption("BspTree.Termination.ct_div_ci",
1630                        optFloat,
1631                        "bsp_term_ct_div_ci=",
1632                        "0.0");
[372]1633
[508]1634        RegisterOption("BspTree.Termination.maxDepth",
1635                        optInt,
1636                        "bsp_term_max_depth=",
1637                        "100");
[372]1638
[508]1639        RegisterOption("BspTree.Termination.maxCostRatio",
1640                        optFloat,
1641                        "bsp_term_axis_aligned_max_cost_ratio=",
1642                        "1.5");
[372]1643
[508]1644        RegisterOption("BspTree.Termination.AxisAligned.ct_div_ci",
1645                        optFloat,
1646                        "bsp_term_axis_aligned_ct_div_ci=",
1647                        "0.5");
[372]1648
[508]1649        RegisterOption("BspTree.AxisAligned.splitBorder",
1650                        optFloat,
1651                        "bsp__axis_aligned_split_border=",
1652                        "0.1");
[372]1653
[508]1654        RegisterOption("BspTree.Termination.AxisAligned.minPolys",
1655                        optInt,
1656                        "bsp_term_axis_aligned_max_polygons=",
1657                        "50");
[379]1658
[508]1659        RegisterOption("BspTree.Termination.AxisAligned.minObjects",
1660                        optInt,
1661                        "bsp_term_min_objects=",
1662                        "3");
[441]1663
[508]1664        RegisterOption("BspTree.Termination.AxisAligned.minRays",
1665                        optInt,
1666                        "bsp_term_axis_aligned_min_rays=",
1667                        "-1");
[374]1668
[508]1669        RegisterOption("BspTree.splitPlaneStrategy",
1670                        optString,
1671                        "bsp_split_method=",
1672                        "leastSplits");
[424]1673
[508]1674        RegisterOption("BspTree.maxPolyCandidates",
1675                optInt,
1676                "bsp_max_poly_candidates=",
1677                "20");
[469]1678
[508]1679        RegisterOption("BspTree.maxRayCandidates",
1680                optInt,
1681                "bsp_max_plane_candidates=",
1682                "20");
[382]1683
[508]1684        RegisterOption("BspTree.maxTests",
1685                optInt,
1686                "bsp_max_tests=",
1687                "5000");
[382]1688
[587]1689        RegisterOption("BspTree.Termination.maxViewCells",
1690                optInt,
1691                "bsp_max_view_cells=",
1692                "5000");
1693
[508]1694        RegisterOption("BspTree.Visualization.exportSplits",
1695                optBool,
[1545]1696                "bsp_visualization.export_splits=",
[508]1697                "false");
[445]1698
[508]1699        RegisterOption("BspTree.Factor.verticalSplits", optFloat, "bsp_factor_vertical=", "1.0");
1700        RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "bsp_factor_largest_poly=", "1.0");
1701        RegisterOption("BspTree.Factor.blockedRays", optFloat, "bsp_factor_blocked=", "1.0");
1702        RegisterOption("BspTree.Factor.leastSplits", optFloat, "bsp_factor_least_splits=", "1.0");
1703        RegisterOption("BspTree.Factor.balancedPolys", optFloat, "bsp_factor_balanced_polys=", "1.0");
1704        RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "bsp_factor_balanced_view_cells=", "1.0");
1705        RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "bsp_factor_least_ray_splits=", "1.0");
1706        RegisterOption("BspTree.Factor.balancedRays", optFloat, "bsp_factor_balanced_rays=", "1.0");
1707        RegisterOption("BspTree.Factor.pvs", optFloat, "bsp_factor_pvs=", "1.0");
[408]1708
[508]1709        /************************************************************************************/
1710        /*                         Preprocessor related options                             */
1711        /************************************************************************************/
[408]1712
[508]1713        RegisterOption("Preprocessor.type",
1714                                        optString,
1715                                        "preprocessor=",
1716                                        "sampling");
[408]1717
[1771]1718        RegisterOption("Preprocessor.stats",
1719                                        optString,
1720                                        "preprocessor_stats=",
1721                                        "stats.log");
1722
[508]1723        RegisterOption("Preprocessor.samplesFilename",
1724                                        optString,
[676]1725                                        "preprocessor_samples_filename=",
[508]1726                                        "rays.out");
[408]1727
[1379]1728        RegisterOption("Preprocessor.loadMeshes",
[658]1729                                        optBool,
[1486]1730                                        "preprocessor_load_meshes=",
[1379]1731                                        "true");
[658]1732
[1785]1733        RegisterOption("Preprocessor.evaluateFilter",
1734                                   optBool,
1735                                   "preprocessor_evaluate_filter",
1736                                   "false");
1737
[1613]1738        RegisterOption("Preprocessor.delayVisibilityComputation",
1739                                   optBool,
1740                                   "preprocessor_delay_computation=",
1741                                   "true");
1742
[563]1743        RegisterOption("Preprocessor.pvsRenderErrorSamples",
1744                                   optInt,
[1444]1745                                   "preprocessor_pvs_rendererror_samples=",
[563]1746                                   "10000");
[682]1747       
1748        RegisterOption("Preprocessor.useGlRenderer",
1749                                        optBool,
[1757]1750                                        "preprocessor_use_gl_renderer",
[682]1751                                        "false");
1752
[538]1753        RegisterOption("Preprocessor.useGlDebugger",
1754                                        optBool,
[1757]1755                                        "preprocessor_use_gl_debugger",
[538]1756                                        "false");
1757
[534]1758        RegisterOption("Preprocessor.detectEmptyViewSpace",
1759                                   optBool,
[682]1760                                   "preprocessor_detect_empty_viewspace=",
[534]1761                                   "false");
1762       
[599]1763        RegisterOption("Preprocessor.quitOnFinish",
1764                                   optBool,
[1112]1765                                   "preprocessor_quit_on_finish",
[599]1766                                   "true");
[534]1767
[685]1768        RegisterOption("Preprocessor.computeVisibility",
1769                                   optBool,
1770                                   "preprocessor_compute_visibility=",
1771                                   "true");
[682]1772
[871]1773        RegisterOption("Preprocessor.exportVisibility",
1774                                   optBool,
[997]1775                                   "preprocessor_export_visibility=",
[871]1776                                   "true");
[682]1777
[871]1778        RegisterOption("Preprocessor.visibilityFile",
1779                                   optString,
1780                                   "preprocessor_visibility_file=",
1781                                   "visibility.xml");
1782
1783        RegisterOption("Preprocessor.applyVisibilityFilter",
1784                                   optBool,
[997]1785                                   "preprocessor_apply_filter=",
[1756]1786                                   "false");
[904]1787       
1788        RegisterOption("Preprocessor.applyVisibilitySpatialFilter",
1789                                   optBool,
[997]1790                                   "preprocessor_apply_spatial_filter=",
[1756]1791                                   "false");
[871]1792
[878]1793        RegisterOption("Preprocessor.visibilityFilterWidth",
1794                                   optFloat,
1795                                   "preprocessor_visibility_filter_width=",
1796                                   "0.02");
[871]1797
[991]1798        RegisterOption("Preprocessor.histogram.maxValue",
1799                                        optInt,
1800                                        "preprocessor_histogram_max_value=",
1801                                        "1000");
[871]1802
[1221]1803        RegisterOption("Preprocessor.rayCastMethod",
1804                                        optInt,
1805                                        "preprocessor_ray_cast_method=",
1806                                        "0");
1807
[991]1808        RegisterOption("Preprocessor.histogram.intervals",
1809                                        optInt,
1810                                        "preprocessor_histogram_intervals=",
1811                                        "20");
[878]1812
[1771]1813        RegisterOption("Preprocessor.histogram.file",
1814                                   optString,
1815                                   "preprocessor_histogram_file=",
1816                                   "histogram.log");
1817
[1414]1818        RegisterOption("Preprocessor.exportKdTree",
1819                                        optBool,
1820                                        "preprocessor_export_kd_tree=",
1821                                        "false");
[991]1822
[1414]1823        RegisterOption("Preprocessor.loadKdTree",
1824                                        optBool,
1825                                        "preprocessor_load_kd_tree=",
1826                                        "false");
1827
[1415]1828        RegisterOption("Preprocessor.kdTreeFilename",
1829                                        optString,
1830                                        "preprocessor_kd_tree_filename=",
1831                                        "vienna_kdtree.bin.gz");
[1414]1832
[1695]1833        RegisterOption("Preprocessor.exportObj",
1834                                        optBool,
1835                                        "preprocessor_export_obj=",
1836                                        "false");
1837
[1723]1838   RegisterOption("Preprocessor.useViewSpaceBox",
1839          optBool,
1840          "preprocessor_use_viewspace_box=",
1841          "false");   
1842   
[1415]1843        /*************************************************************************/
1844        /*             VSS Preprocessor cells related options                    */
1845        /*************************************************************************/
[1414]1846
[469]1847        RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12");
1848        RegisterOption("VssTree.minPvs", optInt, "kd_minpvs=", "1");
1849        RegisterOption("VssTree.minRays", optInt, "kd_minrays=", "10");
1850        RegisterOption("VssTree.maxCostRatio", optFloat, "maxcost=", "0.95");
1851        RegisterOption("VssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5");
[382]1852
[469]1853        RegisterOption("VssTree.epsilon", optFloat, "kd_eps=", "1e-6");
1854        RegisterOption("VssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0");
1855        RegisterOption("VssTree.randomize", optBool, "randomize", "false");
1856        RegisterOption("VssTree.splitType", optString, "split=", "queries");
1857        RegisterOption("VssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false");
1858        RegisterOption("VssTree.useRss", optBool, "rss=", "false");
1859        RegisterOption("VssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000");
[382]1860
[469]1861        RegisterOption("VssTree.minSize", optFloat, "minsize=", "0.001");
[382]1862
[469]1863        RegisterOption("VssTree.maxTotalMemory", optFloat, "mem=", "60.0");
1864        RegisterOption("VssTree.maxStaticMemory", optFloat, "statmem=", "8.0");
[438]1865
[469]1866        RegisterOption("VssTree.queryType", optString, "qtype=", "static");
[438]1867
[532]1868       
1869       
[469]1870        RegisterOption("VssTree.queryPosWeight", optFloat, "qposweight=", "0.0");
[997]1871        RegisterOption("VssTree.useRefDirSplits", optBool, "refdir=", "false");
[469]1872        RegisterOption("VssTree.refDirAngle", optFloat, "refangle=", "10");
1873        RegisterOption("VssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1");
1874        RegisterOption("VssTree.accessTimeThreshold", optInt, "accesstime=", "1000");
1875        RegisterOption("VssTree.minCollapseDepth", optInt, "colldepth=", "4");
[446]1876
[469]1877        RegisterOption("VssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true");
1878        RegisterOption("VssTree.dirSplitDepth", optInt, "dirsplidepth=", "10");
1879
1880
1881        RegisterOption("RssPreprocessor.initialSamples",
1882                                                                        optInt,
[1486]1883                                                                        "rss_initial_samples=",
[469]1884                                                                        "100000");
1885
[463]1886        RegisterOption("RssPreprocessor.vssSamples",
[508]1887                                        optInt,
1888                                        "rss_vss_samples=",
1889                                        "1000000");
1890
[469]1891        RegisterOption("RssPreprocessor.vssSamplesPerPass",
[508]1892                                        optInt,
1893                                        "rss_vss_samples_per_pass=",
1894                                        "1000");
1895
[492]1896        RegisterOption("RssPreprocessor.samplesPerPass",
[508]1897                                        optInt,
1898                                        "rss_samples_per_pass=",
1899                                        "100000");
1900
[469]1901        RegisterOption("RssPreprocessor.useImportanceSampling",
[508]1902                                        optBool,
[1112]1903                                        "rss_use_importance",
[508]1904                                        "true");
1905
[1785]1906        RegisterOption("RssPreprocessor.useRssTree",
1907                                        optBool,
1908                                        "rss_use_rss_tree",
1909                                        "true");
1910
[492]1911        RegisterOption("RssPreprocessor.objectBasedSampling",
[508]1912                                        optBool,
[1112]1913                                        "rss_object_based_sampling",
[508]1914                                        "true");
1915
[492]1916        RegisterOption("RssPreprocessor.directionalSampling",
[508]1917                                        optBool,
[1112]1918                                        "rss_directional_sampling",
[508]1919                                        "false");
1920
[1877]1921        RegisterOption("RssPreprocessor.distributions",
1922                                   optString,
1923                                   "rss_distributions=",
1924                                   "rss+spatial+object");
1925       
[1199]1926        RegisterOption("RssTree.hybridDepth", optInt, "hybrid_depth=", "10");
[469]1927        RegisterOption("RssTree.maxDepth", optInt, "kd_depth=", "12");
1928        RegisterOption("RssTree.minPvs", optInt, "kd_minpvs=", "1");
1929        RegisterOption("RssTree.minRays", optInt, "kd_minrays=", "10");
1930        RegisterOption("RssTree.maxCostRatio", optFloat, "maxcost=", "0.95");
1931        RegisterOption("RssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5");
[508]1932
[469]1933        RegisterOption("RssTree.epsilon", optFloat, "kd_eps=", "1e-6");
1934        RegisterOption("RssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0");
[997]1935        RegisterOption("RssTree.randomize", optBool, "randomize=", "false");
[1199]1936        RegisterOption("RssTree.splitType", optString, "rss_split=", "queries");
[469]1937        RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false");
[508]1938
[469]1939        RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000");
[508]1940
[469]1941        RegisterOption("RssTree.minSize", optFloat, "minsize=", "0.001");
[508]1942
[469]1943        RegisterOption("RssTree.maxTotalMemory", optFloat, "mem=", "60.0");
1944        RegisterOption("RssTree.maxStaticMemory", optFloat, "statmem=", "8.0");
[508]1945
[469]1946        RegisterOption("RssTree.queryType", optString, "qtype=", "static");
[508]1947
[469]1948        RegisterOption("RssTree.queryPosWeight", optFloat, "qposweight=", "0.0");
1949        RegisterOption("RssTree.useRefDirSplits", optBool, "refdir", "false");
1950        RegisterOption("RssTree.refDirAngle", optFloat, "refangle=", "10");
1951        RegisterOption("RssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1");
1952        RegisterOption("RssTree.accessTimeThreshold", optInt, "accesstime=", "1000");
1953        RegisterOption("RssTree.minCollapseDepth", optInt, "colldepth=", "4");
[508]1954
[997]1955        RegisterOption("RssTree.interleaveDirSplits", optBool, "interleavedirsplits=", "true");
[469]1956        RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10");
[997]1957        RegisterOption("RssTree.importanceBasedCost", optBool, "importance_based_cost=", "true");
[492]1958        RegisterOption("RssTree.maxRays", optInt, "rss_max_rays=", "2000000");
[508]1959
[516]1960        RegisterOption("RssTree.perObjectTree", optBool, "rss_per_object_tree", "false");
1961
[997]1962        RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs=", "false");
1963        RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree=", "false");
1964        RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays=", "false");
[469]1965        RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000");
[997]1966        RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells=", "false");
[563]1967        RegisterOption("RssPreprocessor.updateSubdivision",
1968                                   optBool,
[997]1969                                   "rss_update_subdivision=",
[563]1970                                   "false");
[463]1971
[492]1972
[508]1973/************************************************************************************/
[1023]1974/*                      Rss preprocessor related options                            */
[508]1975/************************************************************************************/
1976
1977
[490]1978        RegisterOption("RssPreprocessor.loadInitialSamples",
[508]1979                                        optBool,
1980                                        "vss_load_loadInitialSamples=",
1981                                        "false");
[445]1982
[490]1983        RegisterOption("RssPreprocessor.storeInitialSamples",
[508]1984                                        optBool,
1985                                        "vss_store_storeInitialSamples=",
1986                                        "false");
[490]1987
[508]1988
1989/************************************************************************************/
[1023]1990/*                 View space partition BSP tree related options                    */
[508]1991/************************************************************************************/
1992
[654]1993        RegisterOption("VspBspTree.Termination.minGlobalCostRatio",
1994                                        optFloat,
[997]1995                                        "vsp_bsp_term_min_global_cost_ratio=",
[654]1996                                        "0.0001");
[508]1997
[655]1998        RegisterOption("VspBspTree.useSplitCostQueue",
1999                optBool,
[667]2000                "vsp_bsp_use_split_cost_queue=",
[655]2001                "true");
2002
[654]2003        RegisterOption("VspBspTree.Termination.globalCostMissTolerance",
2004                                        optInt,
[997]2005                                        "vsp_bsp_term_global_cost_miss_tolerance=",
[654]2006                                        "4");
2007
[469]2008        RegisterOption("VspBspTree.Termination.minPolygons",
[508]2009                                        optInt,
2010                                        "vsp_bsp_term_min_polygons=",
[1134]2011                                        "-1");
[445]2012
[469]2013        RegisterOption("VspBspTree.Termination.minPvs",
[508]2014                                        optInt,
2015                                        "vsp_bsp_term_min_pvs=",
2016                                        "20");
[660]2017
[547]2018        RegisterOption("VspBspTree.Termination.minProbability",
[508]2019                                        optFloat,
[547]2020                                        "vsp_bsp_term_min_probability=",
[508]2021                                        "0.001");
[445]2022
[660]2023        RegisterOption("VspBspTree.subdivisionStats",
2024                                        optString,
2025                                        "vsp_bsp_subdivision_stats=",
2026                                        "vspBspSubdivisionStats.log");
2027
[469]2028        RegisterOption("VspBspTree.Termination.maxRayContribution",
[508]2029                                        optFloat,
2030                                        "vsp_bsp_term_ray_contribution=",
[1134]2031                                        "2");
[463]2032
[469]2033        RegisterOption("VspBspTree.Termination.minAccRayLenght",
[508]2034                                        optFloat,
2035                                        "vsp_bsp_term_min_acc_ray_length=",
2036                                        "50");
[445]2037
[469]2038        RegisterOption("VspBspTree.Termination.minRays",
[508]2039                                        optInt,
2040                                        "vsp_bsp_term_min_rays=",
2041                                        "-1");
[445]2042
[469]2043        RegisterOption("VspBspTree.Termination.ct_div_ci",
[508]2044                                        optFloat,
2045                                        "vsp_bsp_term_ct_div_ci=",
2046                                        "0.0");
[445]2047
[469]2048        RegisterOption("VspBspTree.Termination.maxDepth",
[508]2049                                        optInt,
2050                                        "vsp_bsp_term_max_depth=",
[1134]2051                                        "50");
[445]2052
[469]2053        RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio",
[482]2054                optFloat,
[666]2055                "vsp_bsp_term_axis_aligned_max_cost_ratio=",
[482]2056                "1.5");
[445]2057
[612]2058        RegisterOption("VspBspTree.useCostHeuristics",
2059                optBool,
[666]2060                "vsp_bsp_use_cost_heuristics=",
[612]2061                "false");
2062
[478]2063        RegisterOption("VspBspTree.Termination.maxViewCells",
[482]2064                optInt,
[666]2065                "vsp_bsp_term_max_view_cells=",
[744]2066                "10000");
[478]2067
[472]2068        RegisterOption("VspBspTree.Termination.maxCostRatio",
2069                optFloat,
[666]2070                "vsp_bsp_term_max_cost_ratio=",
[472]2071                "1.5");
[445]2072
[472]2073        RegisterOption("VspBspTree.Termination.missTolerance",
[997]2074                optInt,
2075                "vsp_bsp_term_miss_tolerance=",
2076                "4");
2077
[469]2078        RegisterOption("VspBspTree.splitPlaneStrategy",
[1134]2079                                        optInt,
[508]2080                                        "vsp_bsp_split_method=",
[1134]2081                                        "1026");
[448]2082
[469]2083        RegisterOption("VspBspTree.maxPolyCandidates",
[508]2084                                        optInt,
2085                                        "vsp_bsp_max_poly_candidates=",
2086                                        "20");
[1134]2087
[469]2088        RegisterOption("VspBspTree.maxRayCandidates",
[508]2089                                        optInt,
2090                                        "vsp_bsp_max_plane_candidates=",
2091                                        "20");
[469]2092
2093        RegisterOption("VspBspTree.maxTests",
[508]2094                                        optInt,
2095                                        "vsp_bsp_max_tests=",
2096                                        "5000");
[469]2097
2098        RegisterOption("VspBspTree.Construction.samples",
[508]2099                                        optInt,
[673]2100                                        "vsp_bsp_construction_samples=",
[508]2101                                        "100000");
[469]2102
[801]2103        RegisterOption("VspBspTree.Construction.minBand",
2104                                        optFloat,
2105                                        "vsp_bsp_construction_min_band=",
[1074]2106                                        "0.01");
[801]2107
2108        RegisterOption("VspBspTree.Construction.maxBand",
2109                                        optFloat,
[1147]2110                                        "vsp_bsp_construction_max_band=",
[1074]2111                                        "0.99");
[801]2112
[822]2113        RegisterOption("VspBspTree.Construction.useDrivingAxisForMaxCost",
2114                                        optBool,
2115                                        "vsp_bsp_construction_use_drivingaxis_for_maxcost=",
2116                                        "false");
2117
[469]2118        RegisterOption("VspBspTree.Construction.epsilon",
[508]2119                                        optFloat,
[1023]2120                                        "vsp_bsp_construction_epsilon=",
[508]2121                                        "0.002");
[469]2122
2123        RegisterOption("VspBspTree.Visualization.exportSplits",
[508]2124                                        optBool,
2125                                        "vsp_bsp_visualization.export_splits",
2126                                        "false");
2127
[485]2128        RegisterOption("VspBspTree.splitUseOnlyDrivingAxis",
[508]2129                                        optBool,
[667]2130                                        "vsp_bsp_split_only_driving_axis=",
[508]2131                                        "false");
2132
[607]2133        RegisterOption("VspBspTree.usePolygonSplitIfAvailable",
2134                                        optBool,
2135                    "vsp_bsp_usePolygonSplitIfAvailable=",
[611]2136                                        "false");
[607]2137
[508]2138        RegisterOption("VspBspTree.Termination.AxisAligned.minRays",
2139                        optInt,
2140                        "bsp_term_axis_aligned_min_rays=",
[1134]2141                        "0");
[492]2142       
[508]2143        RegisterOption("VspBspTree.Termination.AxisAligned.maxRayContribution",
2144                        optFloat,
2145                        "bsp_term_axis_aligned_min_rays=",
[1134]2146                        "2");
[508]2147
[676]2148        RegisterOption("VspBspTree.Factor.leastRaySplits",
2149                                        optFloat,
2150                                        "vsp_bsp_factor_least_ray_splits=",
2151                                        "1.0");
2152
2153        RegisterOption("VspBspTree.Factor.balancedRays",
2154                                        optFloat,
2155                                        "vsp_bsp_factor_balanced_rays=",
2156                                        "1.0");
2157
2158        RegisterOption("VspBspTree.Factor.pvs",
2159                                        optFloat,
2160                                        "vsp_bsp_factor_pvs=",
2161                                        "1.0");
[664]2162       
[580]2163        RegisterOption("VspBspTree.Construction.renderCostWeight",
[478]2164                        optFloat,
[1002]2165                        "vsp_bsp_post_process_render_cost_weight=",
[1134]2166                        "1.0");
[478]2167
[1020]2168        RegisterOption("VspBspTree.Construction.renderCostDecreaseWeight",
2169                        optFloat,
[1121]2170                        "vsp_bsp_construction_render_cost_decrease_weight=",
[1020]2171                        "0.99");
2172
[486]2173        RegisterOption("VspBspTree.Construction.randomize",
2174                optBool,
2175                "vsp_bsp_construction_randomize=",
2176                "false");
[508]2177
[663]2178        RegisterOption("VspBspTree.simulateOctree",
2179                optBool,
2180                "vsp_bsp_simulate_octree=",
2181                "false");
2182
[735]2183        RegisterOption("VspBspTree.nodePriorityQueueType",
2184                optInt,
2185                "vsp_bsp_node_queue_type=",
2186                "0");
[664]2187
2188        RegisterOption("VspBspTree.useRandomAxis",
2189                optBool,
2190                "-vsp_bsp_use_random_axis=",
2191                "false");
2192
[508]2193        RegisterOption("VspBspTree.maxTotalMemory",
2194                optFloat,
2195                "vsp_bsp_max_total_mem=",
2196                "60.0");
2197
2198        RegisterOption("VspBspTree.maxStaticMemory",
2199                optFloat,
2200                "vsp_bsp_max_static_mem=",
2201                "8.0");
[564]2202
[1023]2203
2204
[1027]2205/***************************************************************************/
2206/*                 View space partition tree related options               */
2207/***************************************************************************/
[1023]2208
[580]2209       
[1027]2210        RegisterOption("VspTree.Construction.samples",
2211                                        optInt,
2212                                        "vsp_construction_samples=",
2213                                        "10000");
2214
[1121]2215        RegisterOption("VspTree.Construction.renderCostDecreaseWeight",
[1576]2216                                optFloat,
2217                                "vsp_construction_render_cost_decrease_weight=",
[1665]2218                                "0.99");
[1121]2219
[1023]2220        RegisterOption("VspTree.Termination.maxDepth",
2221                                        optInt,
2222                                        "vsp_term_max_depth=",
2223                                        "100");
2224
2225        RegisterOption("VspTree.Termination.minRays",
2226                                        optInt,
2227                                        "vsp_term_min_rays=",
2228                                        "-1");
2229
2230
2231        RegisterOption("VspTree.Termination.minPvs",
2232                                        optInt,
2233                                        "vsp_term_min_pvs=",
2234                                        "20");
2235
2236        RegisterOption("VspTree.Termination.minProbability",
2237                                        optFloat,
2238                                        "vsp_term_min_probability=",
[1576]2239                                        "0.0000001");
[1023]2240
2241        RegisterOption("VspTree.Termination.maxRayContribution",
[1576]2242                                optFloat,
2243                                "vsp_term_ray_contribution=",
2244                                "0.9");
[1023]2245       
2246        RegisterOption("VspTree.Termination.maxCostRatio",
[1576]2247                                optFloat,
2248                                "vsp_term_max_cost_ratio=",
2249                                "1.5");
[1023]2250       
2251        RegisterOption("VspTree.Termination.maxViewCells",
[1576]2252                                optInt,
2253                                "vsp_term_max_view_cells=",
2254                                "10000");
[564]2255
[1023]2256       
2257        RegisterOption("VspTree.Termination.missTolerance",
[1576]2258                                optInt,
2259                                "vsp_term_miss_tolerance=",
2260                                "4");
[1023]2261
2262        RegisterOption("VspTree.Termination.minGlobalCostRatio",
2263                                        optFloat,
2264                                        "vsp_term_min_global_cost_ratio=",
2265                                        "0.0001");
2266
2267        RegisterOption("VspTree.Termination.globalCostMissTolerance",
2268                                        optInt,
2269                                        "vsp_term_global_cost_miss_tolerance=",
2270                                        "4");
2271
2272        RegisterOption("VspTree.Termination.ct_div_ci",
2273                                        optFloat,
2274                                        "vsp_term_ct_div_ci=",
2275                                        "0.0");
2276
2277        RegisterOption("VspTree.Construction.epsilon",
2278                                        optFloat,
2279                                        "vsp_construction_epsilon=",
2280                                        "0.002");
2281
2282        RegisterOption("VspTree.splitUseOnlyDrivingAxis",
2283                                        optBool,
2284                                        "vsp_split_only_driving_axis=",
2285                                        "false");
2286
2287        RegisterOption("VspTree.maxStaticMemory",
[1576]2288                                        optFloat,
2289                                        "vsp_max_static_mem=",
2290                                        "8.0");
[1023]2291
2292        RegisterOption("VspTree.useCostHeuristics",
[1576]2293                                        optBool,
2294                                        "vsp_use_cost_heuristics=",
2295                                        "false");
[1023]2296
2297        RegisterOption("VspTree.simulateOctree",
[1576]2298                                        optBool,
2299                                        "vsp_simulate_octree=",
2300                                        "false");
[1023]2301
2302        RegisterOption("VspTree.Construction.randomize",
[1576]2303                                        optBool,
2304                                        "vsp_construction_randomize=",
2305                                        "false");
[1023]2306
2307        RegisterOption("VspTree.subdivisionStats",
2308                                        optString,
2309                                        "vsp_subdivision_stats=",
2310                                        "vspSubdivisionStats.log");
2311
2312        RegisterOption("VspTree.Construction.minBand",
2313                                        optFloat,
2314                                        "vsp_construction_min_band=",
[1074]2315                                        "0.01");
[1023]2316
2317        RegisterOption("VspTree.Construction.maxBand",
2318                                        optFloat,
[1074]2319                                        "vsp_construction_max_band=",
2320                                        "0.99");
[1106]2321       
[1149]2322        RegisterOption("VspTree.maxTests",
2323                                        optInt,
2324                                        "vsp_max_tests=",
[1161]2325                                        "5000");
[1143]2326
2327
[1074]2328
[1288]2329/***********************************************************************/
2330/*           Object space partition tree related options               */
2331/***********************************************************************/
[1143]2332
[1294]2333
[1106]2334        RegisterOption("OspTree.Construction.randomize",
[1288]2335                                        optBool,
2336                                        "osp_construction_randomize=",
2337                                        "false");
[1106]2338
2339        RegisterOption("OspTree.Termination.maxDepth",
2340                                        optInt,
2341                                        "osp_term_max_depth=",
2342                                        "30");
2343       
2344        RegisterOption("OspTree.Termination.maxLeaves",
2345                                        optInt,
2346                                        "osp_term_max_leaves=",
2347                                        "1000");
2348       
2349        RegisterOption("OspTree.Termination.minObjects",
2350                                        optInt,
2351                                        "osp_term_min_objects=",
2352                                        "1");
2353
2354        RegisterOption("OspTree.Termination.minProbability",
2355                                        optFloat,
2356                                        "osp_term_min_objects=",
[1288]2357                                        "0.00001");
[1106]2358
2359        RegisterOption("OspTree.Termination.missTolerance",
2360                                        optInt,
2361                                        "osp_term_miss_tolerance=",
[1288]2362                                        "8");
[1106]2363
2364        RegisterOption("OspTree.Termination.maxCostRatio",
2365                                        optFloat,
2366                                        "osp_term_max_cost_ratio=",
2367                                        "0.99");
2368
2369        RegisterOption("OspTree.Termination.minGlobalCostRatio",
2370                                        optFloat,
2371                                        "osp_term_min_global_cost_ratio=",
2372                                        "0.00001");
2373
2374        RegisterOption("OspTree.Termination.globalCostMissTolerance",
2375                                        optInt,
2376                                        "osp_term_global_cost_miss_tolerance=",
2377                                        "4");
2378
2379        RegisterOption("OspTree.Termination.ct_div_ci",
2380                                        optFloat,
2381                                        "osp_term_ct_div_ci=",
2382                                        "0");
2383       
2384        RegisterOption("OspTree.Construction.epsilon",
[1288]2385                                   optFloat,
2386                                   "osp_construction_epsilon=",
2387                                   "0.00001");
[1106]2388       
2389        // if only the driving axis is used for axis aligned split
2390        RegisterOption("OspTree.splitUseOnlyDrivingAxis",
[1288]2391                                   optBool,
2392                                   "osp_split_only_driving_axis=",
2393                                   "false");
[1106]2394
2395        RegisterOption("OspTree.maxStaticMemory",
[1288]2396                                   optFloat,
2397                                   "osp_max_static_mem=",
2398                                   "8.0");
[1106]2399
2400        RegisterOption("OspTree.useCostHeuristics",
[1288]2401                                   optBool,
2402                                   "osp_use_cost_heuristics=",
2403                                   "true");
[1106]2404
2405        RegisterOption("OspTree.subdivisionStats",
2406                                        optString,
2407                                        "osp_subdivision_stats=",
2408                                        "ospSubdivisionStats.log");
2409
2410        RegisterOption("OspTree.Construction.splitBorder",
2411                                        optFloat,
2412                                        "osp_construction_split_border=",
2413                                        "0.01");
2414
[1121]2415        RegisterOption("OspTree.Construction.renderCostDecreaseWeight",
[1288]2416                                   optFloat,
2417                                   "osp_construction_render_cost_decrease_weight=",
2418                                   "0.99");
[1106]2419
2420
[1288]2421
[1297]2422/**********************************************************************/
2423/*            Bounding Volume Hierarchy related options               */
2424/**********************************************************************/
[1288]2425
2426        RegisterOption("BvHierarchy.Construction.randomize",
2427                                        optBool,
2428                                        "bvh_construction_randomize=",
2429                                        "false");
2430
2431        RegisterOption("BvHierarchy.Termination.maxDepth",
2432                                        optInt,
2433                                        "bvh_term_max_depth=",
2434                                        "30");
2435       
2436        RegisterOption("BvHierarchy.Termination.maxLeaves",
2437                                        optInt,
2438                                        "bvh_term_max_leaves=",
2439                                        "1000");
2440       
2441        RegisterOption("BvHierarchy.Termination.minObjects",
2442                                        optInt,
2443                                        "bvh_term_min_objects=",
2444                                        "1");
2445
2446        RegisterOption("BvHierarchy.Termination.minProbability",
2447                                        optFloat,
2448                                        "bvh_term_min_objects=",
[1576]2449                                        "0.0000001");
[1288]2450
[1370]2451        RegisterOption("BvHierarchy.Termination.minRays",
2452                                        optInt,
2453                                        "bvh_term_min_rays=",
2454                                        "0");
2455
[1288]2456        RegisterOption("BvHierarchy.Termination.missTolerance",
2457                                        optInt,
2458                                        "osp_term_miss_tolerance=",
2459                                        "8");
2460
2461        RegisterOption("BvHierarchy.Termination.maxCostRatio",
2462                                        optFloat,
2463                                        "bvh_term_max_cost_ratio=",
2464                                        "0.99");
2465
2466        RegisterOption("BvHierarchy.Termination.minGlobalCostRatio",
2467                                        optFloat,
2468                                        "bvh_term_min_global_cost_ratio=",
2469                                        "0.00001");
2470
2471        RegisterOption("BvHierarchy.Termination.globalCostMissTolerance",
2472                                        optInt,
2473                                        "bvh_term_global_cost_miss_tolerance=",
2474                                        "4");
2475
2476        // if only the driving axis is used for axis aligned split
2477        RegisterOption("BvHierarchy.splitUseOnlyDrivingAxis",
2478                                   optBool,
2479                                   "bvh_split_only_driving_axis=",
2480                                   "false");
2481
2482        RegisterOption("BvHierarchy.maxStaticMemory",
2483                                   optFloat,
2484                                   "bvh_max_static_mem=",
2485                                   "8.0");
2486
2487        RegisterOption("BvHierarchy.useCostHeuristics",
2488                                   optBool,
2489                                   "bvh_use_cost_heuristics=",
2490                                   "true");
[1643]2491       
2492        RegisterOption("BvHierarchy.useSah",
2493                                   optBool,
2494                                   "bvh_use_sah=",
2495                                   "false");
2496
[1288]2497        RegisterOption("BvHierarchy.subdivisionStats",
[1174]2498                                        optString,
[1288]2499                                        "bvh_subdivision_stats=",
2500                                        "bvhSubdivisionStats.log");
[1174]2501
[1288]2502        RegisterOption("BvHierarchy.Construction.renderCostDecreaseWeight",
2503                                   optFloat,
2504                                   "bvh_construction_render_cost_decrease_weight=",
[1665]2505                                   "0.99");
[1359]2506       
2507        RegisterOption("BvHierarchy.Construction.useGlobalSorting",
2508                                        optBool,
2509                                        "bvh_construction_use_global_sorting=",
[1489]2510                                        "true");
[1779]2511       
[1784]2512        RegisterOption("BvHierarchy.Construction.useInitialSubdivision",
[1779]2513                                        optBool,
2514                                        "bvh_construction_use_initial_subdivision=",
2515                                        "false");
[1288]2516
[1786]2517        RegisterOption("BvHierarchy.Construction.Initial.minObjects",
2518                                        optInt,
2519                                        "bvh_construction_use_initial_min_objects=",
2520                                        "100000");
2521
2522        RegisterOption("BvHierarchy.Construction.Initial.minArea",
2523                                        optFloat,
2524                                        "bvh_construction_use_initial_min_area=",
2525                                        "0.0001");
2526
2527        RegisterOption("BvHierarchy.Construction.Initial.maxAreaRatio",
2528                                        optFloat,
2529                                        "bvh_construction_use_initial_max_area_ratio=",
[1825]2530                                        "0.9");
[1786]2531
[1676]2532        RegisterOption("BvHierarchy.minRaysForVisibility",
2533                                        optInt,
2534                                        "bvh_min_rays_for_vis=",
2535                                        "0");
[1640]2536
[1727]2537        RegisterOption("BvHierarchy.maxTests",
2538                                        optInt,
2539                                        "bvh_max_tests=",
2540                                        "50000");
[1676]2541
[1727]2542
[1359]2543        /*******************************************************************/
2544        /*               Hierarchy Manager related options                 */
2545        /*******************************************************************/
[1288]2546
[1640]2547        RegisterOption("Hierarchy.Construction.samples",
2548                                        optInt,
[1642]2549                                        "hierarchy_construction_samples=",
[1640]2550                                        "100000");
2551
[1288]2552        RegisterOption("Hierarchy.subdivisionStats",
2553                           optString,
2554                                   "hierarchy_subdivision_stats=",
2555                                   "hierarchySubdivisionStats.log");
2556
2557        RegisterOption("Hierarchy.type",
2558                           optString,
2559                                   "hierarchy_type=",
2560                                   "bvh");
2561
2562        RegisterOption("Hierarchy.Termination.minGlobalCostRatio",
2563                                        optFloat,
2564                                        "hierarchy_term_min_global_cost_ratio=",
[1444]2565                                        "0.000000001");
[1288]2566
2567        RegisterOption("Hierarchy.Termination.globalCostMissTolerance",
2568                                        optInt,
2569                                        "hierarchy_term_global_cost_miss_tolerance=",
2570                                        "4");
2571
2572        RegisterOption("Hierarchy.Termination.maxLeaves",
2573                                        optInt,
2574                                        "hierarchy_term_max_leaves=",
2575                                        "1000");
2576       
[1293]2577        RegisterOption("Hierarchy.Construction.type",
2578                                        optInt,
2579                                        "hierarchy_construction_type=",
2580                                        "0");
2581
[1311]2582        RegisterOption("Hierarchy.Construction.minDepthForOsp",
2583                                        optInt,
2584                                        "hierarchy_construction_min_depth_for_osp=",
2585                                        "-1");
2586
[1370]2587        RegisterOption("Hierarchy.Construction.startWithObjectSpace",
2588                                        optBool,
2589                                        "hierarchy_construction_start_with_osp=",
2590                                        "true");
2591
[1662]2592        RegisterOption("Hierarchy.Construction.considerMemory",
2593                                        optBool,
2594                                        "hierarchy_construction_consider_memory=",
[1744]2595                                        "true");
[1662]2596
[1314]2597        RegisterOption("Hierarchy.Construction.repairQueue",
2598                                        optBool,
2599                                        "hierarchy_construction_repair_queue=",
2600                                        "true");
[1311]2601
[1370]2602        RegisterOption("Hierarchy.Construction.minDepthForVsp",
2603                                        optInt,
2604                                        "hierarchy_construction_min_depth_for_vsp=",
2605                                        "-1");
[1359]2606
[1649]2607        RegisterOption("Hierarchy.Termination.maxMemory",
2608                                        optFloat,
[1653]2609                                        "hierarchy_term_max_memory=",
[1649]2610                                        "1");
2611
[1666]2612        RegisterOption("Hierarchy.Termination.memoryConst",
2613                                        optFloat,
2614                                        "hierarchy_term_memory_const=",
2615                                        "1.0");
2616
[1545]2617        RegisterOption("Hierarchy.Construction.useMultiLevel",
[1449]2618                                        optBool,
[1545]2619                                        "hierarchy_construction_multilevel=",
[1449]2620                                        "false");
2621
[1576]2622        RegisterOption("Hierarchy.Construction.levels",
2623                                        optInt,
2624                                        "hierarchy_construction_levels=",
2625                                        "4");
[1727]2626
2627        RegisterOption("Hierarchy.Construction.maxRepairs",
2628                                        optInt,
[1843]2629                                        "hierarchy_construction_max_repairs=",
[1727]2630                                        "1000");
2631
[1640]2632        RegisterOption("Hierarchy.Construction.minStepsOfSameType",
2633                                        optInt,
2634                                        "hierarchy_construction_min_steps_same_type=",
2635                                        "200");
[1576]2636
[1684]2637        RegisterOption("Hierarchy.Construction.maxStepsOfSameType",
2638                                        optInt,
2639                                        "hierarchy_construction_max_steps_same_type=",
2640                                        "700");
2641
[1633]2642        RegisterOption("Hierarchy.Construction.recomputeSplitPlaneOnRepair",
2643                                        optBool,
2644                                        "hierarchy_construction_recompute_split_on_repair=",
2645                                        "true");
2646
[1458]2647        /////////////////////////////////////////////////////////////////
[372]2648}
2649
2650void
2651Environment::SetStaticOptions()
2652{
2653 
2654  // get Global option values
2655  GetRealValue("Limits.threshold", Limits::Threshold);
2656  GetRealValue("Limits.small", Limits::Small);
2657  GetRealValue("Limits.infinity", Limits::Infinity);
2658
2659
2660}
2661
[938]2662bool
[492]2663Environment::Parse(const int argc, char **argv, bool useExePath)
[372]2664{
[938]2665  bool result = true;
[372]2666  // Read the names of the scene, environment and output files
2667  ReadCmdlineParams(argc, argv, "");
2668
2669  char *envFilename = new char[128];
2670
2671  char filename[64];
2672
2673  // Get the environment file name
2674  if (!GetParam(' ', 0, filename)) {
2675    // user didn't specified environment file explicitly, so
[1199]2676    strcpy(filename, "default.env");
[372]2677  }
[1757]2678
[372]2679 
2680  if (useExePath) {
2681    char *path = GetPath(argv[0]);
2682    if (*path != 0)
2683      sprintf(envFilename, "%s/%s", path, filename);
2684    else
2685      strcpy(envFilename, filename);
2686   
2687    delete path;
2688  }
2689  else
2690    strcpy(envFilename, filename);
2691
2692 
2693  // Now it's time to read in environment file.
2694  if (!ReadEnvFile(envFilename)) {
2695    // error - bad input file name specified ?
2696    cerr<<"Error parsing environment file "<<envFilename<<endl;
[938]2697        result = false;
[372]2698  }
2699  delete envFilename;
2700
2701  // Parse the command line; options given on the command line subsume
2702  // stuff specified in the input environment file.
2703  ParseCmdline(argc, argv, 0);
2704
2705  SetStaticOptions();
2706
2707  // Check for request for help
2708  if (CheckForSwitch(argc, argv, '?')) {
2709    PrintUsage(cout);
2710    exit(0);
2711  }
[938]2712 
2713  return true;
[372]2714}
[860]2715
[878]2716}
Note: See TracBrowser for help on using the repository browser.