Changeset 1145 for GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
- Timestamp:
- 07/24/06 10:12:34 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1112 r1145 16 16 #include "ResourceManager.h" 17 17 18 #include <QApplication> 19 #include <QtOpenGL> 18 //#include <QApplication> 19 //#include <QtOpenGL> 20 #include <boost/thread/thread.hpp> 21 #include <boost/thread/xtime.hpp> 20 22 #include "GlRenderer.h" 21 23 … … 25 27 26 28 using namespace GtpVisibilityPreprocessor; 29 30 Preprocessor *preprocessor = NULL; 31 32 #if QT_ENABLED 33 QApplication *app = NULL; 34 #endif 35 36 37 void Cleanup() 38 { 39 #if QT_ENABLED 40 DEL_PTR(rendererWidget); 41 #endif 42 43 DEL_PTR(preprocessor); 44 45 Environment::DelSingleton(); 46 MeshManager::DelSingleton(); 47 MaterialManager::DelSingleton(); 48 } 49 50 51 void DisplayWidget() 52 { 53 #if QT_ENABLED 54 QApplication *app = NULL; 55 56 // create a qt application first (must be created before any opengl widget ...) 57 app = new QApplication(argc, argv); 58 59 if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 60 QMessageBox::information(0, "OpenGL pbuffers", 61 "This system does not support OpenGL/pbuffers.", 62 QMessageBox::Ok); 63 return -1; 64 } 65 66 // note matt: capsulate qt dependent code as good as possible 67 rendererWidget = 68 new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 69 70 rendererWidget->resize(640, 480); 71 rendererWidget->show(); 72 73 if (0 && p->GetRenderer()) 74 { 75 cout<<"CONNECTING"<<endl; 76 QObject::connect(p->GetRenderer(), 77 SIGNAL(UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &)), 78 rendererWidget->mControlWidget, 79 SLOT(UpdatePvsErrorItem(int i, 80 GlRendererBuffer::PvsErrorEntry &))); 81 82 cout<<"CONNECTED"<<endl; 83 } 84 #endif 85 } 86 27 87 28 88 int … … 30 90 { 31 91 32 //Now just call this function at the start of your program and if you're 33 //compiling in debug mode (F5), any leaks will be displayed in the Output 34 //window when the program shuts down. If you're not in debug mode this will 35 //be ignored. Use it as you will! 36 //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 37 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 38 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 39 _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR); 40 41 InitTiming(); 42 43 Debug.open("debug.log"); 44 45 Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH); 46 MeshKdTree::ParseEnvironment(); 47 48 char buff[128]; 49 Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff); 50 string preprocessorType(buff); 51 52 Preprocessor *p = NULL; 53 54 55 if (preprocessorType == "vss") 56 { 57 p = new VssPreprocessor(); 58 } 59 else 60 { 61 if (preprocessorType == "rss") 62 { 63 p = new RssPreprocessor(); 92 //Now just call this function at the start of your program and if you're 93 //compiling in debug mode (F5), any leaks will be displayed in the Output 94 //window when the program shuts down. If you're not in debug mode this will 95 //be ignored. Use it as you will! 96 //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 97 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 98 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 99 _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR); 100 101 int returnCode = 0; 102 103 InitTiming(); 104 105 Debug.open("debug.log"); 106 107 Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH); 108 MeshKdTree::ParseEnvironment(); 109 110 char buff[128]; 111 Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff); 112 string preprocessorType(buff); 113 114 if (preprocessorType == "vss") 115 { 116 preprocessor = new VssPreprocessor(); 64 117 } 65 118 else 66 119 { 67 if (preprocessorType == "exact") 68 { 69 p = new ExactPreprocessor(); 70 } 71 else 72 { 73 if (preprocessorType == "sampling") 120 if (preprocessorType == "rss") 74 121 { 75 p = new SamplingPreprocessor();122 preprocessor = new RssPreprocessor(); 76 123 } 77 124 else 78 { 79 if (preprocessorType == "render") 80 { 81 p = new RenderSampler(); 82 } 83 else { 84 Environment::DelSingleton(); 85 cerr<<"Unknown preprocessor type"<<endl; 86 Debug<<"Unknown preprocessor type"<<endl; 87 exit(1); 88 } 125 { 126 if (preprocessorType == "exact") 127 { 128 preprocessor = new ExactPreprocessor(); 129 } 130 else 131 { 132 if (preprocessorType == "sampling") 133 { 134 preprocessor = new SamplingPreprocessor(); 135 } 136 else 137 { 138 if (preprocessorType == "render") 139 { 140 preprocessor = new RenderSampler(); 141 } 142 else { 143 Environment::DelSingleton(); 144 cerr<<"Unknown preprocessor type"<<endl; 145 Debug<<"Unknown preprocessor type"<<endl; 146 exit(1); 147 } 148 } 149 } 89 150 } 90 } 91 } 92 } 93 94 QApplication *app = NULL; 95 96 if (p->mUseGlRenderer || p->mUseGlDebugger) { 151 } 97 152 98 // create a qt application first (must be created before any opengl widget... 99 app = new QApplication(argc, argv); 100 101 if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 102 QMessageBox::information(0, "OpenGL pbuffers", 103 "This system does not support OpenGL/pbuffers.", 104 QMessageBox::Ok); 105 return -1; 106 } 107 } 108 109 preprocessor = p; 110 111 Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 112 string filename(buff); 113 114 p->LoadScene(filename); 115 116 p->BuildKdTree(); 117 p->KdTreeStatistics(cout); 118 119 // parse view cells related options 120 p->PrepareViewCells(); 121 122 123 // create a preprocessor thread 124 PreprocessorThread *pt = new PreprocessorThread(p, app); 125 126 // p->mSceneGraph->Export("soda.x3d"); 127 if (0) { 128 p->Export(filename + "-out.x3d", true, false, false); 129 p->Export(filename + "-kdtree.x3d", false, true, false); 130 } 131 132 if (p->mUseGlRenderer) { 133 134 rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 135 // renderer->resize(640, 480); 136 137 rendererWidget->resize(640, 480); 138 rendererWidget->show(); 139 140 if (0 && p->GetRenderer()) { 141 142 cout<<"CONNECTING"<<endl; 143 QObject::connect(p->GetRenderer(), 144 SIGNAL(UpdatePvsErrorItem(int i, 145 GlRendererBuffer::PvsErrorEntry &)), 146 147 rendererWidget->mControlWidget, 148 SLOT(UpdatePvsErrorItem(int i, 149 GlRendererBuffer::PvsErrorEntry &))); 150 cout<<"CONNECTED"<<endl; 151 } 152 153 pt->start(QThread::LowPriority); 154 155 156 } else{ 157 // just call the mail method -> will be executed in the main thread 158 pt->Main(); 159 } 160 161 162 int returnCode = 0; 163 164 if (app) 165 { 166 returnCode = app->exec(); 167 DEL_PTR(app); 168 } 169 170 //-- clean up 171 DEL_PTR(p); 172 Environment::DelSingleton(); 173 DEL_PTR(rendererWidget); 174 175 MeshManager::DelSingleton(); 176 MaterialManager::DelSingleton(); 177 178 DEL_PTR(pt); 179 180 return returnCode; 153 154 //-- load scene 155 156 Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 157 string filename(buff); 158 preprocessor->LoadScene(filename); 159 160 //-- build kd tree from scene geometry 161 162 preprocessor->BuildKdTree(); 163 preprocessor->KdTreeStatistics(cout); 164 165 // parse view cells related options 166 preprocessor->PrepareViewCells(); 167 168 // p->mSceneGraph->Export("soda.x3d"); 169 if (0) { 170 preprocessor->Export(filename + "-out.x3d", true, false, false); 171 preprocessor->Export(filename + "-kdtree.x3d", false, true, false); 172 } 173 174 175 // create a preprocessor thread 176 //PreprocessorThread *pt = new PreprocessorThread(p, app); 177 PreprocessorThread pt(preprocessor); 178 179 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 180 { 181 // display the render widget 182 DisplayWidget(); 183 184 // create and run the thread 185 boost::thread thrd(pt); 186 thrd.join(); 187 //pt->start(QThread::LowPriority); 188 } 189 else 190 { 191 // just call the mail method -> will be executed in the main thread 192 pt.Main(); 193 } 194 195 #if QT_ENABLED 196 if (app) 197 { 198 returnCode = app->exec(); 199 DEL_PTR(app); 200 } 201 #endif 202 203 Cleanup(); 204 205 return returnCode; 181 206 } 182 207
Note: See TracChangeset
for help on using the changeset viewer.