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 |
|
---|
26 | using namespace GtpVisibilityPreprocessor;
|
---|
27 |
|
---|
28 | int
|
---|
29 | main(int argc, char **argv)
|
---|
30 | {QApplication *app = new QApplication(argc, argv);
|
---|
31 |
|
---|
32 | cout << "here222237" << endl;
|
---|
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 | cout << "here3" << endl;
|
---|
42 | Debug.open("debug.log");cout << "here2" << endl;
|
---|
43 | environment = new Environment;
|
---|
44 | cout << "here122223" << endl; cout.flush();
|
---|
45 | environment->Parse(argc, argv, USE_EXE_PATH);
|
---|
46 | MeshKdTree::ParseEnvironment();
|
---|
47 | cout << "here222283" << endl;
|
---|
48 | char buff[128];
|
---|
49 | environment->GetStringValue("Preprocessor.type", buff);
|
---|
50 | string preprocessorType(buff);
|
---|
51 |
|
---|
52 | Preprocessor *p;
|
---|
53 | cout << "here22223" << endl;
|
---|
54 | if (preprocessorType == "vss")
|
---|
55 | {cout << "here223" << endl;
|
---|
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 | cout << "here23" << endl;
|
---|
71 | p = new RenderSampler();
|
---|
72 | }
|
---|
73 | else {
|
---|
74 | cerr<<"Unknown preprocessor type"<<endl;
|
---|
75 | Debug<<"Unknown preprocessor type"<<endl;
|
---|
76 | exit(1);
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | //QApplication *app = NULL;
|
---|
81 |
|
---|
82 | if (p->mUseGlRenderer || p->mUseGlDebugger) {
|
---|
83 | cout << "here1111" << endl;
|
---|
84 | // create a qt application first (must be created before any opengl widget...
|
---|
85 | //app = new QApplication(argc, argv);
|
---|
86 | cout << "here1112" << endl;
|
---|
87 | if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
|
---|
88 | cout << "here1133" << endl;cout.flush();
|
---|
89 | QMessageBox::information(0, "OpenGL pbuffers",
|
---|
90 | "This system does not support OpenGL/pbuffers.",
|
---|
91 | QMessageBox::Ok);
|
---|
92 | return -1;
|
---|
93 | }
|
---|
94 | cout << "here1119" << endl;
|
---|
95 | }
|
---|
96 | cout << "here1123" << endl;
|
---|
97 | preprocessor = p;
|
---|
98 |
|
---|
99 | environment->GetStringValue("Scene.filename", buff);
|
---|
100 | string filename(buff);
|
---|
101 | p->LoadScene(filename);
|
---|
102 |
|
---|
103 | p->BuildKdTree();
|
---|
104 | p->KdTreeStatistics(cout);
|
---|
105 | cout << "here1199" << endl;
|
---|
106 | // parse view cells related options
|
---|
107 | p->PrepareViewCells();
|
---|
108 |
|
---|
109 | cout << "here1117" << endl;
|
---|
110 | // create a preprocessor thread
|
---|
111 | PreprocessorThread *pt = new PreprocessorThread(p, app);
|
---|
112 |
|
---|
113 | // p->mSceneGraph->Export("soda.x3d");
|
---|
114 | if (0) {
|
---|
115 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
116 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
117 | }
|
---|
118 | cout << "here1118" << endl;
|
---|
119 | if (p->mUseGlRenderer) {
|
---|
120 | cout << "here1114" << endl;
|
---|
121 | rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
|
---|
122 | // renderer->resize(640, 480);
|
---|
123 | cout << "here1115" << endl;
|
---|
124 | rendererWidget->resize(640, 480);
|
---|
125 | rendererWidget->show();
|
---|
126 | cout << "here1113" << endl;
|
---|
127 | if (p->GetRenderer()) {
|
---|
128 |
|
---|
129 | cout<<"CONNECTING"<<endl;
|
---|
130 | QObject::connect(p->GetRenderer(),
|
---|
131 | SIGNAL(UpdatePvsErrorItem(int i,
|
---|
132 | GlRendererBuffer::PvsErrorEntry &)),
|
---|
133 |
|
---|
134 | rendererWidget->mControlWidget,
|
---|
135 | SLOT(UpdatePvsErrorItem(int i,
|
---|
136 | GlRendererBuffer::PvsErrorEntry &)));
|
---|
137 | cout<<"CONNECTED"<<endl;
|
---|
138 | }
|
---|
139 |
|
---|
140 | pt->start(QThread::LowPriority);
|
---|
141 |
|
---|
142 |
|
---|
143 | } else{
|
---|
144 | // just call the mail method -> will be executed in the main thread
|
---|
145 | pt->Main();
|
---|
146 | }
|
---|
147 |
|
---|
148 |
|
---|
149 | if (app)
|
---|
150 | return app->exec();
|
---|
151 |
|
---|
152 | // clean up
|
---|
153 | DEL_PTR(p);
|
---|
154 | DEL_PTR(environment);
|
---|
155 |
|
---|
156 | return 0;
|
---|
157 | }
|
---|
158 |
|
---|