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

Revision 1076, 4.1 KB checked in by mattausch, 18 years ago (diff)

version for performance testing

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 "ViewCell.h"
13#include "SceneGraph.h"
14#include "PreprocessorThread.h"
15#include "RenderSampler.h"
16#include "ResourceManager.h"
17
18#include <QApplication>
19#include <QtOpenGL>
20#include "GlRenderer.h"
21
22#define USE_EXE_PATH false
23
24#include <crtdbg.h>
25
26using namespace GtpVisibilityPreprocessor;
27
28int
29main(int argc, char **argv)
30{
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
41  Debug.open("debug.log");
42 
43  Environment::GetSingleton()->Parse(argc, argv, USE_EXE_PATH);
44  MeshKdTree::ParseEnvironment();
45
46  char buff[128];
47  Environment::GetSingleton()->GetStringValue("Preprocessor.type", buff);
48  string preprocessorType(buff);
49
50  Preprocessor *p = NULL;
51
52 
53  if (preprocessorType == "vss")
54  {
55          p = new VssPreprocessor();
56  }
57  else
58  {
59        if (preprocessorType == "rss")
60        {
61                p = new RssPreprocessor();
62        }
63        else
64        {
65          if (preprocessorType == "exact")
66          {
67                p = new ExactPreprocessor();
68          }
69          else
70          {
71                if (preprocessorType == "sampling")
72                {
73                  p = new SamplingPreprocessor();
74                }
75                else
76                {       
77                  if (preprocessorType == "render")
78                  {
79                         p = new RenderSampler();
80                  }
81                  else {
82                          Environment::DelSingleton();
83                          cerr<<"Unknown preprocessor type"<<endl;
84                          Debug<<"Unknown preprocessor type"<<endl;
85                          exit(1);
86                  }
87                }
88          }
89        }
90  }
91 
92  QApplication *app = NULL;
93
94  if (p->mUseGlRenderer || p->mUseGlDebugger) {
95       
96        // create a qt application first (must be created before any opengl widget...
97        app = new QApplication(argc, argv);
98       
99        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
100          QMessageBox::information(0, "OpenGL pbuffers",
101                                                           "This system does not support OpenGL/pbuffers.",
102                                                           QMessageBox::Ok);
103          return -1;
104        }
105  }
106 
107  preprocessor = p;
108 
109  Environment::GetSingleton()->GetStringValue("Scene.filename", buff);
110  string filename(buff);
111 
112  p->LoadScene(filename);
113 
114  p->BuildKdTree();
115  p->KdTreeStatistics(cout);
116 
117  // parse view cells related options
118  p->PrepareViewCells();
119 
120
121  // create a preprocessor thread
122  PreprocessorThread *pt = new PreprocessorThread(p, app);
123
124  //  p->mSceneGraph->Export("soda.x3d");
125  if (0) {
126    p->Export(filename + "-out.x3d", true, false, false);
127    p->Export(filename + "-kdtree.x3d", false, true, false);   
128  }
129
130  if (p->mUseGlRenderer) {
131         
132        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
133        //  renderer->resize(640, 480);
134         
135        rendererWidget->resize(640, 480);
136        rendererWidget->show();
137       
138        if (p->GetRenderer()) {
139         
140          cout<<"CONNECTING"<<endl;
141          QObject::connect(p->GetRenderer(),
142                                           SIGNAL(UpdatePvsErrorItem(int i,
143                                                                                                 GlRendererBuffer::PvsErrorEntry &)),
144
145                                           rendererWidget->mControlWidget,
146                                           SLOT(UpdatePvsErrorItem(int i,
147                                                                                           GlRendererBuffer::PvsErrorEntry &)));
148          cout<<"CONNECTED"<<endl;
149        }
150       
151        pt->start(QThread::LowPriority);
152       
153       
154  } else{
155        // just call the mail method -> will be executed in the main thread
156        pt->Main();
157  }
158 
159
160  int returnCode = 0;
161
162  if (app)
163  {
164         returnCode = app->exec();
165        DEL_PTR(app);
166        }
167
168  //-- clean up
169  DEL_PTR(p);
170  Environment::DelSingleton();
171  DEL_PTR(rendererWidget);
172
173  MeshManager::DelSingleton();
174  MaterialManager::DelSingleton();
175
176  DEL_PTR(pt);
177
178  return returnCode;
179}
180
Note: See TracBrowser for help on using the repository browser.