[162] | 1 | #include "SamplingPreprocessor.h"
|
---|
[374] | 2 | #include "VssPreprocessor.h"
|
---|
[446] | 3 | #include "RssPreprocessor.h"
|
---|
[162] | 4 | #include "ExactPreprocessor.h"
|
---|
| 5 | #include "Parser.h"
|
---|
| 6 | #include "UnigraphicsParser.h"
|
---|
[170] | 7 | #include "X3dParser.h"
|
---|
[162] | 8 | #include "Environment.h"
|
---|
| 9 | #include "Camera.h"
|
---|
[170] | 10 | #include "MeshKdTree.h"
|
---|
[264] | 11 | #include "Exporter.h"
|
---|
[310] | 12 | #include "ViewCell.h"
|
---|
[321] | 13 | #include "SceneGraph.h"
|
---|
[492] | 14 | #include "PreprocessorThread.h"
|
---|
[878] | 15 | #include "RenderSampler.h"
|
---|
[1001] | 16 | #include "ResourceManager.h"
|
---|
[162] | 17 |
|
---|
[492] | 18 | #include <QApplication>
|
---|
| 19 | #include <QtOpenGL>
|
---|
| 20 | #include "GlRenderer.h"
|
---|
| 21 |
|
---|
[162] | 22 | #define USE_EXE_PATH false
|
---|
| 23 |
|
---|
[570] | 24 | #include <crtdbg.h>
|
---|
[372] | 25 |
|
---|
[863] | 26 | using namespace GtpVisibilityPreprocessor;
|
---|
[492] | 27 |
|
---|
[162] | 28 | int
|
---|
[492] | 29 | main(int argc, char **argv)
|
---|
[997] | 30 | {
|
---|
[991] | 31 |
|
---|
[997] | 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() {
|
---|
[570] | 37 | _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
|
---|
| 38 | _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE);
|
---|
| 39 | _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);
|
---|
[997] | 40 |
|
---|
| 41 | Debug.open("debug.log");
|
---|
[1004] | 42 |
|
---|
| 43 | Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH);
|
---|
[170] | 44 | MeshKdTree::ParseEnvironment();
|
---|
[997] | 45 |
|
---|
[409] | 46 | char buff[128];
|
---|
[1004] | 47 | Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff);
|
---|
[409] | 48 | string preprocessorType(buff);
|
---|
[997] | 49 |
|
---|
[1002] | 50 | Preprocessor *p = NULL;
|
---|
| 51 |
|
---|
| 52 |
|
---|
[464] | 53 | if (preprocessorType == "vss")
|
---|
[997] | 54 | {
|
---|
| 55 | p = new VssPreprocessor();
|
---|
[991] | 56 | }
|
---|
[464] | 57 | else
|
---|
[1002] | 58 | {
|
---|
[464] | 59 | if (preprocessorType == "rss")
|
---|
[1002] | 60 | {
|
---|
| 61 | p = new RssPreprocessor();
|
---|
| 62 | }
|
---|
[374] | 63 | else
|
---|
[1002] | 64 | {
|
---|
[464] | 65 | if (preprocessorType == "exact")
|
---|
[1002] | 66 | {
|
---|
[464] | 67 | p = new ExactPreprocessor();
|
---|
[1002] | 68 | }
|
---|
[446] | 69 | else
|
---|
[1002] | 70 | {
|
---|
[464] | 71 | if (preprocessorType == "sampling")
|
---|
[1002] | 72 | {
|
---|
[464] | 73 | p = new SamplingPreprocessor();
|
---|
[1002] | 74 | }
|
---|
[811] | 75 | else
|
---|
[1002] | 76 | {
|
---|
[811] | 77 | if (preprocessorType == "render")
|
---|
[991] | 78 | {
|
---|
[1002] | 79 | p = new RenderSampler();
|
---|
[991] | 80 | }
|
---|
[811] | 81 | else {
|
---|
[1004] | 82 | Environment::DelSingleton();
|
---|
[1002] | 83 | cerr<<"Unknown preprocessor type"<<endl;
|
---|
| 84 | Debug<<"Unknown preprocessor type"<<endl;
|
---|
| 85 | exit(1);
|
---|
[811] | 86 | }
|
---|
[1002] | 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
[811] | 91 |
|
---|
[997] | 92 | QApplication *app = NULL;
|
---|
[496] | 93 |
|
---|
[811] | 94 | if (p->mUseGlRenderer || p->mUseGlDebugger) {
|
---|
[997] | 95 |
|
---|
[496] | 96 | // create a qt application first (must be created before any opengl widget...
|
---|
[997] | 97 | app = new QApplication(argc, argv);
|
---|
| 98 |
|
---|
[496] | 99 | if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
|
---|
| 100 | QMessageBox::information(0, "OpenGL pbuffers",
|
---|
| 101 | "This system does not support OpenGL/pbuffers.",
|
---|
| 102 | QMessageBox::Ok);
|
---|
| 103 | return -1;
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
[997] | 106 |
|
---|
[492] | 107 | preprocessor = p;
|
---|
[464] | 108 |
|
---|
[1004] | 109 | Environment::GetSingleton()->GetStringValue("Scene.filename", buff);
|
---|
[492] | 110 | string filename(buff);
|
---|
[1076] | 111 |
|
---|
[492] | 112 | p->LoadScene(filename);
|
---|
| 113 |
|
---|
| 114 | p->BuildKdTree();
|
---|
| 115 | p->KdTreeStatistics(cout);
|
---|
[997] | 116 |
|
---|
[492] | 117 | // parse view cells related options
|
---|
| 118 | p->PrepareViewCells();
|
---|
| 119 |
|
---|
[997] | 120 |
|
---|
[492] | 121 | // create a preprocessor thread
|
---|
[556] | 122 | PreprocessorThread *pt = new PreprocessorThread(p, app);
|
---|
[492] | 123 |
|
---|
[162] | 124 | // p->mSceneGraph->Export("soda.x3d");
|
---|
[176] | 125 | if (0) {
|
---|
[242] | 126 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
[263] | 127 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
[170] | 128 | }
|
---|
[997] | 129 |
|
---|
[492] | 130 | if (p->mUseGlRenderer) {
|
---|
[997] | 131 |
|
---|
[556] | 132 | rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
|
---|
[492] | 133 | // renderer->resize(640, 480);
|
---|
[997] | 134 |
|
---|
[496] | 135 | rendererWidget->resize(640, 480);
|
---|
| 136 | rendererWidget->show();
|
---|
[997] | 137 |
|
---|
[746] | 138 | if (p->GetRenderer()) {
|
---|
[811] | 139 |
|
---|
[746] | 140 | cout<<"CONNECTING"<<endl;
|
---|
| 141 | QObject::connect(p->GetRenderer(),
|
---|
| 142 | SIGNAL(UpdatePvsErrorItem(int i,
|
---|
| 143 | GlRendererBuffer::PvsErrorEntry &)),
|
---|
[811] | 144 |
|
---|
[746] | 145 | rendererWidget->mControlWidget,
|
---|
| 146 | SLOT(UpdatePvsErrorItem(int i,
|
---|
| 147 | GlRendererBuffer::PvsErrorEntry &)));
|
---|
| 148 | cout<<"CONNECTED"<<endl;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
[492] | 151 | pt->start(QThread::LowPriority);
|
---|
[746] | 152 |
|
---|
| 153 |
|
---|
[556] | 154 | } else{
|
---|
[492] | 155 | // just call the mail method -> will be executed in the main thread
|
---|
| 156 | pt->Main();
|
---|
[170] | 157 | }
|
---|
[492] | 158 |
|
---|
[878] | 159 |
|
---|
[1001] | 160 | int returnCode = 0;
|
---|
| 161 |
|
---|
[878] | 162 | if (app)
|
---|
[1005] | 163 | {
|
---|
[1001] | 164 | returnCode = app->exec();
|
---|
[1005] | 165 | DEL_PTR(app);
|
---|
| 166 | }
|
---|
[878] | 167 |
|
---|
[1002] | 168 | //-- clean up
|
---|
[840] | 169 | DEL_PTR(p);
|
---|
[1004] | 170 | Environment::DelSingleton();
|
---|
[1005] | 171 | DEL_PTR(rendererWidget);
|
---|
[1002] | 172 |
|
---|
[1001] | 173 | MeshManager::DelSingleton();
|
---|
| 174 | MaterialManager::DelSingleton();
|
---|
[840] | 175 |
|
---|
[1002] | 176 | DEL_PTR(pt);
|
---|
[1001] | 177 |
|
---|
| 178 | return returnCode;
|
---|
[162] | 179 | }
|
---|
| 180 |
|
---|