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

Revision 387, 3.9 KB checked in by bittner, 19 years ago (diff)

vss preprocessor updates

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  BspTree::ParseEnvironment();
26
27        char buff[128];
28
29        environment->GetStringValue("Preprocessor.type", buff);
30
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::sConstructionMethod == BspTree::FROM_RAYS))
66  {
67          if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
68          {
69                   // view cells input file name
70                  environment->GetStringValue("ViewCells.filename", buff);
71                  string vcFilename(buff);
72
73                  if (vcFilename != "")
74                          p->LoadViewCells(vcFilename);
75                  else
76                          p->GenerateViewCells();
77
78                  Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
79          }
80       
81          p->BuildBspTree();
82       
83          p->Export("vc_bsptree.x3d", false, false, true);
84          p->BspTreeStatistics(Debug);
85
86#if 0
87          //-- export the complementary view cells
88          // i.e., the view cells not associated with leafs in the tree.
89          Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d");
90
91          ViewCellContainer::iterator vc_compl_it;
92          ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size());
93 
94          sort(p->mViewCells.begin(), p->mViewCells.end());
95
96          vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
97                  X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin());
98
99          vc_compl.erase(vc_compl_it, vc_compl.end());
100 
101
102          if (exporter)
103          {     
104                  Debug << "Exporting complementary view cells" << endl;
105                  exporter->ExportViewCells(vc_compl); // export view cells
106                  delete exporter;
107          }
108#endif
109  }
110
111  //  p->mSceneGraph->Export("soda.x3d");
112  if (0) {
113    p->Export(filename + "-out.x3d", true, false, false);
114    p->Export(filename + "-kdtree.x3d", false, true, false);   
115  }
116 
117   
118  if (1) {
119    p->ComputeVisibility();
120    p->ExportPreprocessedData("scene.vis");
121  }
122
123        Camera camera;
124  if (0) {
125    //camera.LookAtBox(p->mKdTree->GetBox());
126                camera.LookInBox(p->mKdTree->GetBox());
127                camera.SetPosition(camera.mPosition + Vector3(0,300,0));
128    camera.SnapImage("camera.jpg", p->mKdTree);
129        }
130        if (0) {
131    camera.LookInBox(p->mKdTree->GetBox());
132    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
133    camera.SnapImage("camera2.jpg", p->mKdTree);
134  }
135
136        if (0) {
137    camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) );
138                camera.SetDirection(Vector3(1, 0, 0));
139                camera.SnapImage("camera3.jpg", p->mKdTree);
140  }
141
142  // clean up
143  DEL_PTR(p);
144  DEL_PTR(environment);
145
146  return 0;
147}
148
Note: See TracBrowser for help on using the repository browser.