[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 |
|
---|
[319] | 40 | if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS &&
|
---|
| 41 | !(BspTree::sConstructionMethod == BspTree::FROM_RAYS)) // construct tree later
|
---|
[310] | 42 | { |
---|
| 43 | if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) |
---|
| 44 | { |
---|
| 45 | // view cells input file name
|
---|
| 46 | environment->GetStringValue("ViewCells.filename", buff); |
---|
| 47 | string vcFilename(buff); |
---|
| 48 | |
---|
[309] | 49 | if (vcFilename != "")
|
---|
[310] | 50 | p->LoadViewCells(vcFilename);
|
---|
[309] | 51 | else
|
---|
| 52 | p->GenerateViewCells();
|
---|
[289] | 53 |
|
---|
[310] | 54 | Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl;
|
---|
[309] | 55 | }
|
---|
[310] | 56 |
|
---|
| 57 | p->BuildBspTree();
|
---|
[309] | 58 |
|
---|
| 59 | p->BspTreeStatistics(Debug);
|
---|
| 60 | p->Export("vc_bsptree2.x3d", false, false, true);
|
---|
[312] | 61 | // export the bsp splits |
---|
| 62 | Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d");
|
---|
| 63 | |
---|
| 64 | if (exporter) |
---|
| 65 | { |
---|
[315] | 66 | Material m; |
---|
[313] | 67 | m.mDiffuseColor = RgbColor(1, 0, 0); |
---|
| 68 | exporter->SetForcedMaterial(m);
|
---|
[318] | 69 | exporter->SetWireframe();//exporter->SetFilled();
|
---|
[312] | 70 | exporter->ExportBspSplits(*p->mBspTree);
|
---|
[313] | 71 | |
---|
[318] | 72 | //m.mDiffuseColor = RgbColor(0, 1, 0); |
---|
| 73 | //exporter->SetForcedMaterial(m);
|
---|
[313] | 74 | exporter->SetFilled();
|
---|
| 75 |
|
---|
[318] | 76 | exporter->ResetForcedMaterial();
|
---|
[313] | 77 | exporter->ExportViewCells(p->mViewCells);
|
---|
| 78 |
|
---|
[312] | 79 | delete exporter;
|
---|
| 80 | } |
---|
[303] | 81 | #if 0 |
---|
[309] | 82 | //-- export the complementary view cells |
---|
| 83 | // i.e., the view cells not associated with leafs in the tree. |
---|
| 84 | Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); |
---|
[292] | 85 | |
---|
[309] | 86 | ViewCellContainer::iterator vc_compl_it; |
---|
| 87 | ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); |
---|
[294] | 88 | |
---|
[309] | 89 | sort(p->mViewCells.begin(), p->mViewCells.end());
|
---|
| 90 |
|
---|
| 91 | vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),
|
---|
| 92 | X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin()); |
---|
| 93 | |
---|
| 94 | vc_compl.erase(vc_compl_it, vc_compl.end()); |
---|
[292] | 95 | |
---|
| 96 | |
---|
[309] | 97 | if (exporter) |
---|
| 98 | { |
---|
| 99 | Debug << "Exporting complementary view cells" << endl;
|
---|
[313] | 100 | exporter->ExportViewCells(vc_compl); // export view cells
|
---|
[309] | 101 | delete exporter;
|
---|
| 102 | }
|
---|
| 103 | #endif
|
---|
[294] | 104 | }
|
---|
[263] | 105 |
|
---|
[162] | 106 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 107 | if (0) {
|
---|
[242] | 108 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 109 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 110 | }
|
---|
| 111 |
|
---|
[261] | 112 |
|
---|
[176] | 113 | if (1) {
|
---|
| 114 | p->ComputeVisibility();
|
---|
| 115 | p->ExportPreprocessedData("scene.vis");
|
---|
| 116 | }
|
---|
[235] | 117 |
|
---|
[237] | 118 | if (1) {
|
---|
[170] | 119 | Camera camera;
|
---|
[237] | 120 | //camera.LookAtBox(p->mKdTree->GetBox());
|
---|
| 121 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 122 | camera.SetPosition(camera.mPosition + Vector3(0,300,0));
|
---|
[191] | 123 | camera.SnapImage("camera.jpg", p->mKdTree);
|
---|
| 124 |
|
---|
[170] | 125 |
|
---|
| 126 | camera.LookInBox(p->mKdTree->GetBox());
|
---|
| 127 | camera.SetPosition(camera.mPosition - Vector3(0,100,0));
|
---|
| 128 | camera.SnapImage("camera2.png", p->mKdTree);
|
---|
| 129 | }
|
---|
[162] | 130 |
|
---|
[261] | 131 | // clean up
|
---|
| 132 | DEL_PTR(p);
|
---|
| 133 | DEL_PTR(environment);
|
---|
| 134 |
|
---|
[162] | 135 | return 0;
|
---|
| 136 | }
|
---|
| 137 |
|
---|