[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 | |
---|
| 10 | bool |
---|
| 11 | Preprocessor::LoadViewcells(const string filename) |
---|
| 12 | { |
---|
| 13 | |
---|
| 14 | return true; |
---|
| 15 | } |
---|
[65] | 16 | |
---|
[162] | 17 | bool |
---|
| 18 | Preprocessor::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] | 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; |
---|
[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 | |
---|
| 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(); |
---|
[176] | 59 | mSceneGraph->CollectObjects(&root->mObjects); |
---|
[65] | 60 | |
---|
[162] | 61 | mKdTree->Construct(); |
---|
| 62 | return true; |
---|
| 63 | } |
---|
[65] | 64 | |
---|
[234] | 65 | bool |
---|
| 66 | Preprocessor::BuildBspTree() |
---|
| 67 | { |
---|
| 68 | |
---|
| 69 | return true; |
---|
| 70 | } |
---|
[162] | 71 | |
---|
[234] | 72 | |
---|
| 73 | |
---|
[162] | 74 | void |
---|
| 75 | Preprocessor::KdTreeStatistics(ostream &s) |
---|
[65] | 76 | { |
---|
[162] | 77 | s<<mKdTree->GetStatistics(); |
---|
[65] | 78 | } |
---|
[162] | 79 | |
---|
[234] | 80 | void |
---|
| 81 | Preprocessor::BspTreeStatistics(ostream &s) |
---|
| 82 | { |
---|
| 83 | // s<<mBspTree->GetStatistics(); |
---|
| 84 | } |
---|
[162] | 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 | |
---|