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