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 |
|
---|
17 | #include <QApplication>
|
---|
18 | #include <QtOpenGL>
|
---|
19 | #include "GlRenderer.h"
|
---|
20 |
|
---|
21 | #define USE_EXE_PATH false
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 | int
|
---|
28 | main(int argc, char **argv)
|
---|
29 | {
|
---|
30 | Debug.open("debug.log");
|
---|
31 | environment = new Environment;
|
---|
32 | environment->Parse(argc, argv, USE_EXE_PATH);
|
---|
33 | MeshKdTree::ParseEnvironment();
|
---|
34 |
|
---|
35 | char buff[128];
|
---|
36 | environment->GetStringValue("Preprocessor.type", buff);
|
---|
37 | string preprocessorType(buff);
|
---|
38 |
|
---|
39 | Preprocessor *p;
|
---|
40 |
|
---|
41 | if (preprocessorType == "vss")
|
---|
42 | p = new VssPreprocessor();
|
---|
43 | else
|
---|
44 | if (preprocessorType == "rss")
|
---|
45 | p = new RssPreprocessor();
|
---|
46 | else
|
---|
47 | if (preprocessorType == "exact")
|
---|
48 | p = new ExactPreprocessor();
|
---|
49 | else
|
---|
50 | if (preprocessorType == "sampling")
|
---|
51 | p = new SamplingPreprocessor();
|
---|
52 | else {
|
---|
53 | cerr<<"Unknown preprocessor type"<<endl;
|
---|
54 | Debug<<"Unknown preprocessor type"<<endl;
|
---|
55 | exit(1);
|
---|
56 | }
|
---|
57 |
|
---|
58 | QApplication *app = NULL;
|
---|
59 |
|
---|
60 | if (p->mUseGlRenderer) {
|
---|
61 | // create a qt application first (must be created before any opengl widget...
|
---|
62 | app = new QApplication(argc, argv);
|
---|
63 |
|
---|
64 | if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
|
---|
65 | QMessageBox::information(0, "OpenGL pbuffers",
|
---|
66 | "This system does not support OpenGL/pbuffers.",
|
---|
67 | QMessageBox::Ok);
|
---|
68 | return -1;
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | preprocessor = p;
|
---|
73 |
|
---|
74 | environment->GetStringValue("Scene.filename", buff);
|
---|
75 | string filename(buff);
|
---|
76 | p->LoadScene(filename);
|
---|
77 |
|
---|
78 | p->BuildKdTree();
|
---|
79 | p->KdTreeStatistics(cout);
|
---|
80 |
|
---|
81 | // parse view cells related options
|
---|
82 | p->PrepareViewCells();
|
---|
83 |
|
---|
84 |
|
---|
85 | // create a preprocessor thread
|
---|
86 | PreprocessorThread *pt = new PreprocessorThread(p);
|
---|
87 |
|
---|
88 | // p->mSceneGraph->Export("soda.x3d");
|
---|
89 | if (0) {
|
---|
90 | p->Export(filename + "-out.x3d", true, false, false);
|
---|
91 | p->Export(filename + "-kdtree.x3d", false, true, false);
|
---|
92 | }
|
---|
93 |
|
---|
94 | if (p->mUseGlRenderer) {
|
---|
95 |
|
---|
96 | rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
|
---|
97 | // renderer->resize(640, 480);
|
---|
98 | rendererWidget->resize(640, 480);
|
---|
99 | rendererWidget->show();
|
---|
100 |
|
---|
101 | pt->start(QThread::LowPriority);
|
---|
102 |
|
---|
103 | } else {
|
---|
104 | // just call the mail method -> will be executed in the main thread
|
---|
105 | pt->Main();
|
---|
106 | }
|
---|
107 |
|
---|
108 | // clean up
|
---|
109 | // DEL_PTR(p);
|
---|
110 | // DEL_PTR(environment);
|
---|
111 | if (app)
|
---|
112 | return app->exec();
|
---|
113 |
|
---|
114 | return 0;
|
---|
115 | }
|
---|
116 |
|
---|