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

Revision 840, 3.7 KB checked in by mattausch, 18 years ago (diff)

implementing bounding box hack

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"
[822]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
[492]26
27
[162]28int
[492]29main(int argc, char **argv)
[162]30{
[570]31       
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);
40
[162]41  Debug.open("debug.log");
42  environment = new Environment;
43  environment->Parse(argc, argv, USE_EXE_PATH);
[170]44  MeshKdTree::ParseEnvironment();
[693]45
[409]46  char buff[128];
47  environment->GetStringValue("Preprocessor.type", buff);
48  string preprocessorType(buff);
[374]49       
50  Preprocessor *p;
51
[464]52  if (preprocessorType == "vss")
53        p = new VssPreprocessor();
54  else
55        if (preprocessorType == "rss")
56          p = new RssPreprocessor();
[374]57        else
[464]58          if (preprocessorType == "exact")
59                p = new ExactPreprocessor();
[446]60          else
[464]61                if (preprocessorType == "sampling")
62                  p = new SamplingPreprocessor();
[811]63                else
64                  if (preprocessorType == "render")
[822]65;//                     p = new RenderSampler();
[811]66                  else {
67                        cerr<<"Unknown preprocessor type"<<endl;
68                        Debug<<"Unknown preprocessor type"<<endl;
69                        exit(1);
70                  }
71 
[496]72
73  QApplication *app = NULL;
[574]74
[811]75  if (p->mUseGlRenderer || p->mUseGlDebugger) {
[496]76        // create a qt application first (must be created before any opengl widget...
77        app = new QApplication(argc, argv);
78       
79        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
80          QMessageBox::information(0, "OpenGL pbuffers",
81                                                           "This system does not support OpenGL/pbuffers.",
82                                                           QMessageBox::Ok);
83          return -1;
84        }
85  }
86 
[492]87  preprocessor = p;
[464]88 
[492]89  environment->GetStringValue("Scene.filename", buff);
90  string filename(buff);
91  p->LoadScene(filename);
92 
93  p->BuildKdTree();
94  p->KdTreeStatistics(cout);
95 
96  // parse view cells related options
97  p->PrepareViewCells();
98 
[260]99
[492]100  // create a preprocessor thread
[556]101  PreprocessorThread *pt = new PreprocessorThread(p, app);
[492]102
[162]103  //  p->mSceneGraph->Export("soda.x3d");
[176]104  if (0) {
[242]105    p->Export(filename + "-out.x3d", true, false, false);
[263]106    p->Export(filename + "-kdtree.x3d", false, true, false);   
[170]107  }
[235]108
[492]109  if (p->mUseGlRenderer) {
110       
[556]111        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
[492]112        //  renderer->resize(640, 480);
[496]113        rendererWidget->resize(640, 480);
114        rendererWidget->show();
[811]115       
[746]116        if (p->GetRenderer()) {
[811]117         
[746]118          cout<<"CONNECTING"<<endl;
119          QObject::connect(p->GetRenderer(),
120                                           SIGNAL(UpdatePvsErrorItem(int i,
121                                                                                                 GlRendererBuffer::PvsErrorEntry &)),
[811]122
[746]123                                           rendererWidget->mControlWidget,
124                                           SLOT(UpdatePvsErrorItem(int i,
125                                                                                           GlRendererBuffer::PvsErrorEntry &)));
126          cout<<"CONNECTED"<<endl;
127        }
128       
[492]129        pt->start(QThread::LowPriority);
[746]130       
131       
[556]132  } else{
[492]133        // just call the mail method -> will be executed in the main thread
134        pt->Main();
[170]135  }
[492]136 
[261]137  // clean up
[840]138  DEL_PTR(p);
139  DEL_PTR(environment);
140
[496]141  if (app)
142        return app->exec();
[556]143 
[162]144  return 0;
145}
146
Note: See TracBrowser for help on using the repository browser.