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

Revision 693, 3.2 KB checked in by mattausch, 18 years ago (diff)
Line 
1#include "SamplingPreprocessor.h"
2#include "VssPreprocessor.h"
3#include "RssPreprocessor.h"
4#include "ExactPreprocessor.h"
5#include "Parser.h"
6#include "UnigraphicsParser.h"
7#include "X3dParser.h"
8#include "Environment.h"
9#include "Camera.h"
10#include "MeshKdTree.h"
11#include "Exporter.h"
12#include "X3dExporter.h" // delete later
13#include "ViewCell.h"
14#include "SceneGraph.h"
15#include "PreprocessorThread.h"
16
17#include <QApplication>
18#include <QtOpenGL>
19#include "GlRenderer.h"
20
21#define USE_EXE_PATH false
22
23#include <crtdbg.h>
24
25
26
27int
28main(int argc, char **argv)
29{
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
40  Debug.open("debug.log");
41  environment = new Environment;
42  environment->Parse(argc, argv, USE_EXE_PATH);
43  MeshKdTree::ParseEnvironment();
44
45  char buff[128];
46  environment->GetStringValue("Preprocessor.type", buff);
47  string preprocessorType(buff);
48       
49  Preprocessor *p;
50
51  if (preprocessorType == "vss")
52        p = new VssPreprocessor();
53  else
54        if (preprocessorType == "rss")
55          p = new RssPreprocessor();
56        else
57          if (preprocessorType == "exact")
58                p = new ExactPreprocessor();
59          else
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                }
67
68
69  QApplication *app = NULL;
70
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 
83  preprocessor = p;
84 
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 
95
96  // create a preprocessor thread
97  PreprocessorThread *pt = new PreprocessorThread(p, app);
98
99  //  p->mSceneGraph->Export("soda.x3d");
100  if (0) {
101    p->Export(filename + "-out.x3d", true, false, false);
102    p->Export(filename + "-kdtree.x3d", false, true, false);   
103  }
104
105  if (p->mUseGlRenderer) {
106       
107        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
108        //  renderer->resize(640, 480);
109        rendererWidget->resize(640, 480);
110        rendererWidget->show();
111        pt->start(QThread::LowPriority);
112  } else{
113        // just call the mail method -> will be executed in the main thread
114        pt->Main();
115  }
116 
117  // clean up
118  //  DEL_PTR(p);
119  //  DEL_PTR(environment);
120  if (app)
121        return app->exec();
122 
123  return 0;
124}
125
Note: See TracBrowser for help on using the repository browser.