source: GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp @ 1112

Revision 1112, 4.1 KB checked in by bittner, 18 years ago (diff)

Merge with Olivers code

RevLine 
[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]26using namespace GtpVisibilityPreprocessor;
[492]27
[162]28int
[492]29main(int argc, char **argv)
[997]30{
[991]31
[1112]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);
[997]40
[1112]41  InitTiming();
42
[997]43  Debug.open("debug.log");
[1004]44 
45  Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH);
[170]46  MeshKdTree::ParseEnvironment();
[997]47
[409]48  char buff[128];
[1004]49  Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff);
[409]50  string preprocessorType(buff);
[997]51
[1002]52  Preprocessor *p = NULL;
53
54 
[464]55  if (preprocessorType == "vss")
[997]56  {
57          p = new VssPreprocessor();
[991]58  }
[464]59  else
[1002]60  {
[464]61        if (preprocessorType == "rss")
[1002]62        {
63                p = new RssPreprocessor();
64        }
[374]65        else
[1002]66        {
[464]67          if (preprocessorType == "exact")
[1002]68          {
[464]69                p = new ExactPreprocessor();
[1002]70          }
[446]71          else
[1002]72          {
[464]73                if (preprocessorType == "sampling")
[1002]74                {
[464]75                  p = new SamplingPreprocessor();
[1002]76                }
[811]77                else
[1002]78                {       
[811]79                  if (preprocessorType == "render")
[991]80                  {
[1002]81                         p = new RenderSampler();
[991]82                  }
[811]83                  else {
[1004]84                          Environment::DelSingleton();
[1002]85                          cerr<<"Unknown preprocessor type"<<endl;
86                          Debug<<"Unknown preprocessor type"<<endl;
87                          exit(1);
[811]88                  }
[1002]89                }
90          }
91        }
92  }
[811]93 
[997]94  QApplication *app = NULL;
[496]95
[811]96  if (p->mUseGlRenderer || p->mUseGlDebugger) {
[997]97       
[496]98        // create a qt application first (must be created before any opengl widget...
[997]99        app = new QApplication(argc, argv);
100       
[496]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  }
[997]108 
[492]109  preprocessor = p;
[464]110 
[1004]111  Environment::GetSingleton()->GetStringValue("Scene.filename", buff);
[492]112  string filename(buff);
[1076]113 
[492]114  p->LoadScene(filename);
115 
116  p->BuildKdTree();
117  p->KdTreeStatistics(cout);
[997]118 
[492]119  // parse view cells related options
120  p->PrepareViewCells();
121 
[997]122
[492]123  // create a preprocessor thread
[556]124  PreprocessorThread *pt = new PreprocessorThread(p, app);
[492]125
[162]126  //  p->mSceneGraph->Export("soda.x3d");
[176]127  if (0) {
[242]128    p->Export(filename + "-out.x3d", true, false, false);
[263]129    p->Export(filename + "-kdtree.x3d", false, true, false);   
[170]130  }
[997]131
[492]132  if (p->mUseGlRenderer) {
[997]133         
[556]134        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
[492]135        //  renderer->resize(640, 480);
[997]136         
[496]137        rendererWidget->resize(640, 480);
138        rendererWidget->show();
[997]139       
[1112]140        if (0 && p->GetRenderer()) {
[811]141         
[746]142          cout<<"CONNECTING"<<endl;
143          QObject::connect(p->GetRenderer(),
144                                           SIGNAL(UpdatePvsErrorItem(int i,
145                                                                                                 GlRendererBuffer::PvsErrorEntry &)),
[1112]146                                           
[746]147                                           rendererWidget->mControlWidget,
148                                           SLOT(UpdatePvsErrorItem(int i,
149                                                                                           GlRendererBuffer::PvsErrorEntry &)));
150          cout<<"CONNECTED"<<endl;
151        }
152       
[492]153        pt->start(QThread::LowPriority);
[746]154       
155       
[556]156  } else{
[492]157        // just call the mail method -> will be executed in the main thread
158        pt->Main();
[170]159  }
[492]160 
[878]161
[1001]162  int returnCode = 0;
163
[878]164  if (app)
[1005]165  {
[1001]166         returnCode = app->exec();
[1005]167        DEL_PTR(app);
168        }
[878]169
[1002]170  //-- clean up
[840]171  DEL_PTR(p);
[1004]172  Environment::DelSingleton();
[1005]173  DEL_PTR(rendererWidget);
[1002]174
[1001]175  MeshManager::DelSingleton();
176  MaterialManager::DelSingleton();
[840]177
[1002]178  DEL_PTR(pt);
[1001]179
180  return returnCode;
[162]181}
182
Note: See TracBrowser for help on using the repository browser.