[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
|
---|
[162] | 11 |
|
---|
| 12 | #define USE_EXE_PATH false
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | int
|
---|
| 16 | main(int argc, const char **argv)
|
---|
| 17 | {
|
---|
| 18 | Debug.open("debug.log");
|
---|
| 19 | environment = new Environment;
|
---|
| 20 | environment->Parse(argc, argv, USE_EXE_PATH);
|
---|
[170] | 21 | MeshKdTree::ParseEnvironment();
|
---|
[235] | 22 | BspTree::ParseEnvironment();
|
---|
| 23 |
|
---|
[162] | 24 | Preprocessor *p =
|
---|
| 25 | new SamplingPreprocessor();
|
---|
| 26 |
|
---|
[170] | 27 | char buff[128];
|
---|
| 28 | environment->GetStringValue("Scene.filename", buff);
|
---|
| 29 | string filename(buff);
|
---|
| 30 |
|
---|
| 31 | p->LoadScene(filename);
|
---|
[235] | 32 |
|
---|
[162] | 33 | p->BuildKdTree();
|
---|
| 34 | p->KdTreeStatistics(cout);
|
---|
[260] | 35 |
|
---|
[235] | 36 | #ifdef TEST_BSP_VIEWCELLS
|
---|
[260] | 37 | environment->GetStringValue("Scene.viewcells", buff);
|
---|
| 38 |
|
---|
[264] | 39 | string vcFilename(buff);
|
---|
[261] | 40 |
|
---|
[263] | 41 | // if BSP tree construction method needs predefined view cells
|
---|
| 42 | if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS)
|
---|
| 43 | {
|
---|
[264] | 44 | if (vcFilename != "")
|
---|
| 45 | p->LoadViewCells(vcFilename); |
---|
[263] | 46 | else
|
---|
| 47 | p->GenerateViewCells();
|
---|
[289] | 48 |
|
---|
[292] | 49 | Debug << "Viewcells loaded / generated. Number of view cells: " << p->mViewCells.size() << endl;
|
---|
[263] | 50 | }
|
---|
| 51 |
|
---|
| 52 | p->BuildBspTree();
|
---|
[235] | 53 | p->BspTreeStatistics(Debug);
|
---|
[289] | 54 | p->Export("vc_bsptree.x3d", false, false, true);
|
---|
[292] | 55 | |
---|
[294] | 56 | //-- export the complementary view cells, i.e., the view cells not associated with leafs in the tree. |
---|
[292] | 57 | Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); |
---|
| 58 | |
---|
| 59 | ViewCellContainer::iterator vc_compl_it; |
---|
| 60 | ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); |
---|
[294] | 61 | |
---|
[292] | 62 | sort(p->mViewCells.begin(), p->mViewCells.end()); |
---|
| 63 | vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
|
---|
| 64 | X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(),
|
---|
| 65 | vc_compl.begin()); |
---|
| 66 | vc_compl.erase(vc_compl_it, vc_compl.end()); |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | if (exporter) |
---|
| 70 | { |
---|
| 71 | exporter->ExportViewCells(&vc_compl); // export view cells
|
---|
| 72 | delete exporter;
|
---|
[294] | 73 | }
|
---|
[263] | 74 |
|
---|
[234] | 75 | #endif
|
---|
| 76 |
|
---|
[162] | 77 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 78 | if (0) {
|
---|
[242] | 79 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 80 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 81 | }
|
---|
| 82 |
|
---|
[261] | 83 |
|
---|
[176] | 84 | if (1) {
|
---|
| 85 | p->ComputeVisibility();
|
---|
| 86 | p->ExportPreprocessedData("scene.vis");
|
---|
| 87 | }
|
---|
[235] | 88 |
|
---|
[237] | 89 | if (1) {
|
---|
[170] | 90 | Camera camera;
|
---|
[237] | 91 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
| 92 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 93 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 94 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
| 95 |
|
---|
[170] | 96 |
|
---|
| 97 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 98 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
| 99 | camera.SnapImage("camera2.png", p->mKdTree);
|
---|
| 100 | }
|
---|
[162] | 101 |
|
---|
[261] | 102 | // clean up
|
---|
| 103 | DEL_PTR(p);
|
---|
| 104 | DEL_PTR(environment);
|
---|
| 105 |
|
---|
[162] | 106 | return 0;
|
---|
| 107 | }
|
---|
| 108 |
|
---|