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

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