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

Revision 746, 3.5 KB checked in by bittner, 19 years ago (diff)

visualization of the render cost and pvs sizes for viewcells

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
69  QApplication *app = NULL;
70
71  if (p->mUseGlRenderer) {
72        // create a qt application first (must be created before any opengl widget...
73        app = new QApplication(argc, argv);
74       
75        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) {
76          QMessageBox::information(0, "OpenGL pbuffers",
77                                                           "This system does not support OpenGL/pbuffers.",
78                                                           QMessageBox::Ok);
79          return -1;
80        }
81  }
82 
83  preprocessor = p;
84 
85  environment->GetStringValue("Scene.filename", buff);
86  string filename(buff);
87  p->LoadScene(filename);
88 
89  p->BuildKdTree();
90  p->KdTreeStatistics(cout);
91 
92  // parse view cells related options
93  p->PrepareViewCells();
94 
95
96  // create a preprocessor thread
97  PreprocessorThread *pt = new PreprocessorThread(p, app);
98
99  //  p->mSceneGraph->Export("soda.x3d");
100  if (0) {
101    p->Export(filename + "-out.x3d", true, false, false);
102    p->Export(filename + "-kdtree.x3d", false, true, false);   
103  }
104
105  if (p->mUseGlRenderer) {
106       
107        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
108        //  renderer->resize(640, 480);
109        rendererWidget->resize(640, 480);
110        rendererWidget->show();
111
112        if (p->GetRenderer()) {
113
114          cout<<"CONNECTING"<<endl;
115          QObject::connect(p->GetRenderer(),
116                                           SIGNAL(UpdatePvsErrorItem(int i,
117                                                                                                 GlRendererBuffer::PvsErrorEntry &)),
118                                           rendererWidget->mControlWidget,
119                                           SLOT(UpdatePvsErrorItem(int i,
120                                                                                           GlRendererBuffer::PvsErrorEntry &)));
121          cout<<"CONNECTED"<<endl;
122        }
123       
124        pt->start(QThread::LowPriority);
125       
126       
127  } else{
128        // just call the mail method -> will be executed in the main thread
129        pt->Main();
130  }
131 
132  // clean up
133  //  DEL_PTR(p);
134  //  DEL_PTR(environment);
135  if (app)
136        return app->exec();
137 
138  return 0;
139}
140
Note: See TracBrowser for help on using the repository browser.