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

Revision 574, 3.2 KB checked in by mattausch, 19 years ago (diff)

finished function for view cell construction
removed bsp rays from vspbspmanager

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