1 | #include "SceneGraph.h" |
---|
2 | #include "Exporter.h" |
---|
3 | #include "UnigraphicsParser.h" |
---|
4 | #include "X3dParser.h" |
---|
5 | #include "Preprocessor.h" |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | bool |
---|
11 | Preprocessor::LoadViewcells(const string filename) |
---|
12 | { |
---|
13 | |
---|
14 | return true; |
---|
15 | } |
---|
16 | |
---|
17 | bool |
---|
18 | Preprocessor::GenerateViewcells() |
---|
19 | { |
---|
20 | ObjectContainer objects; |
---|
21 | mSceneGraph->CollectObjects(&objects); |
---|
22 | //mBspTree = new BspTree(objects); |
---|
23 | |
---|
24 | return true; |
---|
25 | } |
---|
26 | |
---|
27 | bool |
---|
28 | Preprocessor::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 | |
---|
47 | bool |
---|
48 | Preprocessor::ExportPreprocessedData(const string filename) |
---|
49 | { |
---|
50 | return false; |
---|
51 | } |
---|
52 | |
---|
53 | bool |
---|
54 | Preprocessor::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 | |
---|
65 | bool |
---|
66 | Preprocessor::BuildBspTree() |
---|
67 | { |
---|
68 | |
---|
69 | return true; |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | void |
---|
75 | Preprocessor::KdTreeStatistics(ostream &s) |
---|
76 | { |
---|
77 | s<<mKdTree->GetStatistics(); |
---|
78 | } |
---|
79 | |
---|
80 | void |
---|
81 | Preprocessor::BspTreeStatistics(ostream &s) |
---|
82 | { |
---|
83 | // s<<mBspTree->GetStatistics(); |
---|
84 | } |
---|
85 | |
---|
86 | bool |
---|
87 | Preprocessor::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 | |
---|