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

Line 
1#include "SceneGraph.h"
2#include "Exporter.h"
3#include "UnigraphicsParser.h"
4#include "X3dParser.h"
5#include "Preprocessor.h"
6
7
8
9 
10bool
11Preprocessor::LoadViewcells(const string filename)
12{
13 
14  return true;
15}
16
17bool
18Preprocessor::GenerateViewcells()
19{
20        ObjectContainer objects;
21        mSceneGraph->CollectObjects(&objects);
22        //mBspTree = new BspTree(objects);
23 
24        return true;
25}
26
27bool
28Preprocessor::LoadScene(const string filename)
29{
30  // use leaf nodes of the original spatial hiearrchy as occludees
31
32  mSceneGraph = new SceneGraph;
33
34 
35  Parser *parser;
36
37  if (strstr(filename.c_str(), ".x3d"))
38    parser = new X3dParser;
39  else
40    parser = new UnigraphicsParser;
41
42  bool result = parser->ParseFile(filename, &mSceneGraph->mRoot);
43 
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();
59  mSceneGraph->CollectObjects(&root->mObjects);
60 
61  mKdTree->Construct();
62  return true;
63}
64
65bool
66Preprocessor::BuildBspTree()
67{
68 
69  return true;
70}
71
72
73
74void
75Preprocessor::KdTreeStatistics(ostream &s)
76{
77  s<<mKdTree->GetStatistics();
78}
79
80void
81Preprocessor::BspTreeStatistics(ostream &s)
82{
83//  s<<mBspTree->GetStatistics();
84}
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.