[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"
|
---|
[162] | 12 |
|
---|
| 13 | #define USE_EXE_PATH false
|
---|
[310] | 14 | |
---|
[162] | 15 |
|
---|
| 16 | int
|
---|
| 17 | main(int argc, const char **argv)
|
---|
| 18 | {
|
---|
| 19 | Debug.open("debug.log");
|
---|
| 20 | environment = new Environment;
|
---|
| 21 | environment->Parse(argc, argv, USE_EXE_PATH);
|
---|
[170] | 22 | MeshKdTree::ParseEnvironment();
|
---|
[235] | 23 | BspTree::ParseEnvironment();
|
---|
| 24 |
|
---|
[162] | 25 | Preprocessor *p =
|
---|
| 26 | new SamplingPreprocessor();
|
---|
| 27 |
|
---|
[170] | 28 | char buff[128];
|
---|
| 29 | environment->GetStringValue("Scene.filename", buff);
|
---|
| 30 | string filename(buff);
|
---|
| 31 |
|
---|
| 32 | p->LoadScene(filename);
|
---|
[235] | 33 |
|
---|
[162] | 34 | p->BuildKdTree();
|
---|
| 35 | p->KdTreeStatistics(cout);
|
---|
[310] | 36 |
|
---|
| 37 | // parse view cell hierarchy options
|
---|
| 38 | p->ParseViewCellsOptions();
|
---|
[260] | 39 |
|
---|
[309] | 40 | if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS)
|
---|
[310] | 41 | { |
---|
| 42 | if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) |
---|
| 43 | { |
---|
| 44 | // view cells input file name
|
---|
| 45 | environment->GetStringValue("ViewCells.filename", buff); |
---|
| 46 | string vcFilename(buff); |
---|
| 47 | |
---|
[309] | 48 | if (vcFilename != "")
|
---|
[310] | 49 | p->LoadViewCells(vcFilename);
|
---|
[309] | 50 | else
|
---|
| 51 | p->GenerateViewCells();
|
---|
[289] | 52 |
|
---|
[310] | 53 | Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
|
---|
[309] | 54 | }
|
---|
[310] | 55 |
|
---|
| 56 | p->BuildBspTree();
|
---|
[309] | 57 |
|
---|
| 58 | p->BspTreeStatistics(Debug);
|
---|
| 59 | p->Export("vc_bsptree2.x3d", false, false, true);
|
---|
[312] | 60 | // export the bsp splits |
---|
| 61 | Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d");
|
---|
| 62 | |
---|
| 63 | if (exporter) |
---|
| 64 | { |
---|
[315] | 65 | Material m; |
---|
[313] | 66 | m.mDiffuseColor = RgbColor(1, 0, 0); |
---|
| 67 | exporter->SetForcedMaterial(m);
|
---|
| 68 | exporter->SetWireframe();
|
---|
[312] | 69 | exporter->ExportBspSplits(*p->mBspTree);
|
---|
[313] | 70 | |
---|
| 71 | m.mDiffuseColor = RgbColor(0, 1, 0); |
---|
| 72 | exporter->SetForcedMaterial(m);
|
---|
| 73 | exporter->SetFilled();
|
---|
| 74 |
|
---|
| 75 | exporter->ExportViewCells(p->mViewCells);
|
---|
| 76 |
|
---|
[312] | 77 | delete exporter;
|
---|
| 78 | } |
---|
[303] | 79 | #if 0 |
---|
[309] | 80 | //-- export the complementary view cells |
---|
| 81 | // i.e., the view cells not associated with leafs in the tree. |
---|
| 82 | Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); |
---|
[292] | 83 | |
---|
[309] | 84 | ViewCellContainer::iterator vc_compl_it; |
---|
| 85 | ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); |
---|
[294] | 86 | |
---|
[309] | 87 | sort(p->mViewCells.begin(), p->mViewCells.end());
|
---|
| 88 |
|
---|
| 89 | vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
|
---|
| 90 | X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin()); |
---|
| 91 | |
---|
| 92 | vc_compl.erase(vc_compl_it, vc_compl.end()); |
---|
[292] | 93 | |
---|
| 94 | |
---|
[309] | 95 | if (exporter) |
---|
| 96 | { |
---|
| 97 | Debug << "Exporting complementary view cells" << endl;
|
---|
[313] | 98 | exporter->ExportViewCells(vc_compl); // export view cells
|
---|
[309] | 99 | delete exporter;
|
---|
| 100 | }
|
---|
| 101 | #endif
|
---|
[294] | 102 | }
|
---|
[263] | 103 |
|
---|
[162] | 104 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 105 | if (0) {
|
---|
[242] | 106 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 107 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 108 | }
|
---|
| 109 |
|
---|
[261] | 110 |
|
---|
[176] | 111 | if (1) {
|
---|
| 112 | p->ComputeVisibility();
|
---|
| 113 | p->ExportPreprocessedData("scene.vis");
|
---|
| 114 | }
|
---|
[235] | 115 |
|
---|
[237] | 116 | if (1) {
|
---|
[170] | 117 | Camera camera;
|
---|
[237] | 118 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
| 119 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 120 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 121 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
| 122 |
|
---|
[170] | 123 |
|
---|
| 124 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 125 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
| 126 | camera.SnapImage("camera2.png", p->mKdTree);
|
---|
| 127 | }
|
---|
[162] | 128 |
|
---|
[261] | 129 | // clean up
|
---|
| 130 | DEL_PTR(p);
|
---|
| 131 | DEL_PTR(environment);
|
---|
| 132 |
|
---|
[162] | 133 | return 0;
|
---|
| 134 | }
|
---|
| 135 |
|
---|