source: trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp @ 496

Revision 496, 2.6 KB checked in by bittner, 19 years ago (diff)

glrenderer split into widget and buffer, buffer moved to the same thread as the preprocessor

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"
[162]16
[492]17#include <QApplication>
18#include <QtOpenGL>
19#include "GlRenderer.h"
20
[162]21#define USE_EXE_PATH false
22
[372]23
[492]24
25
26
[162]27int
[492]28main(int argc, char **argv)
[162]29{
30  Debug.open("debug.log");
31  environment = new Environment;
32  environment->Parse(argc, argv, USE_EXE_PATH);
[170]33  MeshKdTree::ParseEnvironment();
[492]34 
[409]35  char buff[128];
36  environment->GetStringValue("Preprocessor.type", buff);
37  string preprocessorType(buff);
[374]38       
39  Preprocessor *p;
40
[464]41  if (preprocessorType == "vss")
42        p = new VssPreprocessor();
43  else
44        if (preprocessorType == "rss")
45          p = new RssPreprocessor();
[374]46        else
[464]47          if (preprocessorType == "exact")
48                p = new ExactPreprocessor();
[446]49          else
[464]50                if (preprocessorType == "sampling")
51                  p = new SamplingPreprocessor();
52                else {
53                  cerr<<"Unknown preprocessor type"<<endl;
54                  Debug<<"Unknown preprocessor type"<<endl;
55                  exit(1);
56                }
[496]57
58  QApplication *app = NULL;
[464]59 
[496]60  if (p->mUseGlRenderer) {
61        // create a qt application first (must be created before any opengl widget...
62        app = new QApplication(argc, argv);
63       
64        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
65          QMessageBox::information(0, "OpenGL pbuffers",
66                                                           "This system does not support OpenGL/pbuffers.",
67                                                           QMessageBox::Ok);
68          return -1;
69        }
70  }
71 
[492]72  preprocessor = p;
[464]73 
[492]74  environment->GetStringValue("Scene.filename", buff);
75  string filename(buff);
76  p->LoadScene(filename);
77 
78  p->BuildKdTree();
79  p->KdTreeStatistics(cout);
80 
81  // parse view cells related options
82  p->PrepareViewCells();
83 
[260]84
[492]85  // create a preprocessor thread
86  PreprocessorThread *pt = new PreprocessorThread(p);
87
[162]88  //  p->mSceneGraph->Export("soda.x3d");
[176]89  if (0) {
[242]90    p->Export(filename + "-out.x3d", true, false, false);
[263]91    p->Export(filename + "-kdtree.x3d", false, true, false);   
[170]92  }
[235]93
[492]94  if (p->mUseGlRenderer) {
95       
[496]96        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager);
[492]97        //  renderer->resize(640, 480);
[496]98        rendererWidget->resize(640, 480);
99        rendererWidget->show();
100
[492]101        pt->start(QThread::LowPriority);
102       
103  } else {
104        // just call the mail method -> will be executed in the main thread
105        pt->Main();
[170]106  }
[492]107 
[261]108  // clean up
[492]109  //  DEL_PTR(p);
110  //  DEL_PTR(environment);
[496]111  if (app)
112        return app->exec();
[261]113
[162]114  return 0;
115}
116
Note: See TracBrowser for help on using the repository browser.