[162] | 1 | #include "SamplingPreprocessor.h"
|
---|
| 2 | #include "ExactPreprocessor.h"
|
---|
| 3 | #include "Parser.h"
|
---|
| 4 | #include "UnigraphicsParser.h"
|
---|
[170] | 5 | #include "X3dParser.h"
|
---|
[162] | 6 | #include "Environment.h"
|
---|
| 7 | #include "Camera.h"
|
---|
[170] | 8 | #include "MeshKdTree.h"
|
---|
[264] | 9 | #include "Exporter.h"
|
---|
[292] | 10 | #include "X3dExporter.h" // delete later
|
---|
[310] | 11 | #include "ViewCell.h"
|
---|
[321] | 12 | #include "SceneGraph.h"
|
---|
[162] | 13 |
|
---|
| 14 | #define USE_EXE_PATH false
|
---|
[310] | 15 | |
---|
[162] | 16 |
|
---|
| 17 | int
|
---|
| 18 | main(int argc, const char **argv)
|
---|
| 19 | {
|
---|
| 20 | Debug.open("debug.log");
|
---|
| 21 | environment = new Environment;
|
---|
| 22 | environment->Parse(argc, argv, USE_EXE_PATH);
|
---|
[170] | 23 | MeshKdTree::ParseEnvironment();
|
---|
[235] | 24 | BspTree::ParseEnvironment();
|
---|
| 25 |
|
---|
[162] | 26 | Preprocessor *p =
|
---|
| 27 | new SamplingPreprocessor();
|
---|
| 28 |
|
---|
[170] | 29 | char buff[128];
|
---|
| 30 | environment->GetStringValue("Scene.filename", buff);
|
---|
| 31 | string filename(buff);
|
---|
| 32 |
|
---|
| 33 | p->LoadScene(filename);
|
---|
[235] | 34 |
|
---|
[162] | 35 | p->BuildKdTree();
|
---|
| 36 | p->KdTreeStatistics(cout);
|
---|
[310] | 37 |
|
---|
| 38 | // parse view cell hierarchy options
|
---|
| 39 | p->ParseViewCellsOptions();
|
---|
[260] | 40 |
|
---|
[331] | 41 | // construct tree immediately for "from view cells" or "from scene geometry"
|
---|
| 42 | // construction method. For "from rays" construction, wait until there is
|
---|
| 43 | // a certain number of rays collected
|
---|
[319] | 44 | if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS &&
|
---|
[331] | 45 | !(BspTree::sConstructionMethod == BspTree::FROM_RAYS))
|
---|
[310] | 46 | { |
---|
| 47 | if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) |
---|
| 48 | { |
---|
| 49 | // view cells input file name
|
---|
| 50 | environment->GetStringValue("ViewCells.filename", buff); |
---|
| 51 | string vcFilename(buff); |
---|
| 52 | |
---|
[309] | 53 | if (vcFilename != "")
|
---|
[310] | 54 | p->LoadViewCells(vcFilename);
|
---|
[309] | 55 | else
|
---|
| 56 | p->GenerateViewCells();
|
---|
[289] | 57 |
|
---|
[310] | 58 | Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
|
---|
[309] | 59 | }
|
---|
[310] | 60 |
|
---|
| 61 | p->BuildBspTree();
|
---|
[332] | 62 |
|
---|
[322] | 63 | p->Export("vc_bsptree.x3d", false, false, true);
|
---|
| 64 | p->BspTreeStatistics(Debug); |
---|
| 65 | |
---|
[303] | 66 | #if 0 |
---|
[309] | 67 | //-- export the complementary view cells |
---|
| 68 | // i.e., the view cells not associated with leafs in the tree. |
---|
| 69 | Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); |
---|
[292] | 70 | |
---|
[309] | 71 | ViewCellContainer::iterator vc_compl_it; |
---|
| 72 | ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); |
---|
[294] | 73 | |
---|
[309] | 74 | sort(p->mViewCells.begin(), p->mViewCells.end());
|
---|
| 75 |
|
---|
| 76 | vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
|
---|
| 77 | X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin()); |
---|
| 78 | |
---|
| 79 | vc_compl.erase(vc_compl_it, vc_compl.end()); |
---|
[292] | 80 | |
---|
| 81 | |
---|
[309] | 82 | if (exporter) |
---|
| 83 | { |
---|
| 84 | Debug << "Exporting complementary view cells" << endl;
|
---|
[313] | 85 | exporter->ExportViewCells(vc_compl); // export view cells
|
---|
[309] | 86 | delete exporter;
|
---|
| 87 | }
|
---|
| 88 | #endif
|
---|
[294] | 89 | }
|
---|
[263] | 90 |
|
---|
[162] | 91 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 92 | if (0) {
|
---|
[242] | 93 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 94 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 95 | }
|
---|
| 96 |
|
---|
[261] | 97 |
|
---|
[333] | 98 | if (0) {
|
---|
[176] | 99 | p->ComputeVisibility();
|
---|
| 100 | p->ExportPreprocessedData("scene.vis");
|
---|
| 101 | }
|
---|
[235] | 102 |
|
---|
[237] | 103 | if (1) {
|
---|
[170] | 104 | Camera camera;
|
---|
[237] | 105 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
[333] | 106 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 107 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 108 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
[333] | 109 |
|
---|
[170] | 110 |
|
---|
| 111 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 112 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
[333] | 113 | camera.SnapImage("camera2.jpg", p->mKdTree);
|
---|
[170] | 114 | }
|
---|
[162] | 115 |
|
---|
[261] | 116 | // clean up
|
---|
| 117 | DEL_PTR(p);
|
---|
| 118 | DEL_PTR(environment);
|
---|
| 119 |
|
---|
[162] | 120 | return 0;
|
---|
| 121 | }
|
---|
| 122 |
|
---|