source: trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp @ 574

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

finished function for view cell construction
removed bsp rays from vspbspmanager

RevLine 
[162]1#include "SamplingPreprocessor.h"
[374]2#include "VssPreprocessor.h"
[446]3#include "RssPreprocessor.h"
[162]4#include "ExactPreprocessor.h"
5#include "Parser.h"
6#include "UnigraphicsParser.h"
[170]7#include "X3dParser.h"
[162]8#include "Environment.h"
9#include "Camera.h"
[170]10#include "MeshKdTree.h"
[264]11#include "Exporter.h"
[292]12#include "X3dExporter.h" // delete later
[310]13#include "ViewCell.h"
[321]14#include "SceneGraph.h"
[492]15#include "PreprocessorThread.h"
[162]16
[492]17#include <QApplication>
18#include <QtOpenGL>
19#include "GlRenderer.h"
20
[162]21#define USE_EXE_PATH false
22
[570]23#include <crtdbg.h>
[372]24
[492]25
26
[162]27int
[492]28main(int argc, char **argv)
[162]29{
[570]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
[162]40  Debug.open("debug.log");
41  environment = new Environment;
42  environment->Parse(argc, argv, USE_EXE_PATH);
[170]43  MeshKdTree::ParseEnvironment();
[492]44 
[409]45  char buff[128];
46  environment->GetStringValue("Preprocessor.type", buff);
47  string preprocessorType(buff);
[374]48       
49  Preprocessor *p;
50
[464]51  if (preprocessorType == "vss")
52        p = new VssPreprocessor();
53  else
54        if (preprocessorType == "rss")
55          p = new RssPreprocessor();
[374]56        else
[464]57          if (preprocessorType == "exact")
58                p = new ExactPreprocessor();
[446]59          else
[464]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                }
[496]67
68  QApplication *app = NULL;
[574]69
[496]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 
[492]82  preprocessor = p;
[464]83 
[492]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 
[260]94
[492]95  // create a preprocessor thread
[556]96  PreprocessorThread *pt = new PreprocessorThread(p, app);
[492]97
[162]98  //  p->mSceneGraph->Export("soda.x3d");
[176]99  if (0) {
[242]100    p->Export(filename + "-out.x3d", true, false, false);
[263]101    p->Export(filename + "-kdtree.x3d", false, true, false);   
[170]102  }
[235]103
[492]104  if (p->mUseGlRenderer) {
105       
[556]106        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree);
[492]107        //  renderer->resize(640, 480);
[496]108        rendererWidget->resize(640, 480);
109        rendererWidget->show();
[492]110        pt->start(QThread::LowPriority);
[556]111  } else{
[492]112        // just call the mail method -> will be executed in the main thread
113        pt->Main();
[170]114  }
[492]115 
[261]116  // clean up
[492]117  //  DEL_PTR(p);
118  //  DEL_PTR(environment);
[496]119  if (app)
120        return app->exec();
[556]121 
[162]122  return 0;
123}
124
Note: See TracBrowser for help on using the repository browser.