[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
|
---|
[303] | 42 |
|
---|
[304] | 43 | if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS)
|
---|
[263] | 44 | {
|
---|
[264] | 45 | if (vcFilename != "")
|
---|
| 46 | p->LoadViewCells(vcFilename); |
---|
[263] | 47 | else
|
---|
| 48 | p->GenerateViewCells();
|
---|
[289] | 49 |
|
---|
[297] | 50 | Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
|
---|
[263] | 51 | }
|
---|
| 52 |
|
---|
| 53 | p->BuildBspTree();
|
---|
[235] | 54 | p->BspTreeStatistics(Debug);
|
---|
[303] | 55 | p->Export("vc_bsptree2.x3d", false, false, true);
|
---|
[292] | 56 | |
---|
[303] | 57 | #if 0 |
---|
[302] | 58 | //-- export the complementary view cells |
---|
| 59 | // i.e., the view cells not associated with leafs in the tree. |
---|
[292] | 60 | Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); |
---|
| 61 | |
---|
| 62 | ViewCellContainer::iterator vc_compl_it; |
---|
| 63 | ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); |
---|
[294] | 64 | |
---|
[292] | 65 | sort(p->mViewCells.begin(), p->mViewCells.end()); |
---|
| 66 | vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
|
---|
| 67 | X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(),
|
---|
| 68 | vc_compl.begin()); |
---|
| 69 | vc_compl.erase(vc_compl_it, vc_compl.end()); |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | if (exporter) |
---|
| 73 | { |
---|
[303] | 74 | Debug << Exporting complementary view cells" << endl; |
---|
[292] | 75 | exporter->ExportViewCells(&vc_compl); // export view cells
|
---|
| 76 | delete exporter;
|
---|
[294] | 77 | }
|
---|
[303] | 78 | #endif
|
---|
[263] | 79 |
|
---|
[234] | 80 | #endif
|
---|
| 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 |
|
---|
[176] | 89 | if (1) {
|
---|
| 90 | p->ComputeVisibility();
|
---|
| 91 | p->ExportPreprocessedData("scene.vis");
|
---|
| 92 | }
|
---|
[235] | 93 |
|
---|
[237] | 94 | if (1) {
|
---|
[170] | 95 | Camera camera;
|
---|
[237] | 96 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
| 97 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 98 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 99 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
| 100 |
|
---|
[170] | 101 |
|
---|
| 102 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 103 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
| 104 | camera.SnapImage("camera2.png", p->mKdTree);
|
---|
| 105 | }
|
---|
[162] | 106 |
|
---|
[261] | 107 | // clean up
|
---|
| 108 | DEL_PTR(p);
|
---|
| 109 | DEL_PTR(environment);
|
---|
| 110 |
|
---|
[162] | 111 | return 0;
|
---|
| 112 | }
|
---|
| 113 |
|
---|