Changeset 234
- Timestamp:
- 08/10/05 18:07:51 (19 years ago)
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r225 r234 63 63 Name="VCCLCompilerTool" 64 64 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;"$(QTDIR)\include";"$(QTDIR)\include\Qt";..\include" 65 PreprocessorDefinitions="WIN32;NDEBUG;_LIB "65 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;DEST_BSP_VIEWCELLS" 66 66 RuntimeLibrary="2" 67 67 RuntimeTypeInfo="TRUE" -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r176 r234 18 18 Preprocessor::GenerateViewcells() 19 19 { 20 ObjectContainer objects; 21 mSceneGraph->CollectObjects(&objects); 22 //mBspTree = new BspTree(objects); 20 23 21 24 return true; 22 25 } 23 26 … … 60 63 } 61 64 65 bool 66 Preprocessor::BuildBspTree() 67 { 68 69 return true; 70 } 71 72 62 73 63 74 void … … 67 78 } 68 79 80 void 81 Preprocessor::BspTreeStatistics(ostream &s) 82 { 83 // s<<mBspTree->GetStatistics(); 84 } 69 85 70 86 bool -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r221 r234 60 60 virtual bool BuildKdTree(); 61 61 62 /** Build the BSP tree of currently loaded occluders/occludees/viewcells. The construction 63 is driven by the environment settings, which also sais which of the three types of 64 entities should be used to drive the heuristical construction (only occluders by default) 65 */ 66 virtual bool BuildBspTree(); 67 62 68 /** Compute visibility method. This method has to be reimplemented by the actual 63 69 Preprocessor implementation (e.g. SamplingPreprocessor, ExactPreprocessor, … … 75 81 76 82 virtual void KdTreeStatistics(ostream &s); 77 83 virtual void BspTreeStatistics(ostream &s); 84 78 85 /// scene graph loaded from file 79 86 SceneGraph *mSceneGraph; … … 90 97 ViewCellContainer mViewcells; 91 98 92 99 BspTree * mBspTree; 93 100 94 101 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r233 r234 247 247 248 248 BspTree::BspTree(const ViewCellContainer &viewCells): 249 mMaxPolys(0), mMaxDepth( 0), mRoot(NULL)249 mMaxPolys(0), mMaxDepth(999999), mRoot(NULL) // null => until we stripped all polygons 250 250 { 251 251 //mRootCell = cell; … … 298 298 CopyMesh2Polygon(viewCell->GetMesh(), polys); 299 299 300 tStack.push(BspTraversalData(mRoot, NULL, &polys, 0 , viewCell));300 tStack.push(BspTraversalData(mRoot, NULL, &polys, 0)); 301 301 302 302 while (!tStack.empty()) … … 318 318 319 319 // push the children on the stack 320 if (frontPolys->size() > 0) 320 if (frontPolys->size() > 0) // if polygons on this side of bsp tree 321 321 tStack.push(BspTraversalData(interior->GetFront(), interior->GetParent(), frontPolys, tData.mDepth + 1)); 322 322 else 323 323 delete frontPolys; 324 324 325 if (backPolys > 0) 326 tStack.push(BspTraversalData(interior->GetBack(), interior->GetParent(), backPolys, tData.mDepth + 1)); // TODO: really need to keep viewcell??325 if (backPolys > 0) // if polygons on this side of bsp tree 326 tStack.push(BspTraversalData(interior->GetBack(), interior->GetParent(), backPolys, tData.mDepth + 1)); 327 327 else 328 328 delete backPolys; … … 330 330 else // reached leaf and must split 331 331 { 332 BuildTree(tStack, tData); 333 } 334 } 335 /* BspNode *currentNode = mRoot; 336 337 std::stack<BspTraversalData> tStack; 338 // stack<STraversalData> tStack; 339 340 //tStack.push(tdata); 341 342 while (!tStack.empty()) 343 { 344 BspTraversalData data = tStack.top(); 345 346 tStack.pop(); 347 348 Mesh backPolys; 349 Mesh frontPolys; 350 351 if (data.mNode->IsLeaf()) // if we have a leaf => subdivide 352 { 353 BspNode *node = SubdivideNode(dynamic_cast<BspLeaf *>(data.mNode), 354 data.mParent, 355 data.mPolys, 356 data.mDepth, 357 data.viewCell, 358 backPolys, 359 frontPolys); 360 361 if (!node->IsLeaf()) // node was subdivided 362 { 363 BspInterior *interior = dynamic_cast<BspInterior *>(node); 364 365 // push the children on the stack (there are always two children) 366 //tStack.push(BspTraversalData(interior->GetBack(), interior, backPolys, data.mDepth + 1)); 367 //tStack.push(BspTraversalData(interior->GetFront(), interior, frontPolys, data.mDepth + 1)); 368 } 369 } 370 }*/ 332 BuildTree(tStack, tData, NULL); 333 } 334 } 371 335 } 372 336 … … 415 379 Copy2PolygonSoup(objects, *polys); 416 380 417 BspTraversalData tData(mRoot, mRoot->GetParent(), polys, 0 , NULL);381 BspTraversalData tData(mRoot, mRoot->GetParent(), polys, 0); 418 382 tStack.push(tData); 419 383 … … 428 392 } 429 393 430 void BspTree::BuildTree(BspTraversalStack &tStack, BspTraversalData ¤tData )394 void BspTree::BuildTree(BspTraversalStack &tStack, BspTraversalData ¤tData, ViewCell *viewCell) 431 395 { 432 396 PolygonQueue *backPolys = new PolygonQueue(); … … 437 401 currentData.mPolys, 438 402 currentData.mDepth, 439 currentData.mViewCell,403 viewCell, 440 404 backPolys, 441 405 frontPolys); … … 446 410 447 411 // push the children on the stack (there are always two children) 448 tStack.push(BspTraversalData(interior->GetBack(), interior, backPolys, currentData.mDepth + 1 , NULL));449 tStack.push(BspTraversalData(interior->GetFront(), interior, frontPolys, currentData.mDepth + 1 , currentData.mViewCell));412 tStack.push(BspTraversalData(interior->GetBack(), interior, backPolys, currentData.mDepth + 1)); 413 tStack.push(BspTraversalData(interior->GetFront(), interior, frontPolys, currentData.mDepth + 1)); 450 414 } 451 415 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r233 r234 17 17 18 18 typedef std::queue<Polygon *> PolygonQueue; 19 20 class BspTreeStatistics // TODO: should have common superclass with KdTreeStatistics 21 { 22 public: 23 // total number of nodes 24 int nodes; 25 // totals number of rays 26 int rays; 27 // total number of query domains 28 int queryDomains; 29 // total number of ray references 30 int rayRefs; 31 // refs in non empty leafs 32 int rayRefsNonZeroQuery; 33 // total number of query references 34 int objectRefs; 35 // nodes with zero queries 36 int zeroQueryNodes; 37 // max depth nodes 38 int maxDepthNodes; 39 // max number of rays per node 40 int maxObjectRefs; 41 // number of dynamically added ray refs 42 int addedRayRefs; 43 // number of dynamically removed ray refs 44 int removedRayRefs; 45 46 // Constructor 47 BspTreeStatistics() 48 { 49 Reset(); 50 } 51 52 int Nodes() const {return nodes;} 53 int Interior() const { return nodes/2; } 54 int Leaves() const { return (nodes/2) + 1; } 55 56 void Reset() 57 { 58 nodes = 0; 59 60 rays = queryDomains = 0; 61 rayRefs = rayRefsNonZeroQuery = objectRefs = 0; 62 zeroQueryNodes = 0; 63 maxDepthNodes = 0; 64 //minCostNodes = 0; 65 maxObjectRefs = 0; 66 addedRayRefs = removedRayRefs = 0; 67 } 68 69 void 70 Print(ostream &app) const; 71 72 friend ostream &operator<<(ostream &s, const BspTreeStatistics &stat) { 73 stat.Print(s); 74 return s; 75 } 76 77 }; 19 78 20 79 /** … … 179 238 /** Builds a new extension of the tree. 180 239 */ 181 void BuildTree(BspTraversalStack &tStack, BspTraversalData ¤tData );240 void BuildTree(BspTraversalStack &tStack, BspTraversalData ¤tData, ViewCell *viewCell = NULL); 182 241 183 242 /** Selects a splitting plane from the given polygons. … … 232 291 /// maximal depth 233 292 int mMaxDepth; 293 294 BspTreeStatistics mStat; 234 295 }; 235 296 -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r191 r234 30 30 p->KdTreeStatistics(cout); 31 31 32 #ifdef DEST_BSP_VIEWCELLS 33 p->GenerateViewcells(); 34 p->BspTreeStatistics(cout); 35 #endif 36 32 37 // p->mSceneGraph->Export("soda.x3d"); 33 38 if (0) {
Note: See TracChangeset
for help on using the changeset viewer.