source: trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp @ 420

Revision 420, 3.0 KB checked in by mattausch, 19 years ago (diff)
Line 
1#include "SamplingPreprocessor.h"
2#include "VssPreprocessor.h"
3#include "ExactPreprocessor.h"
4#include "Parser.h"
5#include "UnigraphicsParser.h"
6#include "X3dParser.h"
7#include "Environment.h"
8#include "Camera.h"
9#include "MeshKdTree.h"
10#include "Exporter.h"
11#include "X3dExporter.h" // delete later
12#include "ViewCell.h"
13#include "SceneGraph.h"
14
15#define USE_EXE_PATH false
16
17
18int
19main(int argc, const char **argv)
20{
21  Debug.open("debug.log");
22  environment = new Environment;
23  environment->Parse(argc, argv, USE_EXE_PATH);
24  MeshKdTree::ParseEnvironment();
25 
26  VspKdTree::ParseEnvironment();
27
28  char buff[128];
29 
30  environment->GetStringValue("Preprocessor.type", buff);
31  string preprocessorType(buff);
32       
33  Preprocessor *p;
34
35        if (preprocessorType == "vss")
36                p = new VssPreprocessor();
37        else
38                if (preprocessorType == "exact")
39                        p = new ExactPreprocessor();
40                else
41                        if (preprocessorType == "sampling")
42                                p = new SamplingPreprocessor();
43                        else {
44                                cerr<<"Unknown preprocessor type"<<endl;
45                                Debug<<"Unknown preprocessor type"<<endl;
46                                exit(1);
47                        }
48       
49
50  environment->GetStringValue("Scene.filename", buff);
51  string filename(buff);
52
53  p->LoadScene(filename);
54       
55  p->BuildKdTree();
56  p->KdTreeStatistics(cout);
57 
58  // parse view cell hierarchy options
59  p->ParseViewCellsOptions();
60
61  // construct tree immediately for "from view cells" or "from scene geometry"
62  // construction method. For "from rays" construction, wait until there is
63  // a certain number of rays collected
64  if (ViewCell::sHierarchy == ViewCell::BSP &&
65          !(BspTree::mConstructionMethod == BspTree::FROM_RAYS))
66  {
67          if (BspTree::mConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
68          {
69                  // view cells input file name
70                  environment->GetStringValue("ViewCells.filename", buff);
71                  string vcFilename(buff);
72                  p->LoadViewCells(vcFilename);
73                  Debug << (int)p->mViewCells.size() << " view cells loaded" << endl;
74          }
75       
76          p->BuildBspTree();
77       
78          p->Export("vc_bsptree.x3d", false, false, true);
79          p->BspTreeStatistics(Debug);
80  }
81
82  //  p->mSceneGraph->Export("soda.x3d");
83  if (0) {
84    p->Export(filename + "-out.x3d", true, false, false);
85    p->Export(filename + "-kdtree.x3d", false, true, false);   
86  }
87 
88   
89  if (1) {
90    p->ComputeVisibility();
91    p->ExportPreprocessedData("scene.vis");
92  }
93
94        Camera camera;
95  if (0) {
96    //camera.LookAtBox(p->mKdTree->GetBox());
97                camera.LookInBox(p->mKdTree->GetBox());
98                camera.SetPosition(camera.mPosition + Vector3(0,300,0));
99    camera.SnapImage("camera.jpg", p->mKdTree);
100        }
101        if (0) {
102    camera.LookInBox(p->mKdTree->GetBox());
103    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
104    camera.SnapImage("camera2.jpg", p->mKdTree);
105  }
106
107        if (0) {
108    camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) );
109                camera.SetDirection(Vector3(1, 0, 0));
110                camera.SnapImage("camera3.jpg", p->mKdTree);
111  }
112
113  // clean up
114  DEL_PTR(p);
115  DEL_PTR(environment);
116
117  return 0;
118}
119
Note: See TracBrowser for help on using the repository browser.