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