Changeset 2600 for GTP/trunk/Lib/Vis
- Timestamp:
- 01/16/08 09:38:50 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/include/SceneGraph.h
r68 r2600 7 7 namespace GtpVisibilityPreprocessor { 8 8 9 /** Basic scene graph node, we are interested only in bounding boxes and topology 10 of the scene graph */ 11 class SceneGraphNode { 12 public: 13 14 15 protected: 16 MeshContainer mGeometry; 17 NodeContainer mChildren; 18 AxisAlignedBox3 mBox; 19 }; 9 /** Basic scene graph node, we are interested only in bounding boxes and topology 10 of the scene graph 11 */ 12 class SceneGraphNode 13 { 14 public: 15 virtual bool IsLeaf() const = NULL; 16 17 protected: 18 19 AxisAlignedBox3 mBox; 20 }; 20 21 21 22 22 /** Scene graph class */ 23 class SceneGraph { 24 25 protected: 26 SceneGraphNode *mRoot; 27 }; 23 24 /** Basic scene graph node, we are interested only in bounding boxes and topology 25 of the scene graph */ 26 class SceneGraphInterior: public SceneGraphNode 27 { 28 public: 29 ~SceneGraphInterior(); 30 31 virtual bool IsLeaf() const { return false; } 32 33 protected: 34 35 NodeContainer mChildren; 36 }; 37 38 39 /** Basic scene graph node, we are interested only in bounding boxes and topology 40 of the scene graph */ 41 class SceneGraphLeaf: public SceneGraphNode 42 { 43 public: 44 ~SceneGraphLeaf(); 45 virtual bool IsLeaf() const { return true; } 46 47 protected: 48 MeshContainer mGeometry; 49 }; 50 51 52 /** Scene graph class 53 */ 54 class SceneGraph 55 { 56 protected: 57 SceneGraphNode *mRoot; 58 }; 28 59 29 60 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2598 r2600 15 15 #include "SamplingStrategy.h" 16 16 #include "Preprocessor.h" 17 #include "SceneGraph.h" 17 18 18 19 … … 399 400 OcclusionQuery::GenQueries(mOcclusionQueries, 10); 400 401 401 CreateVertexArrays( );402 CreateVertexArrays(static_cast<SceneGraphLeaf *>(mSceneGraph->GetRoot())); 402 403 } 403 404 … … 484 485 GlRenderer::RenderScene() 485 486 { 486 487 Intersectable::NewMail(); 487 488 488 489 #if 1 489 490 490 491 _RenderSceneTrianglesWithDrawArrays(); 491 492 492 493 #else 493 494 495 if (glList == -1) {496 497 498 499 500 }501 502 glCallList(glList);503 504 _RenderSceneTriangles();505 506 #endif 507 494 static int glList = -1; 495 if (mUseGlLists) { 496 if (glList == -1) { 497 glList = glGenLists(1); 498 glNewList(glList, GL_COMPILE); 499 _RenderSceneTriangles(); 500 glEndList(); 501 } 502 503 glCallList(glList); 504 } else 505 _RenderSceneTriangles(); 506 507 #endif 508 return true; 508 509 } 509 510 … … 1701 1702 #endif 1702 1703 1703 void GlRenderer::CreateVertexArrays() 1704 { 1705 mData = new Vector3[mObjects.size() * 6]; 1706 mIndices = new unsigned int[mObjects.size() * 3]; 1707 1708 size_t offset = mObjects.size() * 3; 1709 1710 for (size_t i = 0; i < mObjects.size(); ++ i) 1711 { 1712 TriangleIntersectable *obj = static_cast<TriangleIntersectable *>(mObjects[i]); 1704 1705 void GlRenderer::CreateVertexArrays(SceneGraphLeaf *leaf) 1706 { 1707 mData = new Vector3[leaf->mGeometry.size() * 6]; 1708 mIndices = new unsigned int[leaf->mGeometry.size() * 3]; 1709 1710 size_t offset = leaf->mGeometry.size() * 3; 1711 1712 for (size_t i = 0; i < leaf->mGeometry.size(); ++ i) 1713 { 1714 TriangleIntersectable *obj = static_cast<TriangleIntersectable *>(leaf->mGeometry[i]); 1713 1715 1714 1716 Triangle3 tri = obj->GetItem(); … … 1734 1736 glNormalPointer(GL_FLOAT, 0, (char *)NULL + offset * sizeof(Vector3)); 1735 1737 1736 glBufferDataARB(GL_ARRAY_BUFFER_ARB, mObjects.size() * 6 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB);1738 glBufferDataARB(GL_ARRAY_BUFFER_ARB, leaf->mObjects.size() * 6 * sizeof(Vector3), mData, GL_STATIC_DRAW_ARB); 1737 1739 glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 1738 1740 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r2598 r2600 28 28 class BvhNode; 29 29 class SimpleRayContainer; 30 class SceneGraphLeaf; 30 31 31 32 struct VssRayContainer; … … 222 223 protected: 223 224 224 void CreateVertexArrays( );225 void CreateVertexArrays(SceneGraphLeaf *leaf); 225 226 void DeleteVbos(); 226 227 void EnableDrawArrays(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r2575 r2600 183 183 static void ProcessMesh(FaceContainer &faces, 184 184 map<int, Vector3> &hashTable, 185 SceneGraph Node*root,185 SceneGraphLeaf *root, 186 186 vector<FaceParentInfo> *parents) 187 187 { … … 222 222 223 223 bool ObjParser::ParseFile(const string filename, 224 SceneGraph Node*root,224 SceneGraphLeaf *root, 225 225 const bool loadMeshes, 226 226 vector<FaceParentInfo> *parents) -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.h
r1379 r2600 16 16 17 17 virtual bool ParseFile(const std::string filename, 18 SceneGraph Node*root,18 SceneGraphLeaf *root, 19 19 const bool loadMeshes = true, 20 20 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/Parser.h
r1786 r2600 10 10 11 11 class SceneGraphNode; 12 class SceneGraphLeaf; 12 13 class Intersectable; 13 14 … … 19 20 20 21 virtual bool ParseFile(const std::string filename, 21 SceneGraph Node*root,22 SceneGraphLeaf *root, 22 23 const bool loadMeshes = true, 23 24 std::vector<FaceParentInfo> *parents = NULL) -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.cpp
r2575 r2600 56 56 bool 57 57 PlyParser::ParseSingleFile(const std::string filename, 58 SceneGraph Node*root)58 SceneGraphLeaf *root) 59 59 { 60 60 /*** the PLY object ***/ … … 260 260 bool 261 261 PlyParser::ParseFile(const string filename, 262 SceneGraph Node*root,262 SceneGraphLeaf *root, 263 263 const bool loadMeshes, 264 264 vector<FaceParentInfo> *parents) -
GTP/trunk/Lib/Vis/Preprocessing/src/PlyParser.h
r2176 r2600 15 15 16 16 bool ParseFile(const std::string filename, 17 SceneGraph Node*root,17 SceneGraphLeaf *root, 18 18 const bool loadMeshes = true, 19 19 std::vector<FaceParentInfo> *parents = NULL); … … 23 23 bool 24 24 ParseSingleFile(const std::string filename, 25 SceneGraph Node*root);25 SceneGraphLeaf *root); 26 26 27 27 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2599 r2600 187 187 188 188 bool Preprocessor::LoadBinaryObj(const string &filename, 189 SceneGraph Node*root,189 SceneGraphLeaf *root, 190 190 vector<FaceParentInfo> *parents) 191 191 { … … 1617 1617 const ObjectContainer &preprocessorObjects) 1618 1618 { 1619 // bool success = LoadBinaryObj(filename, mSceneGraph->GetRoot(), &mFa seParents);1619 // bool success = LoadBinaryObj(filename, mSceneGraph->GetRoot(), &mFaceParents); 1620 1620 bool success = LoadBinaryObj(filename, mSceneGraph->GetRoot(), NULL); 1621 1621 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2593 r2600 31 31 class RayCaster; 32 32 class GlobalLinesRenderer; 33 class SceneGraphLeaf; 33 34 34 35 … … 277 278 278 279 bool LoadBinaryObj(const std::string &filename, 279 SceneGraph Node*root,280 SceneGraphLeaf *root, 280 281 std::vector<FaceParentInfo> *parents); 281 282 282 bool ExportBinaryObj(const std::string &filename, SceneGraph Node*root);283 bool ExportBinaryObj(const std::string &filename, SceneGraphLeaf *root); 283 284 284 285 void SetupRay(Ray &ray, const Vector3 &point, -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.cpp
r2544 r2600 32 32 SceneGraphNode::~SceneGraphNode() 33 33 { 34 CLEAR_CONTAINER(mGeometry); 34 } 35 36 37 SceneGraphLeaf::~SceneGraphLeaf() 38 { 39 CLEAR_CONTAINER(mGeometry); 40 } 41 42 43 SceneGraphInterior::~SceneGraphInterior() 44 { 35 45 // recursivly delete all children 36 46 CLEAR_CONTAINER(mChildren); 37 47 } 48 38 49 39 50 … … 61 72 62 73 63 void SceneGraph::SetRoot(SceneGraph Node*root)74 void SceneGraph::SetRoot(SceneGraphLeaf *root) 64 75 { 65 76 mRoot = root; … … 67 78 68 79 69 int 70 SceneGraph::CollectObjects(ObjectContainer *instances) 80 int SceneGraph::CollectObjects(ObjectContainer &instances) 71 81 { 72 82 instances->clear(); … … 74 84 75 85 stack<SceneGraphNode *> nodeStack; 76 nodeStack.push(mRoot);77 78 while (!nodeStack.empty()) {79 SceneGraphNode *node = nodeStack.top();80 nodeStack.pop();81 82 ObjectContainer::const_iterator mi = node->mGeometry.begin();83 for (; mi != node->mGeometry.end(); mi++)84 {85 instances->push_back(*mi);86 }87 88 SceneGraphNodeContainer::iterator ni = node->mChildren.begin();89 for (; ni != node->mChildren.end(); ni++) {90 nodeStack.push(*ni);91 number++;92 }93 }94 95 return number;96 }97 98 99 int100 SceneGraph::AssignObjectIds()101 {102 // matt: rather start with id zero103 int id = 0;104 stack<SceneGraphNode *> nodeStack;105 106 86 nodeStack.push(mRoot); 107 87 … … 111 91 nodeStack.pop(); 112 92 113 ObjectContainer::iterator mi = node->mGeometry.begin(); 114 115 for (; mi != node->mGeometry.end(); mi ++) 116 { 117 (*mi)->SetId(id ++); 118 } 119 120 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 121 for (; ni != node->mChildren.end(); ni ++) 122 { 123 nodeStack.push(*ni); 93 if (node->IsLeaf()) 94 { 95 SceneGraphLeaf *leaf = static_cast<SceneGraphNodeLeaf *>(node); 96 97 ObjectContainer::const_iterator mi = leaf->mGeometry.begin(); 98 99 for (; mi != leaf->mGeometry.end(); mi++) 100 { 101 instances->push_back(*mi); 102 } 103 } 104 else 105 { 106 SceneGraphInterior *interior = static_cast<SceneGraphNodeInterior *>(node); 107 SceneGraphNodeContainer::iterator ni = interior->mChildren.begin(); 108 109 for (; ni != interior->mChildren.end(); ++ ni) 110 { 111 nodeStack.push(*ni); 112 number++; 113 } 114 } 115 } 116 117 return number; 118 } 119 120 121 int 122 SceneGraph::AssignObjectIds() 123 { 124 // matt: rather start with id zero 125 int id = 0; 126 stack<SceneGraphNode *> nodeStack; 127 128 nodeStack.push(mRoot); 129 130 while (!nodeStack.empty()) 131 { 132 SceneGraphNode *node = nodeStack.top(); 133 nodeStack.pop(); 134 135 if (node->IsLeaf) 136 { 137 SceneGraphLeaf *leaf = static_cast<SceneGraphLeaf *>(node); 138 ObjectContainer::iterator mi = leaf->mGeometry.begin(); 139 140 for (; mi != leaf->mGeometry.end(); mi ++) 141 { 142 (*mi)->SetId(id ++); 143 } 144 } 145 else 146 { 147 SceneGraphInterior *interior = static_cast<SceneGraphInterior *>(node); 148 SceneGraphNodeContainer::iterator ni = interior->mChildren.begin(); 149 for (; ni != node->mChildren.end(); ni ++) 150 { 151 nodeStack.push(*ni); 152 } 124 153 } 125 154 } … … 132 161 SceneGraph::GetStatistics(int &intersectables, int &faces) const 133 162 { 134 135 136 137 163 stack<SceneGraphNode *> nodeStack; 164 165 nodeStack.push(mRoot); 166 faces = 0; 138 167 intersectables = 0; 139 140 141 142 143 144 168 while (!nodeStack.empty()) { 169 SceneGraphNode *node = nodeStack.top(); 170 nodeStack.pop(); 171 172 ObjectContainer::const_iterator mi = node->mGeometry.begin(); 173 for (; mi != node->mGeometry.end(); mi++) { 145 174 intersectables++; 146 175 faces += (*mi)->NumberOfFaces(); 147 176 } 148 149 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 150 for (; ni != node->mChildren.end(); ni++) { 151 nodeStack.push(*ni); 152 } 153 } 177 178 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 179 for (; ni != node->mChildren.end(); ni++) { 180 nodeStack.push(*ni); 181 } 182 } 183 184 } 185 186 187 void SceneGraphInterior::UpdateBox() 188 { 189 AxisAlignedBox3 box; 190 box.Initialize(); 191 192 ObjectContainer::const_iterator mi = mGeometry.begin(); 193 for (; mi != mGeometry.end(); mi++) 194 box.Include((*mi)->GetBox()); 195 196 mBox = box; 197 } 198 199 200 void SceneGraphLeaf::UpdateBox() 201 { 202 AxisAlignedBox3 box; 203 204 box.Initialize(); 205 206 SceneGraphNodeContainer::iterator ni = mChildren.begin(); 154 207 155 } 156 157 158 void 159 SceneGraphNode::UpdateBox() 160 { 161 AxisAlignedBox3 box; 162 163 box.Initialize(); 164 165 ObjectContainer::const_iterator mi = mGeometry.begin(); 166 for (; mi != mGeometry.end(); mi++) 167 box.Include((*mi)->GetBox()); 168 169 SceneGraphNodeContainer::iterator ni = mChildren.begin(); 170 for (; ni != mChildren.end(); ni++) { 171 (*ni)->UpdateBox(); 172 box.Include((*ni)->mBox); 173 } 174 175 mBox = box; 176 } 208 for (; ni != mChildren.end(); ++ ni) 209 { 210 (*ni)->UpdateBox(); 211 box.Include((*ni)->mBox); 212 } 213 214 mBox = box; 215 } 216 177 217 178 218 -
GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h
r2176 r2600 3 3 4 4 #include <string> 5 //6 7 5 #include "Containers.h" 8 6 #include "AxisAlignedBox3.h" 9 7 8 10 9 namespace GtpVisibilityPreprocessor { 11 10 11 12 12 /** Basic scene graph node, we are interested only in bounding boxes and topology 13 13 of the scene graph 14 */ 15 class SceneGraphNode { 14 */ 15 class SceneGraphNode 16 { 16 17 public: 17 ObjectContainer mGeometry; 18 SceneGraphNodeContainer mChildren; 19 AxisAlignedBox3 mBox; 20 ~SceneGraphNode(); 21 void UpdateBox(); 18 19 virtual ~SceneGraphNode(); 20 virtual bool IsLeaf() const = 0; 21 22 virtual void UpdateBox() = 0; 23 24 //protected: 25 26 AxisAlignedBox3 mBox; 22 27 }; 28 29 30 31 /** Scene graph interior node. 32 */ 33 class SceneGraphInterior: public SceneGraphNode 34 { 35 public: 36 virtual bool IsLeaf() const { return false; } 37 virtual void UpdateBox(); 38 39 //protected: 40 41 NodeContainer mChildren; 42 }; 43 44 45 /** Scene graph leaf node. 46 */ 47 class SceneGraphLeaf: public SceneGraphNode 48 { 49 public: 50 51 virtual bool IsLeaf() const { return true; } 52 virtual void UpdateBox(); 53 54 //protected: 55 56 MeshContainer mGeometry; 57 }; 58 23 59 24 60 -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r2572 r2600 46 46 bool 47 47 UnigraphicsParser::ParseFile(const string filename, 48 SceneGraph Node*root,48 SceneGraphLeaf *root, 49 49 const bool loadMeshes, 50 50 vector<FaceParentInfo> *parents) -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.h
r1379 r2600 16 16 17 17 virtual bool ParseFile(const std::string filename, 18 SceneGraph Node*root,18 SceneGraphLeaf *root, 19 19 const bool loadMeshes = false, 20 20 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2599 r2600 1688 1688 // create temporary scene graph for loading the view cells geometry 1689 1689 // note: delete the meshes as they are created two times for transformed mesh instances. 1690 SceneGraphNode *root = new SceneGraph Node();1690 SceneGraphNode *root = new SceneGraphLeaf(); 1691 1691 const bool success = parser.ParseFile(filename, root, true); 1692 1692 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r2176 r2600 190 190 stream<<"<Group>"<<endl; 191 191 192 SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 193 for (; ni != node->mChildren.end(); ni++) 194 ExportSceneNode(*ni); 195 196 197 ObjectContainer::const_iterator mi = node->mGeometry.begin(); 198 for (; mi != node->mGeometry.end(); mi++) { 199 // export the transform... 200 ExportIntersectable(*mi); 201 } 202 192 if (!node->IsLeaf()) 193 { 194 SceneGraphInterior *interior = static_cast<SceneGraphInterior *>(node); 195 196 SceneGraphNodeContainer::iterator ni = interior->mChildren.begin(); 197 for (; ni != interior->mChildren.end(); ni++) 198 ExportSceneNode(*ni); 199 } 200 else 201 { 202 SceneGraphLeaf *leaf = static_cast<SceneGraphLeaf *>(node); 203 204 ObjectContainer::const_iterator mi = leaf->mGeometry.begin(); 205 for (; mi != leaf->mGeometry.end(); ++ mi) 206 { 207 // export the transform... 208 ExportIntersectable(*mi); 209 } 210 } 211 203 212 stream<<"</Group>"<<endl; 204 213 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r2539 r2600 85 85 // StdInParseHandlers: Constructors and Destructor 86 86 // --------------------------------------------------------------------------- 87 X3dParseHandlers::X3dParseHandlers(SceneGraph Node*root,87 X3dParseHandlers::X3dParseHandlers(SceneGraphLeaf *root, 88 88 const bool loadMeshes): 89 89 mElementCount(0) … … 637 637 bool 638 638 X3dParser::ParseFile(const string filename, 639 SceneGraph Node*root,639 SceneGraphLeaf *root, 640 640 const bool loadMeshes, 641 641 vector<FaceParentInfo> *parents) -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.h
r2176 r2600 15 15 X3dParser(); 16 16 17 bool ParseFile( 18 const std::string filename, 19 SceneGraphNode *root, 17 bool ParseFile(const std::string filename, 18 SceneGraphLeaf *root, 20 19 const bool loadMeshes = false, 21 20 vector<FaceParentInfo> *parents = NULL); -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h
r2176 r2600 17 17 18 18 class SceneGraphNode; 19 class SceneGraphLeaf; 19 20 class Mesh; 20 21 class Material; … … 41 42 // Constructors and Destructor 42 43 // ----------------------------------------------------------------------- 43 X3dParseHandlers(SceneGraph Node*root, const bool loadMeshes = false);44 X3dParseHandlers(SceneGraphLeaf *root, const bool loadMeshes = false); 44 45 ~X3dParseHandlers(); 45 46 … … 78 79 void resetDocument(); 79 80 80 SceneGraph Node*mCurrentNode;81 SceneGraphLeaf *mCurrentNode; 81 82 82 83 vector<VertexIndexContainer> mCurrentVertexIndices;
Note: See TracChangeset
for help on using the changeset viewer.