#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" #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(); if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS) { 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->BspTreeStatistics(Debug); p->Export("vc_bsptree2.x3d", false, false, true); // export the bsp splits Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d"); if (exporter) { Material m; m.mDiffuseColor = RgbColor(1, 0, 0); exporter->SetForcedMaterial(m); exporter->SetWireframe(); exporter->ExportBspSplits(*p->mBspTree); m.mDiffuseColor = RgbColor(0, 1, 0); exporter->SetForcedMaterial(m); exporter->SetFilled(); exporter->ExportViewCells(p->mViewCells); delete exporter; } #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 (1) { 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.png", p->mKdTree); } // clean up DEL_PTR(p); DEL_PTR(environment); return 0; }