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

Revision 292, 2.9 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
12#define USE_EXE_PATH false
13
14
15int
16main(int argc, const char **argv)
17{
18  Debug.open("debug.log");
19  environment = new Environment;
20  environment->Parse(argc, argv, USE_EXE_PATH);
21  MeshKdTree::ParseEnvironment();
22  BspTree::ParseEnvironment();
23
24  Preprocessor *p =
25    new SamplingPreprocessor();
26
27  char buff[128];
28  environment->GetStringValue("Scene.filename", buff);
29  string filename(buff);
30
31  p->LoadScene(filename);
32
33  p->BuildKdTree();
34  p->KdTreeStatistics(cout);
35
36#ifdef TEST_BSP_VIEWCELLS
37  environment->GetStringValue("Scene.viewcells", buff);
38
39  string vcFilename(buff);
40
41  // if BSP tree construction method needs predefined view cells
42  if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS)
43  {
44          if (vcFilename != "")
45          p->LoadViewCells(vcFilename);
46          else
47                  p->GenerateViewCells();
48
49         Debug << "Viewcells loaded / generated. Number of view cells: " << p->mViewCells.size() << endl;
50  }
51
52  p->BuildBspTree();
53  p->BspTreeStatistics(Debug);
54  p->Export("vc_bsptree.x3d", false, false, true);
55
56
57  // export the complementary view cells, i.e., the view cells not in the tree.
58  Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d");
59
60  ViewCellContainer::iterator vc_compl_it;
61  ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size());
62
63  Debug << "here1" << endl;
64  sort(p->mViewCells.begin(), p->mViewCells.end());
65  Debug << "here2.5 " << X3dExporter::foundViewCells.size() << endl;
66 
67  vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
68                                 X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(),
69                                 vc_compl.begin());
70
71  Debug << "here2" << endl;
72 
73  vc_compl.erase(vc_compl_it, vc_compl.end());
74 
75  Debug << "Complementary view cells: " << vc_compl.size() << endl;
76
77  if (exporter)
78  {     
79          exporter->ExportViewCells(&vc_compl); // export view cells
80          delete exporter;
81  }Debug << "here4" << endl;
82
83#endif
84
85  //  p->mSceneGraph->Export("soda.x3d");
86  if (0) {
87    p->Export(filename + "-out.x3d", true, false, false);
88    p->Export(filename + "-kdtree.x3d", false, true, false);   
89  }
90 
91   
92  if (1) {
93    p->ComputeVisibility();
94    p->ExportPreprocessedData("scene.vis");
95  }
96
97  if (1) {
98    Camera camera;
99    //camera.LookAtBox(p->mKdTree->GetBox());
100        camera.LookInBox(p->mKdTree->GetBox());
101        camera.SetPosition(camera.mPosition + Vector3(0,300,0));
102    camera.SnapImage("camera.jpg", p->mKdTree);
103
104   
105    camera.LookInBox(p->mKdTree->GetBox());
106    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
107    camera.SnapImage("camera2.png", p->mKdTree);
108  }
109
110  // clean up
111  DEL_PTR(p);
112  DEL_PTR(environment);
113
114  return 0;
115}
116
Note: See TracBrowser for help on using the repository browser.