[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();
|
---|
[235] | 25 | BspTree::ParseEnvironment();
|
---|
| 26 |
|
---|
[374] | 27 | char buff[128];
|
---|
[162] | 28 |
|
---|
[374] | 29 | environment->GetStringValue("Preprocessor.type", buff);
|
---|
| 30 |
|
---|
| 31 | string preprocessorType(buff);
|
---|
| 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 &&
|
---|
[331] | 65 | !(BspTree::sConstructionMethod == BspTree::FROM_RAYS))
|
---|
[372] | 66 | {
|
---|
| 67 | if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS)
|
---|
| 68 | {
|
---|
[310] | 69 | // view cells input file name
|
---|
[372] | 70 | environment->GetStringValue("ViewCells.filename", buff);
|
---|
| 71 | string vcFilename(buff);
|
---|
| 72 |
|
---|
[309] | 73 | if (vcFilename != "")
|
---|
[310] | 74 | p->LoadViewCells(vcFilename);
|
---|
[309] | 75 | else
|
---|
| 76 | p->GenerateViewCells();
|
---|
[289] | 77 |
|
---|
[310] | 78 | Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
|
---|
[309] | 79 | }
|
---|
[310] | 80 |
|
---|
| 81 | p->BuildBspTree();
|
---|
[332] | 82 |
|
---|
[322] | 83 | p->Export("vc_bsptree.x3d", false, false, true);
|
---|
[372] | 84 | p->BspTreeStatistics(Debug);
|
---|
| 85 |
|
---|
| 86 | #if 0
|
---|
| 87 | //-- export the complementary view cells
|
---|
| 88 | // i.e., the view cells not associated with leafs in the tree.
|
---|
| 89 | Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d");
|
---|
| 90 |
|
---|
| 91 | ViewCellContainer::iterator vc_compl_it;
|
---|
| 92 | ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size());
|
---|
| 93 |
|
---|
[309] | 94 | sort(p->mViewCells.begin(), p->mViewCells.end());
|
---|
| 95 |
|
---|
| 96 | vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
|
---|
[372] | 97 | X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin());
|
---|
| 98 |
|
---|
| 99 | vc_compl.erase(vc_compl_it, vc_compl.end());
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | if (exporter)
|
---|
| 103 | {
|
---|
[309] | 104 | Debug << "Exporting complementary view cells" << endl;
|
---|
[313] | 105 | exporter->ExportViewCells(vc_compl); // export view cells
|
---|
[309] | 106 | delete exporter;
|
---|
| 107 | }
|
---|
| 108 | #endif
|
---|
[294] | 109 | }
|
---|
[263] | 110 |
|
---|
[162] | 111 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 112 | if (0) {
|
---|
[242] | 113 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 114 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 115 | }
|
---|
| 116 |
|
---|
[261] | 117 |
|
---|
[335] | 118 | if (1) {
|
---|
[176] | 119 | p->ComputeVisibility();
|
---|
| 120 | p->ExportPreprocessedData("scene.vis");
|
---|
| 121 | }
|
---|
[235] | 122 |
|
---|
[386] | 123 | Camera camera;
|
---|
[344] | 124 | if (0) {
|
---|
[237] | 125 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
[333] | 126 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 127 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 128 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
[386] | 129 | }
|
---|
| 130 | if (0) {
|
---|
[170] | 131 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 132 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
[333] | 133 | camera.SnapImage("camera2.jpg", p->mKdTree);
|
---|
[170] | 134 | }
|
---|
[162] | 135 |
|
---|
[386] | 136 | if (0) {
|
---|
| 137 | camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) );
|
---|
| 138 | camera.SetDirection(Vector3(1, 0, 0));
|
---|
| 139 | camera.SnapImage("camera3.jpg", p->mKdTree);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[261] | 142 | // clean up
|
---|
| 143 | DEL_PTR(p);
|
---|
| 144 | DEL_PTR(environment);
|
---|
| 145 |
|
---|
[162] | 146 | return 0;
|
---|
| 147 | }
|
---|
| 148 |
|
---|