[162] | 1 | #include "SamplingPreprocessor.h"
|
---|
[374] | 2 | #include "VssPreprocessor.h"
|
---|
[162] | 3 | #include "ExactPreprocessor.h"
|
---|
| 4 | #include "Parser.h"
|
---|
| 5 | #include "UnigraphicsParser.h"
|
---|
[170] | 6 | #include "X3dParser.h"
|
---|
[162] | 7 | #include "Environment.h"
|
---|
| 8 | #include "Camera.h"
|
---|
[170] | 9 | #include "MeshKdTree.h"
|
---|
[264] | 10 | #include "Exporter.h"
|
---|
[292] | 11 | #include "X3dExporter.h" // delete later
|
---|
[310] | 12 | #include "ViewCell.h"
|
---|
[321] | 13 | #include "SceneGraph.h"
|
---|
[162] | 14 |
|
---|
| 15 | #define USE_EXE_PATH false
|
---|
| 16 |
|
---|
[372] | 17 |
|
---|
[162] | 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);
|
---|
[170] | 24 | MeshKdTree::ParseEnvironment();
|
---|
[420] | 25 |
|
---|
[419] | 26 | VspKdTree::ParseEnvironment();
|
---|
[235] | 27 |
|
---|
[409] | 28 | char buff[128];
|
---|
| 29 |
|
---|
| 30 | environment->GetStringValue("Preprocessor.type", buff);
|
---|
| 31 | string preprocessorType(buff);
|
---|
[374] | 32 |
|
---|
| 33 | Preprocessor *p;
|
---|
| 34 |
|
---|
| 35 | if (preprocessorType == "vss")
|
---|
| 36 | p = new VssPreprocessor();
|
---|
| 37 | else
|
---|
| 38 | if (preprocessorType == "exact")
|
---|
| 39 | p = new ExactPreprocessor();
|
---|
| 40 | else
|
---|
| 41 | if (preprocessorType == "sampling")
|
---|
| 42 | p = new SamplingPreprocessor();
|
---|
| 43 | else {
|
---|
| 44 | cerr<<"Unknown preprocessor type"<<endl;
|
---|
| 45 | Debug<<"Unknown preprocessor type"<<endl;
|
---|
| 46 | exit(1);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 |
|
---|
[170] | 50 | environment->GetStringValue("Scene.filename", buff);
|
---|
| 51 | string filename(buff);
|
---|
| 52 |
|
---|
| 53 | p->LoadScene(filename);
|
---|
[387] | 54 |
|
---|
[162] | 55 | p->BuildKdTree();
|
---|
| 56 | p->KdTreeStatistics(cout);
|
---|
[310] | 57 |
|
---|
| 58 | // parse view cell hierarchy options
|
---|
| 59 | p->ParseViewCellsOptions();
|
---|
[260] | 60 |
|
---|
[331] | 61 | // construct tree immediately for "from view cells" or "from scene geometry"
|
---|
| 62 | // construction method. For "from rays" construction, wait until there is
|
---|
| 63 | // a certain number of rays collected
|
---|
[366] | 64 | if (ViewCell::sHierarchy == ViewCell::BSP &&
|
---|
[420] | 65 | !(BspTree::mConstructionMethod == BspTree::FROM_RAYS))
|
---|
[372] | 66 | {
|
---|
[420] | 67 | if (BspTree::mConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
|
---|
[372] | 68 | {
|
---|
[419] | 69 | // view cells input file name
|
---|
[372] | 70 | environment->GetStringValue("ViewCells.filename", buff);
|
---|
| 71 | string vcFilename(buff);
|
---|
[419] | 72 | p->LoadViewCells(vcFilename);
|
---|
| 73 | Debug << (int)p->mViewCells.size() << " view cells loaded" << endl;
|
---|
[309] | 74 | }
|
---|
[310] | 75 |
|
---|
| 76 | p->BuildBspTree();
|
---|
[332] | 77 |
|
---|
[322] | 78 | p->Export("vc_bsptree.x3d", false, false, true);
|
---|
[372] | 79 | p->BspTreeStatistics(Debug);
|
---|
[294] | 80 | }
|
---|
[263] | 81 |
|
---|
[162] | 82 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 83 | if (0) {
|
---|
[242] | 84 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 85 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 86 | }
|
---|
| 87 |
|
---|
[261] | 88 |
|
---|
[335] | 89 | if (1) {
|
---|
[176] | 90 | p->ComputeVisibility();
|
---|
| 91 | p->ExportPreprocessedData("scene.vis");
|
---|
| 92 | }
|
---|
[235] | 93 |
|
---|
[386] | 94 | Camera camera;
|
---|
[344] | 95 | if (0) {
|
---|
[237] | 96 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
[333] | 97 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 98 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 99 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
[386] | 100 | }
|
---|
| 101 | if (0) {
|
---|
[170] | 102 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 103 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
[333] | 104 | camera.SnapImage("camera2.jpg", p->mKdTree);
|
---|
[170] | 105 | }
|
---|
[162] | 106 |
|
---|
[386] | 107 | if (0) {
|
---|
| 108 | camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) );
|
---|
| 109 | camera.SetDirection(Vector3(1, 0, 0));
|
---|
| 110 | camera.SnapImage("camera3.jpg", p->mKdTree);
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[261] | 113 | // clean up
|
---|
| 114 | DEL_PTR(p);
|
---|
| 115 | DEL_PTR(environment);
|
---|
| 116 |
|
---|
[162] | 117 | return 0;
|
---|
| 118 | }
|
---|
| 119 |
|
---|