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

Revision 1942, 70.0 KB checked in by bittner, 18 years ago (diff)

tmp commit

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
[1934]1279        RegisterOption("GvsPreprocessor.stats",
1280                                        optString,
1281                                        "gvs_stats=",
1282                                        "gvsStats.log");
[1500]1283
[1486]1284  /***********************************************************************************/
1285  /*                         View cells related options                              */
1286  /***********************************************************************************/
1287
1288
[508]1289        RegisterOption("ViewCells.type",
1290                        optString,
[664]1291                        "view_cells_type=",
[662]1292                        "vspBspTree");
[372]1293
[662]1294        RegisterOption("ViewCells.samplingType",
1295                        optString,
[664]1296                        "view_cells_sampling_type=",
[662]1297                        "box");
1298
[666]1299        RegisterOption("ViewCells.mergeStats",
[660]1300                                        optString,
[666]1301                                        "view_cells_merge_stats=",
1302                                        "mergeStats.log");
[660]1303
[664]1304        RegisterOption("ViewCells.Evaluation.statsPrefix",
[660]1305                                        optString,
[664]1306                                        "view_cells_evaluation_stats_prefix=",
[660]1307                                        "viewCells");
[1418]1308
[735]1309        RegisterOption("ViewCells.Evaluation.histogram",
1310                                        optBool,
1311                                        "view_cells_evaluation_histogram=",
1312                                        "false");
1313
[997]1314        RegisterOption("ViewCells.Evaluation.histoStepSize",
[735]1315                                        optInt,
[997]1316                                        "view_cells_evaluation_histo_step_size=",
[744]1317                                        "5000");
[735]1318
[1919]1319        RegisterOption("ViewCells.Evaluation.histoMem",
1320                                        optInt,
1321                                        "view_cells_evaluation_histo_mem=",
1322                                        "50");
1323
[728]1324        RegisterOption("ViewCells.renderCostEvaluationType",
1325                                        optString,
1326                                        "view_cells_render_cost_evaluation=",
1327                                        "perobject");
1328
[660]1329        RegisterOption("ViewCells.active",
1330                                        optInt,
[664]1331                                        "view_cells_active=",
[660]1332                                        "1000");
[581]1333
[574]1334        RegisterOption("ViewCells.Construction.samples",
1335                                        optInt,
1336                                        "view_cells_construction_samples=",
[1134]1337                                        "0");
[574]1338
1339        RegisterOption("ViewCells.Construction.samplesPerPass",
1340                                        optInt,
1341                                        "view_cells_construction_samples_per_pass=",
1342                                        "500000");
1343
[508]1344        RegisterOption("ViewCells.PostProcess.samples",
1345                                        optInt,
[712]1346                                        "view_cells_post_process_samples=",
[1134]1347                                        "0");
[421]1348
[508]1349        RegisterOption("ViewCells.Visualization.samples",
1350                                        optInt,
1351                                        "view_cells_visualization_samples=",
[1134]1352                                        "0");
[372]1353
[1020]1354        RegisterOption("ViewCells.Visualization.maxOutput",
1355                                        optInt,
1356                                        "view_cells_visualization_max_output=",
1357                                        "20");
1358
[697]1359        RegisterOption("ViewCells.Filter.maxSize",
1360                                        optInt,
1361                                        "view_cells_filter_max_size=",
1362                                        "4");
1363
1364        RegisterOption("ViewCells.Filter.width",
1365                                        optFloat,
1366                                        "view_cells_filter_width=",
[746]1367                                        "200.0");
[697]1368
[508]1369        RegisterOption("ViewCells.loadFromFile",
1370                                        optBool,
[664]1371                                        "view_cells_load_from_file=",
[508]1372                                        "false");
[485]1373
[586]1374        RegisterOption("ViewCells.PostProcess.refine",
1375                                        optBool,
[664]1376                                        "view_cells_refine=",
[586]1377                                        "false");
1378
1379        RegisterOption("ViewCells.PostProcess.compress",
1380                                        optBool,
[664]1381                                        "view_cells_post_process_compress=",
[586]1382                                        "false");
1383
[662]1384        RegisterOption("ViewCells.Evaluation.samples",
1385                                        optInt,
1386                                        "view_cells_evaluation_samples=",
1387                                        "8000000");
1388
[722]1389        RegisterOption("ViewCells.Evaluation.samplingType",
[837]1390                                        optString,
1391                                        "view_cells_evaluation_sampling_type=",
1392                                        "box");
[722]1393
[662]1394        RegisterOption("ViewCells.Evaluation.samplesPerPass",
1395                                        optInt,
1396                                        "view_cells_evaluation_samples_per_pass=",
1397                                        "300000");
1398
[1695]1399        RegisterOption("ViewCells.Evaluation.samplesForStats",
1400                                        optInt,
1401                                        "view_cells_evaluation_samples_for_stats=",
1402                                        "300000");
1403
[508]1404        RegisterOption("ViewCells.exportToFile",
1405                                        optBool,
[676]1406                                        "view_cells_export_to_file=",
[508]1407                                        "false");
1408
[844]1409        RegisterOption("ViewCells.exportPvs",
1410                                        optBool,
1411                                        "view_cells_export_pvs=",
1412                                        "false");
1413
[840]1414        RegisterOption("ViewCells.exportBboxesForPvs",
1415                                        optBool,
[844]1416                                        "view_cells_export_bounding_boxes=",
[840]1417                                        "true");
1418       
1419        RegisterOption("ViewCells.boxesFilename",
1420                                        optString,
1421                                        "view_cells_boxes_filename=",
1422                                        "boxes.out");
1423
[664]1424        RegisterOption("ViewCells.evaluateViewCells",
1425                                        optBool,
[670]1426                                        "view_cells_evaluate=",
[664]1427                                        "false");
1428
[508]1429        RegisterOption("ViewCells.maxViewCells",
[667]1430                                        optInt,
1431                                        "view_cells_max_view_cells=",
1432                                        "0");
[508]1433
[1713]1434        RegisterOption("ViewCells.Evaluation.stepSize",
1435                                        optInt,
1436                                        "view_cells_evaluation_step_size=",
1437                                        "100");
1438
[511]1439        RegisterOption("ViewCells.maxPvsRatio",
1440                                        optFloat,
1441                                        "view_cells_max_pvs_ratio=",
1442                                        "0.1");
[508]1443
1444        RegisterOption("ViewCells.filename",
[667]1445                                        optString,
1446                                        "view_cells_filename=",
1447                                        "atlanta_viewcells_large.x3d");
[508]1448
1449        RegisterOption("ViewCells.height",
[667]1450                                        optFloat,
1451                                        "view_cells_height=",
1452                                        "5.0");
[508]1453
1454        RegisterOption("ViewCells.Visualization.colorCode",
[667]1455                                        optString,
[708]1456                                        "view_cells_visualization_color_code=",
[667]1457                                        "PVS");
[482]1458
[667]1459        RegisterOption("ViewCells.Visualization.clipPlanePos",
1460                                        optFloat,
[708]1461                                        "view_cells_visualization_clip_plane_pos=",
[667]1462                                        "0.35");
[579]1463       
[508]1464        RegisterOption("ViewCells.Visualization.exportGeometry",
[667]1465                                        optBool,
[708]1466                                        "view_cells_visualization_export_geometry=",
[667]1467                                        "false");
[445]1468
[667]1469        RegisterOption("ViewCells.Visualization.exportRays",
1470                                        optBool,
[708]1471                                        "view_cells_visualization_export_rays=",
[667]1472                                        "false");
1473
[564]1474        RegisterOption("ViewCells.processOnlyValidViewCells",
[667]1475                                        optBool,
[1761]1476                                        "view_cells_process_only_valid_view_cells",
[667]1477                                        "false");
[660]1478
[580]1479        RegisterOption("ViewCells.PostProcess.maxCostRatio",
1480                        optFloat,
[667]1481                        "view_cells_post_process_max_cost_ratio=",
[580]1482                        "0.9");
1483       
1484        RegisterOption("ViewCells.PostProcess.renderCostWeight",
1485                        optFloat,
[667]1486                        "view_cells_post_process_render_cost_weight",
[580]1487                        "0.5");
1488       
1489        RegisterOption("ViewCells.PostProcess.avgCostMaxDeviation",
1490                        optFloat,
[1143]1491                        "view_cells_avgcost_max_deviations",
[580]1492                        "0.5");
1493
1494        RegisterOption("ViewCells.PostProcess.maxMergesPerPass",
1495                optInt,
[667]1496                "view_cells_post_process_max_merges_per_pass=",
[580]1497                "500");
1498
1499        RegisterOption("ViewCells.PostProcess.minViewCells",
1500                optInt,
[667]1501                "view_cells_post_process_min_view_cells=",
[580]1502                "1000");
1503
1504        RegisterOption("ViewCells.PostProcess.useRaysForMerge",
1505                optBool,
1506                "view_cells_post_process_use_rays_for_merge=",
1507                "false");
[591]1508       
1509        RegisterOption("ViewCells.PostProcess.merge",
1510                optBool,
[666]1511                "view_cells_post_process_merge=",
[591]1512                "true");
[580]1513
1514        RegisterOption("ViewCells.Visualization.exportMergedViewCells",
1515                optBool,
1516                "view_cells_viz_export_merged_viewcells=",
1517                "false");
1518
[582]1519        RegisterOption("ViewCells.maxStaticMemory",
1520                optFloat,
1521                "view_cells_max_static_mem=",
1522                "8.0");
[580]1523
[660]1524        RegisterOption("ViewCells.Visualization.useClipPlane",
[591]1525                optBool,
[660]1526                "view_cells_viz_use_clip_plane=",
[591]1527                "false");
1528       
[666]1529        RegisterOption("ViewCells.showVisualization",
1530                optBool,
1531                "view_cells_show_visualization=",
1532                "false");
1533
[660]1534        RegisterOption("ViewCells.Visualization.clipPlaneAxis",
[591]1535                optInt,
[660]1536                "view_cells_viz_clip_plane_axis=",
[591]1537                "0");
1538
[1545]1539        RegisterOption("ViewCells.loadGeometry",
1540                optBool,
1541                "view_cells_load_geometry=",
1542                "false");
[1159]1543       
[1545]1544        RegisterOption("ViewCells.geometryFilename",
1545                optString,
1546                "view_cells_geometry_filename=",
1547                "viewCellsGeometry.x3d");
1548
1549        RegisterOption("ViewCells.useBaseTrianglesAsGeometry",
1550                optBool,
1551                "view_cells_use_base_triangles_as_geometry=",
1552                "false");
1553
[1887]1554        RegisterOption("ViewCells.compressObjects",
1555                optBool,
1556                "view_cells_compress_objects=",
1557                "false");
[1545]1558
[1902]1559        RegisterOption("ViewCells.useKdPvs",
1560                optBool,
1561                "view_cells_use_kd_pvs=",
1562                "false");
[1887]1563
[1902]1564
1565
[1418]1566        /****************************************************************************/
1567        /*                     Render simulation related options                    */
1568        /****************************************************************************/
[372]1569
[406]1570
[508]1571        RegisterOption("Simulation.objRenderCost",
1572                        optFloat,
1573                        "simulation_obj_render_cost",
1574                        "1.0");
[409]1575
[508]1576        RegisterOption("Simulation.vcOverhead",
1577                        optFloat,
1578                        "simulation_vc_overhead",
1579                        "0.05");
[445]1580
[508]1581        RegisterOption("Simulation.moveSpeed",
1582                        optFloat,
1583                        "simulation_moveSpeed",
1584                        "1.0");
[445]1585
1586
1587
[1486]1588        /******************************************************************/
1589        /*                    Bsp tree related options                    */
1590        /******************************************************************/
[445]1591
[372]1592
[508]1593        RegisterOption("BspTree.Construction.input",
1594                optString,
1595                "bsp_construction_input=",
1596                "fromViewCells");
[1867]1597       
[660]1598        RegisterOption("BspTree.subdivisionStats",
1599                                        optString,
[666]1600                                        "bsp_subdivision_stats=",
[660]1601                                        "bspSubdivisionStats.log");
1602
[508]1603        RegisterOption("BspTree.Construction.samples",
1604                optInt,
1605                "bsp_construction_samples=",
1606                "100000");
[390]1607
[508]1608        RegisterOption("BspTree.Construction.epsilon",
1609                optFloat,
[1023]1610                "bsp_construction_epsilon=",
[508]1611                "0.002");
[397]1612
[508]1613        RegisterOption("BspTree.Termination.minPolygons",
1614                        optInt,
1615                        "bsp_term_min_polygons=",
1616                        "5");
[409]1617
[508]1618        RegisterOption("BspTree.Termination.minPvs",
1619                        optInt,
1620                        "bsp_term_min_pvs=",
1621                        "20");
[372]1622
[587]1623        RegisterOption("BspTree.Termination.minProbability",
[508]1624                        optFloat,
[587]1625                        "bsp_term_min_probability=",
[508]1626                        "0.001");
[424]1627
[508]1628        RegisterOption("BspTree.Termination.maxRayContribution",
1629                        optFloat,
1630                        "bsp_term_ray_contribution=",
1631                        "0.005");
[372]1632
[508]1633        RegisterOption("BspTree.Termination.minAccRayLenght",
1634                        optFloat,
1635                        "bsp_term_min_acc_ray_length=",
1636                        "50");
[372]1637
[508]1638        RegisterOption("BspTree.Termination.minRays",
1639                        optInt,
1640                        "bsp_term_min_rays=",
1641                        "-1");
[372]1642
[508]1643        RegisterOption("BspTree.Termination.ct_div_ci",
1644                        optFloat,
1645                        "bsp_term_ct_div_ci=",
1646                        "0.0");
[372]1647
[508]1648        RegisterOption("BspTree.Termination.maxDepth",
1649                        optInt,
1650                        "bsp_term_max_depth=",
1651                        "100");
[372]1652
[508]1653        RegisterOption("BspTree.Termination.maxCostRatio",
1654                        optFloat,
1655                        "bsp_term_axis_aligned_max_cost_ratio=",
1656                        "1.5");
[372]1657
[508]1658        RegisterOption("BspTree.Termination.AxisAligned.ct_div_ci",
1659                        optFloat,
1660                        "bsp_term_axis_aligned_ct_div_ci=",
1661                        "0.5");
[372]1662
[508]1663        RegisterOption("BspTree.AxisAligned.splitBorder",
1664                        optFloat,
1665                        "bsp__axis_aligned_split_border=",
1666                        "0.1");
[372]1667
[508]1668        RegisterOption("BspTree.Termination.AxisAligned.minPolys",
1669                        optInt,
1670                        "bsp_term_axis_aligned_max_polygons=",
1671                        "50");
[379]1672
[508]1673        RegisterOption("BspTree.Termination.AxisAligned.minObjects",
1674                        optInt,
1675                        "bsp_term_min_objects=",
1676                        "3");
[441]1677
[508]1678        RegisterOption("BspTree.Termination.AxisAligned.minRays",
1679                        optInt,
1680                        "bsp_term_axis_aligned_min_rays=",
1681                        "-1");
[374]1682
[508]1683        RegisterOption("BspTree.splitPlaneStrategy",
1684                        optString,
1685                        "bsp_split_method=",
1686                        "leastSplits");
[424]1687
[508]1688        RegisterOption("BspTree.maxPolyCandidates",
1689                optInt,
1690                "bsp_max_poly_candidates=",
1691                "20");
[469]1692
[508]1693        RegisterOption("BspTree.maxRayCandidates",
1694                optInt,
1695                "bsp_max_plane_candidates=",
1696                "20");
[382]1697
[508]1698        RegisterOption("BspTree.maxTests",
1699                optInt,
1700                "bsp_max_tests=",
1701                "5000");
[382]1702
[587]1703        RegisterOption("BspTree.Termination.maxViewCells",
1704                optInt,
1705                "bsp_max_view_cells=",
1706                "5000");
1707
[508]1708        RegisterOption("BspTree.Visualization.exportSplits",
1709                optBool,
[1545]1710                "bsp_visualization.export_splits=",
[508]1711                "false");
[445]1712
[508]1713        RegisterOption("BspTree.Factor.verticalSplits", optFloat, "bsp_factor_vertical=", "1.0");
1714        RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "bsp_factor_largest_poly=", "1.0");
1715        RegisterOption("BspTree.Factor.blockedRays", optFloat, "bsp_factor_blocked=", "1.0");
1716        RegisterOption("BspTree.Factor.leastSplits", optFloat, "bsp_factor_least_splits=", "1.0");
1717        RegisterOption("BspTree.Factor.balancedPolys", optFloat, "bsp_factor_balanced_polys=", "1.0");
1718        RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "bsp_factor_balanced_view_cells=", "1.0");
1719        RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "bsp_factor_least_ray_splits=", "1.0");
1720        RegisterOption("BspTree.Factor.balancedRays", optFloat, "bsp_factor_balanced_rays=", "1.0");
1721        RegisterOption("BspTree.Factor.pvs", optFloat, "bsp_factor_pvs=", "1.0");
[408]1722
[508]1723        /************************************************************************************/
1724        /*                         Preprocessor related options                             */
1725        /************************************************************************************/
[408]1726
[508]1727        RegisterOption("Preprocessor.type",
1728                                        optString,
1729                                        "preprocessor=",
1730                                        "sampling");
[408]1731
[1771]1732        RegisterOption("Preprocessor.stats",
1733                                        optString,
1734                                        "preprocessor_stats=",
1735                                        "stats.log");
1736
[508]1737        RegisterOption("Preprocessor.samplesFilename",
1738                                        optString,
[676]1739                                        "preprocessor_samples_filename=",
[508]1740                                        "rays.out");
[408]1741
[1379]1742        RegisterOption("Preprocessor.loadMeshes",
[658]1743                                        optBool,
[1942]1744                                        "preprocessor_load_meshes",
[1379]1745                                        "true");
[658]1746
[1785]1747        RegisterOption("Preprocessor.evaluateFilter",
1748                                   optBool,
[1942]1749                                   "preprocessor_evaluate_filter",
[1785]1750                                   "false");
1751
[1613]1752        RegisterOption("Preprocessor.delayVisibilityComputation",
1753                                   optBool,
[1942]1754                                   "preprocessor_delay_computation",
[1613]1755                                   "true");
1756
[563]1757        RegisterOption("Preprocessor.pvsRenderErrorSamples",
1758                                   optInt,
[1444]1759                                   "preprocessor_pvs_rendererror_samples=",
[563]1760                                   "10000");
[682]1761       
1762        RegisterOption("Preprocessor.useGlRenderer",
1763                                        optBool,
[1942]1764                                        "preprocessor_use_gl_renderer",
[682]1765                                        "false");
1766
[538]1767        RegisterOption("Preprocessor.useGlDebugger",
1768                                        optBool,
[1942]1769                                        "preprocessor_use_gl_debugger",
[538]1770                                        "false");
1771
[534]1772        RegisterOption("Preprocessor.detectEmptyViewSpace",
1773                                   optBool,
[1942]1774                                   "preprocessor_detect_empty_viewspace",
[534]1775                                   "false");
1776       
[599]1777        RegisterOption("Preprocessor.quitOnFinish",
1778                                   optBool,
[1942]1779                                   "preprocessor_quit_on_finish",
[599]1780                                   "true");
[534]1781
[685]1782        RegisterOption("Preprocessor.computeVisibility",
1783                                   optBool,
[1942]1784                                   "preprocessor_compute_visibility",
[685]1785                                   "true");
[682]1786
[871]1787        RegisterOption("Preprocessor.exportVisibility",
1788                                   optBool,
[1942]1789                                   "preprocessor_export_visibility",
[871]1790                                   "true");
[682]1791
[871]1792        RegisterOption("Preprocessor.visibilityFile",
1793                                   optString,
1794                                   "preprocessor_visibility_file=",
1795                                   "visibility.xml");
1796
1797        RegisterOption("Preprocessor.applyVisibilityFilter",
1798                                   optBool,
[1942]1799                                   "preprocessor_apply_filter",
[1756]1800                                   "false");
[904]1801       
1802        RegisterOption("Preprocessor.applyVisibilitySpatialFilter",
1803                                   optBool,
[1942]1804                                   "preprocessor_apply_spatial_filter",
[1756]1805                                   "false");
[871]1806
[878]1807        RegisterOption("Preprocessor.visibilityFilterWidth",
1808                                   optFloat,
1809                                   "preprocessor_visibility_filter_width=",
1810                                   "0.02");
[871]1811
[991]1812        RegisterOption("Preprocessor.histogram.maxValue",
1813                                        optInt,
1814                                        "preprocessor_histogram_max_value=",
1815                                        "1000");
[871]1816
[1221]1817        RegisterOption("Preprocessor.rayCastMethod",
1818                                        optInt,
1819                                        "preprocessor_ray_cast_method=",
1820                                        "0");
1821
[991]1822        RegisterOption("Preprocessor.histogram.intervals",
1823                                        optInt,
1824                                        "preprocessor_histogram_intervals=",
1825                                        "20");
[878]1826
[1771]1827        RegisterOption("Preprocessor.histogram.file",
1828                                   optString,
1829                                   "preprocessor_histogram_file=",
1830                                   "histogram.log");
1831
[1414]1832        RegisterOption("Preprocessor.exportKdTree",
1833                                        optBool,
1834                                        "preprocessor_export_kd_tree=",
1835                                        "false");
[991]1836
[1414]1837        RegisterOption("Preprocessor.loadKdTree",
1838                                        optBool,
1839                                        "preprocessor_load_kd_tree=",
1840                                        "false");
1841
[1415]1842        RegisterOption("Preprocessor.kdTreeFilename",
1843                                        optString,
1844                                        "preprocessor_kd_tree_filename=",
1845                                        "vienna_kdtree.bin.gz");
[1414]1846
[1695]1847        RegisterOption("Preprocessor.exportObj",
1848                                        optBool,
1849                                        "preprocessor_export_obj=",
1850                                        "false");
1851
[1723]1852   RegisterOption("Preprocessor.useViewSpaceBox",
[1923]1853                                        optBool,
1854                                        "preprocessor_use_viewspace_box=",
1855                                        "false");   
[1900]1856
1857   RegisterOption("Preprocessor.Export.rays", optBool, "export_rays=", "false");
1858        RegisterOption("Preprocessor.Export.numRays", optInt, "export_num_rays=", "5000");
[1723]1859   
[1415]1860        /*************************************************************************/
1861        /*             VSS Preprocessor cells related options                    */
1862        /*************************************************************************/
[1414]1863
[469]1864        RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12");
1865        RegisterOption("VssTree.minPvs", optInt, "kd_minpvs=", "1");
1866        RegisterOption("VssTree.minRays", optInt, "kd_minrays=", "10");
1867        RegisterOption("VssTree.maxCostRatio", optFloat, "maxcost=", "0.95");
1868        RegisterOption("VssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5");
[382]1869
[469]1870        RegisterOption("VssTree.epsilon", optFloat, "kd_eps=", "1e-6");
1871        RegisterOption("VssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0");
1872        RegisterOption("VssTree.randomize", optBool, "randomize", "false");
1873        RegisterOption("VssTree.splitType", optString, "split=", "queries");
1874        RegisterOption("VssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false");
1875        RegisterOption("VssTree.useRss", optBool, "rss=", "false");
1876        RegisterOption("VssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000");
[382]1877
[469]1878        RegisterOption("VssTree.minSize", optFloat, "minsize=", "0.001");
[382]1879
[469]1880        RegisterOption("VssTree.maxTotalMemory", optFloat, "mem=", "60.0");
1881        RegisterOption("VssTree.maxStaticMemory", optFloat, "statmem=", "8.0");
[438]1882
[469]1883        RegisterOption("VssTree.queryType", optString, "qtype=", "static");
[438]1884
[532]1885       
1886       
[469]1887        RegisterOption("VssTree.queryPosWeight", optFloat, "qposweight=", "0.0");
[997]1888        RegisterOption("VssTree.useRefDirSplits", optBool, "refdir=", "false");
[469]1889        RegisterOption("VssTree.refDirAngle", optFloat, "refangle=", "10");
1890        RegisterOption("VssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1");
1891        RegisterOption("VssTree.accessTimeThreshold", optInt, "accesstime=", "1000");
1892        RegisterOption("VssTree.minCollapseDepth", optInt, "colldepth=", "4");
[446]1893
[469]1894        RegisterOption("VssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true");
1895        RegisterOption("VssTree.dirSplitDepth", optInt, "dirsplidepth=", "10");
1896
1897
1898        RegisterOption("RssPreprocessor.initialSamples",
1899                                                                        optInt,
[1486]1900                                                                        "rss_initial_samples=",
[469]1901                                                                        "100000");
1902
[463]1903        RegisterOption("RssPreprocessor.vssSamples",
[508]1904                                        optInt,
1905                                        "rss_vss_samples=",
1906                                        "1000000");
1907
[469]1908        RegisterOption("RssPreprocessor.vssSamplesPerPass",
[508]1909                                        optInt,
1910                                        "rss_vss_samples_per_pass=",
1911                                        "1000");
1912
[492]1913        RegisterOption("RssPreprocessor.samplesPerPass",
[508]1914                                        optInt,
1915                                        "rss_samples_per_pass=",
1916                                        "100000");
1917
[469]1918        RegisterOption("RssPreprocessor.useImportanceSampling",
[508]1919                                        optBool,
[1112]1920                                        "rss_use_importance",
[508]1921                                        "true");
1922
[1785]1923        RegisterOption("RssPreprocessor.useRssTree",
1924                                        optBool,
1925                                        "rss_use_rss_tree",
1926                                        "true");
1927
[492]1928        RegisterOption("RssPreprocessor.objectBasedSampling",
[508]1929                                        optBool,
[1112]1930                                        "rss_object_based_sampling",
[508]1931                                        "true");
1932
[492]1933        RegisterOption("RssPreprocessor.directionalSampling",
[508]1934                                        optBool,
[1112]1935                                        "rss_directional_sampling",
[508]1936                                        "false");
1937
[1877]1938        RegisterOption("RssPreprocessor.distributions",
1939                                   optString,
1940                                   "rss_distributions=",
1941                                   "rss+spatial+object");
1942       
[1199]1943        RegisterOption("RssTree.hybridDepth", optInt, "hybrid_depth=", "10");
[469]1944        RegisterOption("RssTree.maxDepth", optInt, "kd_depth=", "12");
1945        RegisterOption("RssTree.minPvs", optInt, "kd_minpvs=", "1");
1946        RegisterOption("RssTree.minRays", optInt, "kd_minrays=", "10");
1947        RegisterOption("RssTree.maxCostRatio", optFloat, "maxcost=", "0.95");
1948        RegisterOption("RssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5");
[508]1949
[469]1950        RegisterOption("RssTree.epsilon", optFloat, "kd_eps=", "1e-6");
1951        RegisterOption("RssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0");
[997]1952        RegisterOption("RssTree.randomize", optBool, "randomize=", "false");
[1199]1953        RegisterOption("RssTree.splitType", optString, "rss_split=", "queries");
[469]1954        RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false");
[508]1955
[469]1956        RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000");
[508]1957
[469]1958        RegisterOption("RssTree.minSize", optFloat, "minsize=", "0.001");
[508]1959
[469]1960        RegisterOption("RssTree.maxTotalMemory", optFloat, "mem=", "60.0");
1961        RegisterOption("RssTree.maxStaticMemory", optFloat, "statmem=", "8.0");
[508]1962
[469]1963        RegisterOption("RssTree.queryType", optString, "qtype=", "static");
[508]1964
[469]1965        RegisterOption("RssTree.queryPosWeight", optFloat, "qposweight=", "0.0");
1966        RegisterOption("RssTree.useRefDirSplits", optBool, "refdir", "false");
1967        RegisterOption("RssTree.refDirAngle", optFloat, "refangle=", "10");
1968        RegisterOption("RssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1");
1969        RegisterOption("RssTree.accessTimeThreshold", optInt, "accesstime=", "1000");
1970        RegisterOption("RssTree.minCollapseDepth", optInt, "colldepth=", "4");
[508]1971
[997]1972        RegisterOption("RssTree.interleaveDirSplits", optBool, "interleavedirsplits=", "true");
[469]1973        RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10");
[997]1974        RegisterOption("RssTree.importanceBasedCost", optBool, "importance_based_cost=", "true");
[492]1975        RegisterOption("RssTree.maxRays", optInt, "rss_max_rays=", "2000000");
[508]1976
[516]1977        RegisterOption("RssTree.perObjectTree", optBool, "rss_per_object_tree", "false");
1978
[997]1979        RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs=", "false");
1980        RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree=", "false");
[1900]1981
[997]1982        RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells=", "false");
[563]1983        RegisterOption("RssPreprocessor.updateSubdivision",
1984                                   optBool,
[997]1985                                   "rss_update_subdivision=",
[563]1986                                   "false");
[463]1987
[492]1988
[508]1989/************************************************************************************/
[1023]1990/*                      Rss preprocessor related options                            */
[508]1991/************************************************************************************/
1992
1993
[490]1994        RegisterOption("RssPreprocessor.loadInitialSamples",
[508]1995                                        optBool,
1996                                        "vss_load_loadInitialSamples=",
1997                                        "false");
[445]1998
[490]1999        RegisterOption("RssPreprocessor.storeInitialSamples",
[508]2000                                        optBool,
2001                                        "vss_store_storeInitialSamples=",
2002                                        "false");
[490]2003
[508]2004
2005/************************************************************************************/
[1023]2006/*                 View space partition BSP tree related options                    */
[508]2007/************************************************************************************/
2008
[654]2009        RegisterOption("VspBspTree.Termination.minGlobalCostRatio",
2010                                        optFloat,
[997]2011                                        "vsp_bsp_term_min_global_cost_ratio=",
[654]2012                                        "0.0001");
[508]2013
[655]2014        RegisterOption("VspBspTree.useSplitCostQueue",
[1902]2015                                        optBool,
2016                                        "vsp_bsp_use_split_cost_queue=",
2017                                        "true");
[655]2018
[654]2019        RegisterOption("VspBspTree.Termination.globalCostMissTolerance",
2020                                        optInt,
[997]2021                                        "vsp_bsp_term_global_cost_miss_tolerance=",
[654]2022                                        "4");
2023
[469]2024        RegisterOption("VspBspTree.Termination.minPolygons",
[508]2025                                        optInt,
2026                                        "vsp_bsp_term_min_polygons=",
[1134]2027                                        "-1");
[445]2028
[469]2029        RegisterOption("VspBspTree.Termination.minPvs",
[508]2030                                        optInt,
2031                                        "vsp_bsp_term_min_pvs=",
2032                                        "20");
[660]2033
[547]2034        RegisterOption("VspBspTree.Termination.minProbability",
[508]2035                                        optFloat,
[547]2036                                        "vsp_bsp_term_min_probability=",
[508]2037                                        "0.001");
[445]2038
[660]2039        RegisterOption("VspBspTree.subdivisionStats",
2040                                        optString,
2041                                        "vsp_bsp_subdivision_stats=",
2042                                        "vspBspSubdivisionStats.log");
2043
[469]2044        RegisterOption("VspBspTree.Termination.maxRayContribution",
[508]2045                                        optFloat,
2046                                        "vsp_bsp_term_ray_contribution=",
[1134]2047                                        "2");
[463]2048
[469]2049        RegisterOption("VspBspTree.Termination.minAccRayLenght",
[508]2050                                        optFloat,
2051                                        "vsp_bsp_term_min_acc_ray_length=",
2052                                        "50");
[445]2053
[469]2054        RegisterOption("VspBspTree.Termination.minRays",
[508]2055                                        optInt,
2056                                        "vsp_bsp_term_min_rays=",
2057                                        "-1");
[445]2058
[469]2059        RegisterOption("VspBspTree.Termination.ct_div_ci",
[508]2060                                        optFloat,
2061                                        "vsp_bsp_term_ct_div_ci=",
2062                                        "0.0");
[445]2063
[469]2064        RegisterOption("VspBspTree.Termination.maxDepth",
[508]2065                                        optInt,
2066                                        "vsp_bsp_term_max_depth=",
[1134]2067                                        "50");
[445]2068
[469]2069        RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio",
[482]2070                optFloat,
[666]2071                "vsp_bsp_term_axis_aligned_max_cost_ratio=",
[482]2072                "1.5");
[445]2073
[612]2074        RegisterOption("VspBspTree.useCostHeuristics",
2075                optBool,
[666]2076                "vsp_bsp_use_cost_heuristics=",
[612]2077                "false");
2078
[478]2079        RegisterOption("VspBspTree.Termination.maxViewCells",
[482]2080                optInt,
[666]2081                "vsp_bsp_term_max_view_cells=",
[744]2082                "10000");
[478]2083
[472]2084        RegisterOption("VspBspTree.Termination.maxCostRatio",
2085                optFloat,
[666]2086                "vsp_bsp_term_max_cost_ratio=",
[472]2087                "1.5");
[445]2088
[472]2089        RegisterOption("VspBspTree.Termination.missTolerance",
[997]2090                optInt,
2091                "vsp_bsp_term_miss_tolerance=",
2092                "4");
2093
[469]2094        RegisterOption("VspBspTree.splitPlaneStrategy",
[1134]2095                                        optInt,
[508]2096                                        "vsp_bsp_split_method=",
[1134]2097                                        "1026");
[448]2098
[469]2099        RegisterOption("VspBspTree.maxPolyCandidates",
[508]2100                                        optInt,
2101                                        "vsp_bsp_max_poly_candidates=",
2102                                        "20");
[1134]2103
[469]2104        RegisterOption("VspBspTree.maxRayCandidates",
[508]2105                                        optInt,
2106                                        "vsp_bsp_max_plane_candidates=",
2107                                        "20");
[469]2108
2109        RegisterOption("VspBspTree.maxTests",
[508]2110                                        optInt,
2111                                        "vsp_bsp_max_tests=",
2112                                        "5000");
[469]2113
2114        RegisterOption("VspBspTree.Construction.samples",
[508]2115                                        optInt,
[673]2116                                        "vsp_bsp_construction_samples=",
[508]2117                                        "100000");
[469]2118
[801]2119        RegisterOption("VspBspTree.Construction.minBand",
2120                                        optFloat,
2121                                        "vsp_bsp_construction_min_band=",
[1074]2122                                        "0.01");
[801]2123
2124        RegisterOption("VspBspTree.Construction.maxBand",
2125                                        optFloat,
[1147]2126                                        "vsp_bsp_construction_max_band=",
[1074]2127                                        "0.99");
[801]2128
[822]2129        RegisterOption("VspBspTree.Construction.useDrivingAxisForMaxCost",
2130                                        optBool,
2131                                        "vsp_bsp_construction_use_drivingaxis_for_maxcost=",
2132                                        "false");
2133
[469]2134        RegisterOption("VspBspTree.Construction.epsilon",
[508]2135                                        optFloat,
[1023]2136                                        "vsp_bsp_construction_epsilon=",
[508]2137                                        "0.002");
[469]2138
2139        RegisterOption("VspBspTree.Visualization.exportSplits",
[508]2140                                        optBool,
2141                                        "vsp_bsp_visualization.export_splits",
2142                                        "false");
2143
[485]2144        RegisterOption("VspBspTree.splitUseOnlyDrivingAxis",
[508]2145                                        optBool,
[667]2146                                        "vsp_bsp_split_only_driving_axis=",
[508]2147                                        "false");
2148
[607]2149        RegisterOption("VspBspTree.usePolygonSplitIfAvailable",
2150                                        optBool,
2151                    "vsp_bsp_usePolygonSplitIfAvailable=",
[611]2152                                        "false");
[607]2153
[508]2154        RegisterOption("VspBspTree.Termination.AxisAligned.minRays",
2155                        optInt,
2156                        "bsp_term_axis_aligned_min_rays=",
[1134]2157                        "0");
[492]2158       
[508]2159        RegisterOption("VspBspTree.Termination.AxisAligned.maxRayContribution",
2160                        optFloat,
2161                        "bsp_term_axis_aligned_min_rays=",
[1134]2162                        "2");
[508]2163
[676]2164        RegisterOption("VspBspTree.Factor.leastRaySplits",
2165                                        optFloat,
2166                                        "vsp_bsp_factor_least_ray_splits=",
2167                                        "1.0");
2168
2169        RegisterOption("VspBspTree.Factor.balancedRays",
2170                                        optFloat,
2171                                        "vsp_bsp_factor_balanced_rays=",
2172                                        "1.0");
2173
2174        RegisterOption("VspBspTree.Factor.pvs",
2175                                        optFloat,
2176                                        "vsp_bsp_factor_pvs=",
2177                                        "1.0");
[664]2178       
[580]2179        RegisterOption("VspBspTree.Construction.renderCostWeight",
[478]2180                        optFloat,
[1002]2181                        "vsp_bsp_post_process_render_cost_weight=",
[1134]2182                        "1.0");
[478]2183
[1020]2184        RegisterOption("VspBspTree.Construction.renderCostDecreaseWeight",
2185                        optFloat,
[1121]2186                        "vsp_bsp_construction_render_cost_decrease_weight=",
[1020]2187                        "0.99");
2188
[486]2189        RegisterOption("VspBspTree.Construction.randomize",
2190                optBool,
2191                "vsp_bsp_construction_randomize=",
2192                "false");
[508]2193
[663]2194        RegisterOption("VspBspTree.simulateOctree",
2195                optBool,
2196                "vsp_bsp_simulate_octree=",
2197                "false");
2198
[735]2199        RegisterOption("VspBspTree.nodePriorityQueueType",
2200                optInt,
2201                "vsp_bsp_node_queue_type=",
2202                "0");
[664]2203
2204        RegisterOption("VspBspTree.useRandomAxis",
2205                optBool,
2206                "-vsp_bsp_use_random_axis=",
2207                "false");
2208
[508]2209        RegisterOption("VspBspTree.maxTotalMemory",
2210                optFloat,
2211                "vsp_bsp_max_total_mem=",
2212                "60.0");
2213
2214        RegisterOption("VspBspTree.maxStaticMemory",
2215                optFloat,
2216                "vsp_bsp_max_static_mem=",
2217                "8.0");
[564]2218
[1023]2219
2220
[1027]2221/***************************************************************************/
2222/*                 View space partition tree related options               */
2223/***************************************************************************/
[1023]2224
[580]2225       
[1027]2226        RegisterOption("VspTree.Construction.samples",
2227                                        optInt,
2228                                        "vsp_construction_samples=",
2229                                        "10000");
2230
[1121]2231        RegisterOption("VspTree.Construction.renderCostDecreaseWeight",
[1576]2232                                optFloat,
2233                                "vsp_construction_render_cost_decrease_weight=",
[1665]2234                                "0.99");
[1121]2235
[1023]2236        RegisterOption("VspTree.Termination.maxDepth",
2237                                        optInt,
2238                                        "vsp_term_max_depth=",
2239                                        "100");
2240
2241        RegisterOption("VspTree.Termination.minRays",
2242                                        optInt,
2243                                        "vsp_term_min_rays=",
2244                                        "-1");
2245
2246
2247        RegisterOption("VspTree.Termination.minPvs",
2248                                        optInt,
2249                                        "vsp_term_min_pvs=",
2250                                        "20");
2251
2252        RegisterOption("VspTree.Termination.minProbability",
2253                                        optFloat,
2254                                        "vsp_term_min_probability=",
[1576]2255                                        "0.0000001");
[1023]2256
2257        RegisterOption("VspTree.Termination.maxRayContribution",
[1576]2258                                optFloat,
2259                                "vsp_term_ray_contribution=",
2260                                "0.9");
[1023]2261       
2262        RegisterOption("VspTree.Termination.maxCostRatio",
[1576]2263                                optFloat,
2264                                "vsp_term_max_cost_ratio=",
2265                                "1.5");
[1023]2266       
2267        RegisterOption("VspTree.Termination.maxViewCells",
[1576]2268                                optInt,
2269                                "vsp_term_max_view_cells=",
2270                                "10000");
[564]2271
[1023]2272       
2273        RegisterOption("VspTree.Termination.missTolerance",
[1576]2274                                optInt,
2275                                "vsp_term_miss_tolerance=",
2276                                "4");
[1023]2277
2278        RegisterOption("VspTree.Termination.minGlobalCostRatio",
2279                                        optFloat,
2280                                        "vsp_term_min_global_cost_ratio=",
2281                                        "0.0001");
2282
2283        RegisterOption("VspTree.Termination.globalCostMissTolerance",
2284                                        optInt,
2285                                        "vsp_term_global_cost_miss_tolerance=",
2286                                        "4");
2287
2288        RegisterOption("VspTree.Termination.ct_div_ci",
2289                                        optFloat,
2290                                        "vsp_term_ct_div_ci=",
2291                                        "0.0");
2292
2293        RegisterOption("VspTree.Construction.epsilon",
2294                                        optFloat,
2295                                        "vsp_construction_epsilon=",
2296                                        "0.002");
2297
2298        RegisterOption("VspTree.splitUseOnlyDrivingAxis",
2299                                        optBool,
2300                                        "vsp_split_only_driving_axis=",
2301                                        "false");
2302
2303        RegisterOption("VspTree.maxStaticMemory",
[1576]2304                                        optFloat,
2305                                        "vsp_max_static_mem=",
2306                                        "8.0");
[1023]2307
2308        RegisterOption("VspTree.useCostHeuristics",
[1576]2309                                        optBool,
2310                                        "vsp_use_cost_heuristics=",
2311                                        "false");
[1023]2312
2313        RegisterOption("VspTree.simulateOctree",
[1576]2314                                        optBool,
2315                                        "vsp_simulate_octree=",
2316                                        "false");
[1023]2317
2318        RegisterOption("VspTree.Construction.randomize",
[1576]2319                                        optBool,
2320                                        "vsp_construction_randomize=",
2321                                        "false");
[1023]2322
2323        RegisterOption("VspTree.subdivisionStats",
2324                                        optString,
2325                                        "vsp_subdivision_stats=",
2326                                        "vspSubdivisionStats.log");
2327
2328        RegisterOption("VspTree.Construction.minBand",
2329                                        optFloat,
2330                                        "vsp_construction_min_band=",
[1074]2331                                        "0.01");
[1023]2332
2333        RegisterOption("VspTree.Construction.maxBand",
2334                                        optFloat,
[1074]2335                                        "vsp_construction_max_band=",
2336                                        "0.99");
[1106]2337       
[1149]2338        RegisterOption("VspTree.maxTests",
2339                                        optInt,
2340                                        "vsp_max_tests=",
[1161]2341                                        "5000");
[1143]2342
2343
[1074]2344
[1288]2345/***********************************************************************/
2346/*           Object space partition tree related options               */
2347/***********************************************************************/
[1143]2348
[1294]2349
[1106]2350        RegisterOption("OspTree.Construction.randomize",
[1288]2351                                        optBool,
2352                                        "osp_construction_randomize=",
2353                                        "false");
[1106]2354
2355        RegisterOption("OspTree.Termination.maxDepth",
2356                                        optInt,
2357                                        "osp_term_max_depth=",
2358                                        "30");
2359       
2360        RegisterOption("OspTree.Termination.maxLeaves",
2361                                        optInt,
2362                                        "osp_term_max_leaves=",
2363                                        "1000");
2364       
2365        RegisterOption("OspTree.Termination.minObjects",
2366                                        optInt,
2367                                        "osp_term_min_objects=",
2368                                        "1");
2369
2370        RegisterOption("OspTree.Termination.minProbability",
2371                                        optFloat,
2372                                        "osp_term_min_objects=",
[1288]2373                                        "0.00001");
[1106]2374
2375        RegisterOption("OspTree.Termination.missTolerance",
2376                                        optInt,
2377                                        "osp_term_miss_tolerance=",
[1288]2378                                        "8");
[1106]2379
2380        RegisterOption("OspTree.Termination.maxCostRatio",
2381                                        optFloat,
2382                                        "osp_term_max_cost_ratio=",
2383                                        "0.99");
2384
2385        RegisterOption("OspTree.Termination.minGlobalCostRatio",
2386                                        optFloat,
2387                                        "osp_term_min_global_cost_ratio=",
2388                                        "0.00001");
2389
2390        RegisterOption("OspTree.Termination.globalCostMissTolerance",
2391                                        optInt,
2392                                        "osp_term_global_cost_miss_tolerance=",
2393                                        "4");
2394
2395        RegisterOption("OspTree.Termination.ct_div_ci",
2396                                        optFloat,
2397                                        "osp_term_ct_div_ci=",
2398                                        "0");
2399       
2400        RegisterOption("OspTree.Construction.epsilon",
[1288]2401                                   optFloat,
2402                                   "osp_construction_epsilon=",
2403                                   "0.00001");
[1106]2404       
2405        // if only the driving axis is used for axis aligned split
2406        RegisterOption("OspTree.splitUseOnlyDrivingAxis",
[1288]2407                                   optBool,
2408                                   "osp_split_only_driving_axis=",
2409                                   "false");
[1106]2410
2411        RegisterOption("OspTree.maxStaticMemory",
[1288]2412                                   optFloat,
2413                                   "osp_max_static_mem=",
2414                                   "8.0");
[1106]2415
2416        RegisterOption("OspTree.useCostHeuristics",
[1288]2417                                   optBool,
2418                                   "osp_use_cost_heuristics=",
2419                                   "true");
[1106]2420
2421        RegisterOption("OspTree.subdivisionStats",
2422                                        optString,
2423                                        "osp_subdivision_stats=",
2424                                        "ospSubdivisionStats.log");
2425
2426        RegisterOption("OspTree.Construction.splitBorder",
2427                                        optFloat,
2428                                        "osp_construction_split_border=",
2429                                        "0.01");
2430
[1121]2431        RegisterOption("OspTree.Construction.renderCostDecreaseWeight",
[1288]2432                                   optFloat,
2433                                   "osp_construction_render_cost_decrease_weight=",
2434                                   "0.99");
[1106]2435
2436
[1288]2437
[1297]2438/**********************************************************************/
2439/*            Bounding Volume Hierarchy related options               */
2440/**********************************************************************/
[1288]2441
2442        RegisterOption("BvHierarchy.Construction.randomize",
2443                                        optBool,
2444                                        "bvh_construction_randomize=",
2445                                        "false");
2446
2447        RegisterOption("BvHierarchy.Termination.maxDepth",
2448                                        optInt,
2449                                        "bvh_term_max_depth=",
2450                                        "30");
2451       
2452        RegisterOption("BvHierarchy.Termination.maxLeaves",
2453                                        optInt,
2454                                        "bvh_term_max_leaves=",
2455                                        "1000");
2456       
2457        RegisterOption("BvHierarchy.Termination.minObjects",
2458                                        optInt,
2459                                        "bvh_term_min_objects=",
2460                                        "1");
2461
2462        RegisterOption("BvHierarchy.Termination.minProbability",
2463                                        optFloat,
2464                                        "bvh_term_min_objects=",
[1576]2465                                        "0.0000001");
[1288]2466
[1370]2467        RegisterOption("BvHierarchy.Termination.minRays",
2468                                        optInt,
2469                                        "bvh_term_min_rays=",
2470                                        "0");
2471
[1288]2472        RegisterOption("BvHierarchy.Termination.missTolerance",
2473                                        optInt,
2474                                        "osp_term_miss_tolerance=",
2475                                        "8");
2476
2477        RegisterOption("BvHierarchy.Termination.maxCostRatio",
2478                                        optFloat,
2479                                        "bvh_term_max_cost_ratio=",
2480                                        "0.99");
2481
2482        RegisterOption("BvHierarchy.Termination.minGlobalCostRatio",
2483                                        optFloat,
2484                                        "bvh_term_min_global_cost_ratio=",
2485                                        "0.00001");
2486
2487        RegisterOption("BvHierarchy.Termination.globalCostMissTolerance",
2488                                        optInt,
2489                                        "bvh_term_global_cost_miss_tolerance=",
2490                                        "4");
2491
2492        // if only the driving axis is used for axis aligned split
2493        RegisterOption("BvHierarchy.splitUseOnlyDrivingAxis",
2494                                   optBool,
2495                                   "bvh_split_only_driving_axis=",
2496                                   "false");
2497
2498        RegisterOption("BvHierarchy.maxStaticMemory",
2499                                   optFloat,
2500                                   "bvh_max_static_mem=",
2501                                   "8.0");
2502
2503        RegisterOption("BvHierarchy.useCostHeuristics",
2504                                   optBool,
2505                                   "bvh_use_cost_heuristics=",
2506                                   "true");
[1643]2507       
2508        RegisterOption("BvHierarchy.useSah",
2509                                   optBool,
2510                                   "bvh_use_sah=",
2511                                   "false");
2512
[1288]2513        RegisterOption("BvHierarchy.subdivisionStats",
[1174]2514                                        optString,
[1288]2515                                        "bvh_subdivision_stats=",
2516                                        "bvhSubdivisionStats.log");
[1174]2517
[1288]2518        RegisterOption("BvHierarchy.Construction.renderCostDecreaseWeight",
2519                                   optFloat,
2520                                   "bvh_construction_render_cost_decrease_weight=",
[1665]2521                                   "0.99");
[1359]2522       
2523        RegisterOption("BvHierarchy.Construction.useGlobalSorting",
2524                                        optBool,
2525                                        "bvh_construction_use_global_sorting=",
[1489]2526                                        "true");
[1779]2527       
[1784]2528        RegisterOption("BvHierarchy.Construction.useInitialSubdivision",
[1779]2529                                        optBool,
2530                                        "bvh_construction_use_initial_subdivision=",
2531                                        "false");
[1288]2532
[1786]2533        RegisterOption("BvHierarchy.Construction.Initial.minObjects",
2534                                        optInt,
2535                                        "bvh_construction_use_initial_min_objects=",
2536                                        "100000");
2537
2538        RegisterOption("BvHierarchy.Construction.Initial.minArea",
2539                                        optFloat,
2540                                        "bvh_construction_use_initial_min_area=",
2541                                        "0.0001");
2542
2543        RegisterOption("BvHierarchy.Construction.Initial.maxAreaRatio",
2544                                        optFloat,
2545                                        "bvh_construction_use_initial_max_area_ratio=",
[1825]2546                                        "0.9");
[1786]2547
[1676]2548        RegisterOption("BvHierarchy.minRaysForVisibility",
2549                                        optInt,
2550                                        "bvh_min_rays_for_vis=",
2551                                        "0");
[1640]2552
[1727]2553        RegisterOption("BvHierarchy.maxTests",
2554                                        optInt,
2555                                        "bvh_max_tests=",
2556                                        "50000");
[1676]2557
[1727]2558
[1359]2559        /*******************************************************************/
2560        /*               Hierarchy Manager related options                 */
2561        /*******************************************************************/
[1288]2562
[1640]2563        RegisterOption("Hierarchy.Construction.samples",
2564                                        optInt,
[1642]2565                                        "hierarchy_construction_samples=",
[1640]2566                                        "100000");
2567
[1288]2568        RegisterOption("Hierarchy.subdivisionStats",
2569                           optString,
2570                                   "hierarchy_subdivision_stats=",
2571                                   "hierarchySubdivisionStats.log");
2572
2573        RegisterOption("Hierarchy.type",
2574                           optString,
2575                                   "hierarchy_type=",
2576                                   "bvh");
2577
2578        RegisterOption("Hierarchy.Termination.minGlobalCostRatio",
2579                                        optFloat,
2580                                        "hierarchy_term_min_global_cost_ratio=",
[1444]2581                                        "0.000000001");
[1288]2582
2583        RegisterOption("Hierarchy.Termination.globalCostMissTolerance",
2584                                        optInt,
2585                                        "hierarchy_term_global_cost_miss_tolerance=",
2586                                        "4");
2587
2588        RegisterOption("Hierarchy.Termination.maxLeaves",
2589                                        optInt,
2590                                        "hierarchy_term_max_leaves=",
2591                                        "1000");
2592       
[1293]2593        RegisterOption("Hierarchy.Construction.type",
2594                                        optInt,
2595                                        "hierarchy_construction_type=",
2596                                        "0");
2597
[1311]2598        RegisterOption("Hierarchy.Construction.minDepthForOsp",
2599                                        optInt,
2600                                        "hierarchy_construction_min_depth_for_osp=",
2601                                        "-1");
2602
[1370]2603        RegisterOption("Hierarchy.Construction.startWithObjectSpace",
2604                                        optBool,
2605                                        "hierarchy_construction_start_with_osp=",
2606                                        "true");
2607
[1662]2608        RegisterOption("Hierarchy.Construction.considerMemory",
2609                                        optBool,
2610                                        "hierarchy_construction_consider_memory=",
[1744]2611                                        "true");
[1662]2612
[1314]2613        RegisterOption("Hierarchy.Construction.repairQueue",
2614                                        optBool,
2615                                        "hierarchy_construction_repair_queue=",
2616                                        "true");
[1311]2617
[1370]2618        RegisterOption("Hierarchy.Construction.minDepthForVsp",
2619                                        optInt,
2620                                        "hierarchy_construction_min_depth_for_vsp=",
2621                                        "-1");
[1359]2622
[1649]2623        RegisterOption("Hierarchy.Termination.maxMemory",
2624                                        optFloat,
[1653]2625                                        "hierarchy_term_max_memory=",
[1649]2626                                        "1");
2627
[1666]2628        RegisterOption("Hierarchy.Termination.memoryConst",
2629                                        optFloat,
2630                                        "hierarchy_term_memory_const=",
2631                                        "1.0");
2632
[1545]2633        RegisterOption("Hierarchy.Construction.useMultiLevel",
[1449]2634                                        optBool,
[1545]2635                                        "hierarchy_construction_multilevel=",
[1449]2636                                        "false");
2637
[1576]2638        RegisterOption("Hierarchy.Construction.levels",
2639                                        optInt,
2640                                        "hierarchy_construction_levels=",
2641                                        "4");
[1727]2642
2643        RegisterOption("Hierarchy.Construction.maxRepairs",
2644                                        optInt,
[1843]2645                                        "hierarchy_construction_max_repairs=",
[1727]2646                                        "1000");
2647
[1640]2648        RegisterOption("Hierarchy.Construction.minStepsOfSameType",
2649                                        optInt,
2650                                        "hierarchy_construction_min_steps_same_type=",
2651                                        "200");
[1576]2652
[1684]2653        RegisterOption("Hierarchy.Construction.maxStepsOfSameType",
2654                                        optInt,
2655                                        "hierarchy_construction_max_steps_same_type=",
2656                                        "700");
2657
[1633]2658        RegisterOption("Hierarchy.Construction.recomputeSplitPlaneOnRepair",
2659                                        optBool,
2660                                        "hierarchy_construction_recompute_split_on_repair=",
2661                                        "true");
2662
[1895]2663        RegisterOption("Hierarchy.Construction.maxAvgRayContri",
2664                                        optFloat,
2665                                        "hierarchy_construction_max_avg_raycontri=",
2666                                        "99999.0");
2667       
[1912]2668        RegisterOption("Hierarchy.Construction.minAvgRayContri",
2669                                        optFloat,
2670                                        "hierarchy_construction_min_avg_raycontri=",
2671                                        "99990.0");
2672       
[1458]2673        /////////////////////////////////////////////////////////////////
[1895]2674
[372]2675}
2676
2677void
2678Environment::SetStaticOptions()
2679{
2680 
2681  // get Global option values
2682  GetRealValue("Limits.threshold", Limits::Threshold);
2683  GetRealValue("Limits.small", Limits::Small);
2684  GetRealValue("Limits.infinity", Limits::Infinity);
2685
2686
2687}
2688
[938]2689bool
[492]2690Environment::Parse(const int argc, char **argv, bool useExePath)
[372]2691{
[938]2692  bool result = true;
[372]2693  // Read the names of the scene, environment and output files
2694  ReadCmdlineParams(argc, argv, "");
2695
2696  char *envFilename = new char[128];
2697
2698  char filename[64];
2699
2700  // Get the environment file name
2701  if (!GetParam(' ', 0, filename)) {
2702    // user didn't specified environment file explicitly, so
[1199]2703    strcpy(filename, "default.env");
[372]2704  }
[1757]2705
[372]2706 
2707  if (useExePath) {
2708    char *path = GetPath(argv[0]);
2709    if (*path != 0)
2710      sprintf(envFilename, "%s/%s", path, filename);
2711    else
2712      strcpy(envFilename, filename);
2713   
2714    delete path;
2715  }
2716  else
2717    strcpy(envFilename, filename);
2718
2719 
2720  // Now it's time to read in environment file.
2721  if (!ReadEnvFile(envFilename)) {
2722    // error - bad input file name specified ?
2723    cerr<<"Error parsing environment file "<<envFilename<<endl;
[938]2724        result = false;
[372]2725  }
2726  delete envFilename;
2727
2728  // Parse the command line; options given on the command line subsume
2729  // stuff specified in the input environment file.
2730  ParseCmdline(argc, argv, 0);
2731
2732  SetStaticOptions();
2733
2734  // Check for request for help
2735  if (CheckForSwitch(argc, argv, '?')) {
2736    PrintUsage(cout);
2737    exit(0);
2738  }
[938]2739 
2740  return true;
[372]2741}
[860]2742
[878]2743}
Note: See TracBrowser for help on using the repository browser.