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

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

fixed bug for histogram
improved samplerenderer
todo: difference detectempty true / false

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