source: trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp @ 234

Revision 234, 1.7 KB checked in by mattausch, 19 years ago (diff)

added bsp tree stuff

RevLine 
[162]1#include "SceneGraph.h"
2#include "Exporter.h"
3#include "UnigraphicsParser.h"
[170]4#include "X3dParser.h"
[65]5#include "Preprocessor.h"
6
7
8
[162]9 
10bool
11Preprocessor::LoadViewcells(const string filename)
12{
13 
14  return true;
15}
[65]16
[162]17bool
18Preprocessor::GenerateViewcells()
19{
[234]20        ObjectContainer objects;
21        mSceneGraph->CollectObjects(&objects);
22        //mBspTree = new BspTree(objects);
[162]23 
[234]24        return true;
[162]25}
[65]26
[162]27bool
28Preprocessor::LoadScene(const string filename)
29{
30  // use leaf nodes of the original spatial hiearrchy as occludees
31
32  mSceneGraph = new SceneGraph;
[170]33
34 
35  Parser *parser;
36
37  if (strstr(filename.c_str(), ".x3d"))
38    parser = new X3dParser;
39  else
40    parser = new UnigraphicsParser;
41
[162]42  bool result = parser->ParseFile(filename, &mSceneGraph->mRoot);
[65]43 
[162]44  return result;
45}
46
47bool
48Preprocessor::ExportPreprocessedData(const string filename)
49{
50  return false;
51}
52
53bool
54Preprocessor::BuildKdTree()
55{
56  mKdTree = new KdTree;
57  // add mesh instances of the scene graph to the root of the tree
58  KdLeaf *root = (KdLeaf *)mKdTree->GetRoot();
[176]59  mSceneGraph->CollectObjects(&root->mObjects);
[65]60 
[162]61  mKdTree->Construct();
62  return true;
63}
[65]64
[234]65bool
66Preprocessor::BuildBspTree()
67{
68 
69  return true;
70}
[162]71
[234]72
73
[162]74void
75Preprocessor::KdTreeStatistics(ostream &s)
[65]76{
[162]77  s<<mKdTree->GetStatistics();
[65]78}
[162]79
[234]80void
81Preprocessor::BspTreeStatistics(ostream &s)
82{
83//  s<<mBspTree->GetStatistics();
84}
[162]85
86bool
87Preprocessor::Export( const string filename,
88                      const bool scene,
89                      const bool kdtree
90                      )
91{
92  Exporter *exporter = Exporter::GetExporter(filename);
93
94  if (exporter) {
95    if (scene)
96      exporter->ExportScene(mSceneGraph->mRoot);
97
98    if (kdtree) {
99      exporter->SetWireframe();
100      exporter->ExportKdTree(*mKdTree);
101    }
102
103    delete exporter;
104    return true;
105  }
106
107  return false;
108}
109
110
111
Note: See TracBrowser for help on using the repository browser.