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

Revision 315, 3.4 KB checked in by mattausch, 19 years ago (diff)

deleted debug messages

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
13#define USE_EXE_PATH false
14
15
16int
17main(int argc, const char **argv)
18{
19  Debug.open("debug.log");
20  environment = new Environment;
21  environment->Parse(argc, argv, USE_EXE_PATH);
22  MeshKdTree::ParseEnvironment();
23  BspTree::ParseEnvironment();
24
25  Preprocessor *p =
26    new SamplingPreprocessor();
27
28  char buff[128];
29  environment->GetStringValue("Scene.filename", buff);
30  string filename(buff);
31
32  p->LoadScene(filename);
33
34  p->BuildKdTree();
35  p->KdTreeStatistics(cout);
36 
37  // parse view cell hierarchy options
38  p->ParseViewCellsOptions();
39
40  if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS)
41  {
42          if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
43          {
44                   // view cells input file name
45                  environment->GetStringValue("ViewCells.filename", buff);
46                  string vcFilename(buff);
47
48                  if (vcFilename != "")
49                          p->LoadViewCells(vcFilename);
50                  else
51                          p->GenerateViewCells();
52
53                  Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
54          }
55       
56          p->BuildBspTree();
57         
58          p->BspTreeStatistics(Debug);
59          p->Export("vc_bsptree2.x3d", false, false, true);
60          // export the bsp splits
61          Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d");
62
63          if (exporter)
64          {     
65          Material m;
66                  m.mDiffuseColor = RgbColor(1, 0, 0);
67                  exporter->SetForcedMaterial(m);
68                  exporter->SetWireframe();
69                  exporter->ExportBspSplits(*p->mBspTree);
70
71                  m.mDiffuseColor = RgbColor(0, 1, 0);
72                  exporter->SetForcedMaterial(m);
73                  exporter->SetFilled();
74
75                  exporter->ExportViewCells(p->mViewCells);
76
77                  delete exporter;
78          }
79#if 0
80          //-- export the complementary view cells
81          // i.e., the view cells not associated with leafs in the tree.
82          Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d");
83
84          ViewCellContainer::iterator vc_compl_it;
85          ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size());
86 
87          sort(p->mViewCells.begin(), p->mViewCells.end());
88
89          vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
90                  X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin());
91
92          vc_compl.erase(vc_compl_it, vc_compl.end());
93 
94
95          if (exporter)
96          {     
97                  Debug << "Exporting complementary view cells" << endl;
98                  exporter->ExportViewCells(vc_compl); // export view cells
99                  delete exporter;
100          }
101#endif
102  }
103
104  //  p->mSceneGraph->Export("soda.x3d");
105  if (0) {
106    p->Export(filename + "-out.x3d", true, false, false);
107    p->Export(filename + "-kdtree.x3d", false, true, false);   
108  }
109 
110   
111  if (1) {
112    p->ComputeVisibility();
113    p->ExportPreprocessedData("scene.vis");
114  }
115
116  if (1) {
117    Camera camera;
118    //camera.LookAtBox(p->mKdTree->GetBox());
119        camera.LookInBox(p->mKdTree->GetBox());
120        camera.SetPosition(camera.mPosition + Vector3(0,300,0));
121    camera.SnapImage("camera.jpg", p->mKdTree);
122
123   
124    camera.LookInBox(p->mKdTree->GetBox());
125    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
126    camera.SnapImage("camera2.png", p->mKdTree);
127  }
128
129  // clean up
130  DEL_PTR(p);
131  DEL_PTR(environment);
132
133  return 0;
134}
135
Note: See TracBrowser for help on using the repository browser.