#include "SamplingPreprocessor.h" #include "ExactPreprocessor.h" #include "Parser.h" #include "UnigraphicsParser.h" #include "X3dParser.h" #include "Environment.h" #include "Camera.h" #include "MeshKdTree.h" #include "Exporter.h" #include "X3dExporter.h" // delete later #include "ViewCell.h" #include "SceneGraph.h" #define USE_EXE_PATH false int main(int argc, const char **argv) { Debug.open("debug.log"); environment = new Environment; environment->Parse(argc, argv, USE_EXE_PATH); MeshKdTree::ParseEnvironment(); BspTree::ParseEnvironment(); Preprocessor *p = new SamplingPreprocessor(); char buff[128]; environment->GetStringValue("Scene.filename", buff); string filename(buff); p->LoadScene(filename); p->BuildKdTree(); p->KdTreeStatistics(cout); // parse view cell hierarchy options p->ParseViewCellsOptions(); // construct tree immediately for "from view cells" or "from scene geometry" // construction method. For "from rays" construction, wait until there is // a certain number of rays collected if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS && !(BspTree::sConstructionMethod == BspTree::FROM_RAYS)) { if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) { // view cells input file name environment->GetStringValue("ViewCells.filename", buff); string vcFilename(buff); if (vcFilename != "") p->LoadViewCells(vcFilename); else p->GenerateViewCells(); Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl; } p->BuildBspTree(); p->Export("vc_bsptree.x3d", false, false, true); p->BspTreeStatistics(Debug); #if 0 //-- export the complementary view cells // i.e., the view cells not associated with leafs in the tree. Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); ViewCellContainer::iterator vc_compl_it; ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); sort(p->mViewCells.begin(), p->mViewCells.end()); vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(), X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin()); vc_compl.erase(vc_compl_it, vc_compl.end()); if (exporter) { Debug << "Exporting complementary view cells" << endl; exporter->ExportViewCells(vc_compl); // export view cells delete exporter; } #endif } // p->mSceneGraph->Export("soda.x3d"); if (0) { p->Export(filename + "-out.x3d", true, false, false); p->Export(filename + "-kdtree.x3d", false, true, false); } if (0) { p->ComputeVisibility(); p->ExportPreprocessedData("scene.vis"); } if (1) { Camera camera; //camera.LookAtBox(p->mKdTree->GetBox()); camera.LookInBox(p->mKdTree->GetBox()); camera.SetPosition(camera.mPosition + Vector3(0,300,0)); camera.SnapImage("camera.jpg", p->mKdTree); camera.LookInBox(p->mKdTree->GetBox()); camera.SetPosition(camera.mPosition - Vector3(0,100,0)); camera.SnapImage("camera2.jpg", p->mKdTree); } // clean up DEL_PTR(p); DEL_PTR(environment); return 0; }