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

Revision 319, 3.6 KB checked in by mattausch, 19 years ago (diff)

changed the from rays construction (not finished yet)

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          !(BspTree::sConstructionMethod == BspTree::FROM_RAYS)) // construct tree later
42  {
43          if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
44          {
45                   // view cells input file name
46                  environment->GetStringValue("ViewCells.filename", buff);
47                  string vcFilename(buff);
48
49                  if (vcFilename != "")
50                          p->LoadViewCells(vcFilename);
51                  else
52                          p->GenerateViewCells();
53
54                  Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
55          }
56       
57          p->BuildBspTree();
58         
59          p->BspTreeStatistics(Debug);
60          p->Export("vc_bsptree2.x3d", false, false, true);
61          // export the bsp splits
62          Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d");
63
64          if (exporter)
65          {     
66          Material m;
67                  m.mDiffuseColor = RgbColor(1, 0, 0);
68                  exporter->SetForcedMaterial(m);
69                  exporter->SetWireframe();//exporter->SetFilled();
70                  exporter->ExportBspSplits(*p->mBspTree);
71
72                  //m.mDiffuseColor = RgbColor(0, 1, 0);
73                  //exporter->SetForcedMaterial(m);
74                  exporter->SetFilled();
75
76                  exporter->ResetForcedMaterial();
77                  exporter->ExportViewCells(p->mViewCells);
78
79                  delete exporter;
80          }
81#if 0
82          //-- export the complementary view cells
83          // i.e., the view cells not associated with leafs in the tree.
84          Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d");
85
86          ViewCellContainer::iterator vc_compl_it;
87          ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size());
88 
89          sort(p->mViewCells.begin(), p->mViewCells.end());
90
91          vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
92                  X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin());
93
94          vc_compl.erase(vc_compl_it, vc_compl.end());
95 
96
97          if (exporter)
98          {     
99                  Debug << "Exporting complementary view cells" << endl;
100                  exporter->ExportViewCells(vc_compl); // export view cells
101                  delete exporter;
102          }
103#endif
104  }
105
106  //  p->mSceneGraph->Export("soda.x3d");
107  if (0) {
108    p->Export(filename + "-out.x3d", true, false, false);
109    p->Export(filename + "-kdtree.x3d", false, true, false);   
110  }
111 
112   
113  if (1) {
114    p->ComputeVisibility();
115    p->ExportPreprocessedData("scene.vis");
116  }
117
118  if (1) {
119    Camera camera;
120    //camera.LookAtBox(p->mKdTree->GetBox());
121        camera.LookInBox(p->mKdTree->GetBox());
122        camera.SetPosition(camera.mPosition + Vector3(0,300,0));
123    camera.SnapImage("camera.jpg", p->mKdTree);
124
125   
126    camera.LookInBox(p->mKdTree->GetBox());
127    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
128    camera.SnapImage("camera2.png", p->mKdTree);
129  }
130
131  // clean up
132  DEL_PTR(p);
133  DEL_PTR(environment);
134
135  return 0;
136}
137
Note: See TracBrowser for help on using the repository browser.