#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 #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); #ifdef TEST_BSP_VIEWCELLS environment->GetStringValue("Scene.viewcells", buff); string vcFilename(buff); // if BSP tree construction method needs predefined view cells if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS) { if (vcFilename != "") p->LoadViewCells(vcFilename); else p->GenerateViewCells(); Debug << "Viewcells loaded / generated. Number of view cells: " << p->mViewCells.size() << endl; } p->BuildBspTree(); p->BspTreeStatistics(Debug); p->Export("vc_bsptree.x3d", false, false, true); //-- 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) { 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; }