#include "SamplingPreprocessor.h" #include "VssPreprocessor.h" #include "RssPreprocessor.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 "ViewCell.h" #include "SceneGraph.h" #include "PreprocessorThread.h" #include "RenderSampler.h" #include "ResourceManager.h" #include #include #include "GlRenderer.h" #define USE_EXE_PATH false #include using namespace GtpVisibilityPreprocessor; int main(int argc, char **argv) { //Now just call this function at the start of your program and if you're //compiling in debug mode (F5), any leaks will be displayed in the Output //window when the program shuts down. If you're not in debug mode this will //be ignored. Use it as you will! //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR); InitTiming(); Debug.open("debug.log"); Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH); MeshKdTree::ParseEnvironment(); char buff[128]; Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff); string preprocessorType(buff); Preprocessor *p = NULL; if (preprocessorType == "vss") { p = new VssPreprocessor(); } else { if (preprocessorType == "rss") { p = new RssPreprocessor(); } else { if (preprocessorType == "exact") { p = new ExactPreprocessor(); } else { if (preprocessorType == "sampling") { p = new SamplingPreprocessor(); } else { if (preprocessorType == "render") { p = new RenderSampler(); } else { Environment::DelSingleton(); cerr<<"Unknown preprocessor type"<mUseGlRenderer || p->mUseGlDebugger) { // create a qt application first (must be created before any opengl widget... app = new QApplication(argc, argv); if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { QMessageBox::information(0, "OpenGL pbuffers", "This system does not support OpenGL/pbuffers.", QMessageBox::Ok); return -1; } } preprocessor = p; Environment::GetSingleton()->GetStringValue("Scene.filename", buff); string filename(buff); p->LoadScene(filename); p->BuildKdTree(); p->KdTreeStatistics(cout); // parse view cells related options p->PrepareViewCells(); // create a preprocessor thread PreprocessorThread *pt = new PreprocessorThread(p, app); // p->mSceneGraph->Export("soda.x3d"); if (0) { p->Export(filename + "-out.x3d", true, false, false); p->Export(filename + "-kdtree.x3d", false, true, false); } if (p->mUseGlRenderer) { rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); // renderer->resize(640, 480); rendererWidget->resize(640, 480); rendererWidget->show(); if (0 && p->GetRenderer()) { cout<<"CONNECTING"<GetRenderer(), SIGNAL(UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &)), rendererWidget->mControlWidget, SLOT(UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &))); cout<<"CONNECTED"<start(QThread::LowPriority); } else{ // just call the mail method -> will be executed in the main thread pt->Main(); } int returnCode = 0; if (app) { returnCode = app->exec(); DEL_PTR(app); } //-- clean up DEL_PTR(p); Environment::DelSingleton(); DEL_PTR(rendererWidget); MeshManager::DelSingleton(); MaterialManager::DelSingleton(); DEL_PTR(pt); return returnCode; }