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

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