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