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

Revision 422, 3.0 KB checked in by mattausch, 19 years ago (diff)

worded on vspkdtree

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   
26  char buff[128];
27 
28  environment->GetStringValue("Preprocessor.type", buff);
29  string preprocessorType(buff);
30       
31  Preprocessor *p;
32
33        if (preprocessorType == "vss")
34                p = new VssPreprocessor();
35        else
36                if (preprocessorType == "exact")
37                        p = new ExactPreprocessor();
38                else
39                        if (preprocessorType == "sampling")
40                                p = new SamplingPreprocessor();
41                        else {
42                                cerr<<"Unknown preprocessor type"<<endl;
43                                Debug<<"Unknown preprocessor type"<<endl;
44                                exit(1);
45                        }
46       
47
48  environment->GetStringValue("Scene.filename", buff);
49  string filename(buff);
50
51  p->LoadScene(filename);
52       
53  p->BuildKdTree();
54  p->KdTreeStatistics(cout);
55 
56  // parse view cell hierarchy options
57  p->ParseViewCellsOptions();
58
59  if (ViewCell::sHierarchy == ViewCell::BSP)
60  {
61          BspTree::ParseEnvironment();
62
63          // We construct BSP tree immediately for "from view cells" or "from scene geometry"
64          // construction method.
65          // For the "from samples" option, construction is delayed until enough samples were collected
66          if (BspTree::sConstructionMethod != BspTree::FROM_SAMPLES)
67          {             
68                  if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
69                  {
70                          //-- load view cells from file
71                          environment->GetStringValue("ViewCells.filename", buff);
72                          string vcFilename(buff);
73                          p->LoadViewCells(vcFilename);
74                          Debug << (int)p->mViewCells.size() << " view cells loaded" << endl;
75                  }
76                 
77                  p->BuildBspTree();
78       
79                  p->Export("vc_bsptree.x3d", false, false, true);
80                  p->BspTreeStatistics(Debug);
81          }
82  }
83
84  //  p->mSceneGraph->Export("soda.x3d");
85  if (0) {
86    p->Export(filename + "-out.x3d", true, false, false);
87    p->Export(filename + "-kdtree.x3d", false, true, false);   
88  }
89 
90   
91  if (1) {
92    p->ComputeVisibility();
93    p->ExportPreprocessedData("scene.vis");
94  }
95
96        Camera camera;
97  if (0) {
98    //camera.LookAtBox(p->mKdTree->GetBox());
99                camera.LookInBox(p->mKdTree->GetBox());
100                camera.SetPosition(camera.mPosition + Vector3(0,300,0));
101    camera.SnapImage("camera.jpg", p->mKdTree);
102        }
103        if (0) {
104    camera.LookInBox(p->mKdTree->GetBox());
105    camera.SetPosition(camera.mPosition - Vector3(0,100,0));
106    camera.SnapImage("camera2.jpg", p->mKdTree);
107  }
108
109        if (0) {
110    camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) );
111                camera.SetDirection(Vector3(1, 0, 0));
112                camera.SnapImage("camera3.jpg", p->mKdTree);
113  }
114
115  // clean up
116  DEL_PTR(p);
117  DEL_PTR(environment);
118
119  return 0;
120}
121
Note: See TracBrowser for help on using the repository browser.