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

Revision 991, 4.3 KB checked in by mattausch, 18 years ago (diff)
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"
[292]12#include "X3dExporter.h" // delete later
[310]13#include "ViewCell.h"
[321]14#include "SceneGraph.h"
[492]15#include "PreprocessorThread.h"
[878]16#include "RenderSampler.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)
[991]30{QApplication *app = new QApplication(argc, argv);
31
32        cout << "here222237" << endl;
[570]33//Now just call this function at the start of your program and if you're
34//compiling in debug mode (F5), any leaks will be displayed in the Output
35//window when the program shuts down. If you're not in debug mode this will
36//be ignored. Use it as you will!
37//note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() {
38    _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
39    _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE);
40    _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);
[991]41cout << "here3" << endl;
42  Debug.open("debug.log");cout << "here2" << endl;
[162]43  environment = new Environment;
[991]44  cout << "here122223" << endl; cout.flush();
[162]45  environment->Parse(argc, argv, USE_EXE_PATH);
[170]46  MeshKdTree::ParseEnvironment();
[991]47cout << "here222283" << endl;
[409]48  char buff[128];
49  environment->GetStringValue("Preprocessor.type", buff);
50  string preprocessorType(buff);
[374]51       
52  Preprocessor *p;
[991]53cout << "here22223" << endl;
[464]54  if (preprocessorType == "vss")
[991]55  {cout << "here223" << endl;
[464]56        p = new VssPreprocessor();
[991]57  }
[464]58  else
59        if (preprocessorType == "rss")
60          p = new RssPreprocessor();
[374]61        else
[464]62          if (preprocessorType == "exact")
63                p = new ExactPreprocessor();
[446]64          else
[464]65                if (preprocessorType == "sampling")
66                  p = new SamplingPreprocessor();
[811]67                else
68                  if (preprocessorType == "render")
[991]69                  {
70                          cout << "here23" << endl;
[871]71                        p = new RenderSampler();
[991]72                  }
[811]73                  else {
74                        cerr<<"Unknown preprocessor type"<<endl;
75                        Debug<<"Unknown preprocessor type"<<endl;
76                        exit(1);
77                  }
78 
[991]79 
80  //QApplication *app = NULL;
[496]81
[811]82  if (p->mUseGlRenderer || p->mUseGlDebugger) {
[991]83          cout << "here1111" << endl;
[496]84        // create a qt application first (must be created before any opengl widget...
[991]85        //app = new QApplication(argc, argv);
86          cout << "here1112" << endl;
[496]87        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
[991]88                cout << "here1133" << endl;cout.flush();
[496]89          QMessageBox::information(0, "OpenGL pbuffers",
90                                                           "This system does not support OpenGL/pbuffers.",
91                                                           QMessageBox::Ok);
92          return -1;
93        }
[991]94          cout << "here1119" << endl;
[496]95  }
[991]96   cout << "here1123" << endl;
[492]97  preprocessor = p;
[464]98 
[492]99  environment->GetStringValue("Scene.filename", buff);
100  string filename(buff);
101  p->LoadScene(filename);
102 
103  p->BuildKdTree();
104  p->KdTreeStatistics(cout);
[991]105   cout << "here1199" << endl;
[492]106  // parse view cells related options
107  p->PrepareViewCells();
108 
[991]109 cout << "here1117" << endl;
[492]110  // create a preprocessor thread
[556]111  PreprocessorThread *pt = new PreprocessorThread(p, app);
[492]112
[162]113  //  p->mSceneGraph->Export("soda.x3d");
[176]114  if (0) {
[242]115    p->Export(filename + "-out.x3d", true, false, false);
[263]116    p->Export(filename + "-kdtree.x3d", false, true, false);   
[170]117  }
[991]118 cout << "here1118" << endl;
[492]119  if (p->mUseGlRenderer) {
[991]120          cout << "here1114" << endl;
[556]121        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
[492]122        //  renderer->resize(640, 480);
[991]123         cout << "here1115" << endl;
[496]124        rendererWidget->resize(640, 480);
125        rendererWidget->show();
[991]126          cout << "here1113" << endl;
[746]127        if (p->GetRenderer()) {
[811]128         
[746]129          cout<<"CONNECTING"<<endl;
130          QObject::connect(p->GetRenderer(),
131                                           SIGNAL(UpdatePvsErrorItem(int i,
132                                                                                                 GlRendererBuffer::PvsErrorEntry &)),
[811]133
[746]134                                           rendererWidget->mControlWidget,
135                                           SLOT(UpdatePvsErrorItem(int i,
136                                                                                           GlRendererBuffer::PvsErrorEntry &)));
137          cout<<"CONNECTED"<<endl;
138        }
139       
[492]140        pt->start(QThread::LowPriority);
[746]141       
142       
[556]143  } else{
[492]144        // just call the mail method -> will be executed in the main thread
145        pt->Main();
[170]146  }
[492]147 
[878]148
149  if (app)
150        return app->exec();
151
[261]152  // clean up
[840]153  DEL_PTR(p);
154  DEL_PTR(environment);
155
[162]156  return 0;
157}
158
Note: See TracBrowser for help on using the repository browser.