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

Revision 1001, 3.9 KB checked in by mattausch, 18 years ago (diff)

added mesh instance support
improved support for occlusion queries + other extensions

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#include "RenderSampler.h"
17#include "ResourceManager.h"
18
19#include <QApplication>
20#include <QtOpenGL>
21#include "GlRenderer.h"
22
23#define USE_EXE_PATH false
24
25#include <crtdbg.h>
26
27using namespace GtpVisibilityPreprocessor;
28
29int
30main(int argc, char **argv)
31{
32
33        //Now just call this function at the start of your program and if you're
34        //compiling in debug mode (F5), any leaks will be displayed in the Output
35        //window when the program shuts down. If you're not in debug mode this will
36        //be ignored. Use it as you will!
37        //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() {
38    _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
39    _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE);
40    _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);
41
42  Debug.open("debug.log");
43  environment = new Environment;
44 
45  environment->Parse(argc, argv, USE_EXE_PATH);
46  MeshKdTree::ParseEnvironment();
47
48  char buff[128];
49  environment->GetStringValue("Preprocessor.type", buff);
50  string preprocessorType(buff);
51       
52  Preprocessor *p;
53
54  if (preprocessorType == "vss")
55  {
56          p = new VssPreprocessor();
57  }
58  else
59        if (preprocessorType == "rss")
60          p = new RssPreprocessor();
61        else
62          if (preprocessorType == "exact")
63                p = new ExactPreprocessor();
64          else
65                if (preprocessorType == "sampling")
66                  p = new SamplingPreprocessor();
67                else
68                  if (preprocessorType == "render")
69                  {
70                          p = new RenderSampler();
71                  }
72                  else {
73                        cerr<<"Unknown preprocessor type"<<endl;
74                        Debug<<"Unknown preprocessor type"<<endl;
75                        exit(1);
76                  }
77 
78 
79  QApplication *app = NULL;
80
81  if (p->mUseGlRenderer || p->mUseGlDebugger) {
82       
83        // create a qt application first (must be created before any opengl widget...
84        app = new QApplication(argc, argv);
85       
86        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
87          QMessageBox::information(0, "OpenGL pbuffers",
88                                                           "This system does not support OpenGL/pbuffers.",
89                                                           QMessageBox::Ok);
90          return -1;
91        }
92  }
93 
94  preprocessor = p;
95 
96  environment->GetStringValue("Scene.filename", buff);
97  string filename(buff);
98  p->LoadScene(filename);
99 
100  p->BuildKdTree();
101  p->KdTreeStatistics(cout);
102 
103  // parse view cells related options
104  p->PrepareViewCells();
105 
106
107  // create a preprocessor thread
108  PreprocessorThread *pt = new PreprocessorThread(p, app);
109
110  //  p->mSceneGraph->Export("soda.x3d");
111  if (0) {
112    p->Export(filename + "-out.x3d", true, false, false);
113    p->Export(filename + "-kdtree.x3d", false, true, false);   
114  }
115
116  if (p->mUseGlRenderer) {
117         
118        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
119        //  renderer->resize(640, 480);
120         
121        rendererWidget->resize(640, 480);
122        rendererWidget->show();
123       
124        if (p->GetRenderer()) {
125         
126          cout<<"CONNECTING"<<endl;
127          QObject::connect(p->GetRenderer(),
128                                           SIGNAL(UpdatePvsErrorItem(int i,
129                                                                                                 GlRendererBuffer::PvsErrorEntry &)),
130
131                                           rendererWidget->mControlWidget,
132                                           SLOT(UpdatePvsErrorItem(int i,
133                                                                                           GlRendererBuffer::PvsErrorEntry &)));
134          cout<<"CONNECTED"<<endl;
135        }
136       
137        pt->start(QThread::LowPriority);
138       
139       
140  } else{
141        // just call the mail method -> will be executed in the main thread
142        pt->Main();
143  }
144 
145
146  int returnCode = 0;
147
148  if (app)
149         returnCode = app->exec();
150
151   // clean up
152  DEL_PTR(p);
153  DEL_PTR(environment);
154  MeshManager::DelSingleton();
155  MaterialManager::DelSingleton();
156
157
158  return returnCode;
159}
160
Note: See TracBrowser for help on using the repository browser.