#include "SamplingPreprocessor.h" #include "VssPreprocessor.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(); VspKdTree::ParseEnvironment(); char buff[128]; environment->GetStringValue("Preprocessor.type", buff); string preprocessorType(buff); Preprocessor *p; if (preprocessorType == "vss") p = new VssPreprocessor(); else if (preprocessorType == "exact") p = new ExactPreprocessor(); else if (preprocessorType == "sampling") p = new SamplingPreprocessor(); else { cerr<<"Unknown preprocessor type"<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 (ViewCell::sHierarchy == ViewCell::BSP && !(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); p->LoadViewCells(vcFilename); Debug << (int)p->mViewCells.size() << " view cells loaded" << endl; } p->BuildBspTree(); p->Export("vc_bsptree.x3d", false, false, true); p->BspTreeStatistics(Debug); } // 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"); } Camera camera; if (0) { //camera.LookAtBox(p->mKdTree->GetBox()); camera.LookInBox(p->mKdTree->GetBox()); camera.SetPosition(camera.mPosition + Vector3(0,300,0)); camera.SnapImage("camera.jpg", p->mKdTree); } if (0) { camera.LookInBox(p->mKdTree->GetBox()); camera.SetPosition(camera.mPosition - Vector3(0,100,0)); camera.SnapImage("camera2.jpg", p->mKdTree); } if (0) { camera.SetPosition( p->mKdTree->GetBox().Center() - Vector3(0,-100,0) ); camera.SetDirection(Vector3(1, 0, 0)); camera.SnapImage("camera3.jpg", p->mKdTree); } // clean up DEL_PTR(p); DEL_PTR(environment); return 0; }