- Timestamp:
- 09/01/06 19:37:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1308 r1313 451 451 splitCandidate.SetRenderCostDecrease(renderCostDecr); 452 452 453 #if 1453 #if 0 454 454 const float priority = (float)-splitCandidate.mParentData.mDepth; 455 455 #else -
GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h
r1297 r1313 76 76 std::vector<T> mBuffer; 77 77 }; 78 78 79 79 80 /*****************************************************************************/ -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1311 r1313 214 214 215 215 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 216 mHierarchyStats.Stop(); 216 217 mVspTree->mVspStats.Stop(); 217 218 } … … 320 321 { 321 322 const bool ospDepthReached = 322 (mMinDepthForObjectSpaceSubdivion == mVspTree->mVspStats.maxDepth);323 (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth); 323 324 const bool stillNotOsp = (mObjectSpaceSubdivisionType == NO_OBJ_SUBDIV); 324 325 Debug << "here10 " << mMinDepthForObjectSpaceSubdivion << " " << mVspTree->mVspStats.maxDepth << endl;326 325 327 return stillNotOsp && (mTQueue.Empty() || ospDepthReached);326 return stillNotOsp && (mTQueue.Empty() || ((mConstructionType == 1) && ospDepthReached)); 328 327 } 329 328 … … 335 334 mHierarchyStats.nodes = 0; 336 335 mGlobalCostMisses = 0; 337 Debug << "here2" << endl; 336 338 337 // use objects for evaluating vsp tree construction in the first levels 339 338 // of the subdivision 340 339 const int savedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 341 340 mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 342 Debug << "here3" << endl; 341 343 342 // start with view space subdivison: prepare vsp tree for traversal 344 343 PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 345 344 346 const bool repairQueue = false; 347 //const bool repairQueue = true; 348 349 while (!FinishedConstruction()); 350 {Debug << "here7" << endl; 351 // we use objects for evaluating vsp tree construction until 352 // a certain depth once a certain depth existiert .... 353 if (StartObjectSpaceSubdivision()) 354 { 355 Debug << "here8" << endl; 356 mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 357 PrepareObjectSpaceSubdivision(sampleRays, objects); 358 Debug << "here9" << endl; 359 } 360 345 //const bool repairQueue = false; 346 const bool repairQueue = true; 347 cout << "here55 " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 348 // start object space subdivision immediately? 349 if (StartObjectSpaceSubdivision()) 350 {cout << "here1155 "; 351 mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 352 PrepareObjectSpaceSubdivision(sampleRays, objects); 353 } 354 355 int i = 0; 356 while (!FinishedConstruction()) 357 { 361 358 mCurrentCandidate = NextSubdivisionCandidate(); 362 359 mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); … … 370 367 ++ mGlobalCostMisses; 371 368 } 372 369 373 370 //-- subdivide leaf node 374 371 if (ApplySubdivisionCandidate(mCurrentCandidate)) 375 372 { 373 cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 376 374 mHierarchyStats.nodes += 2; 377 375 … … 384 382 } 385 383 384 // we use objects for evaluating vsp tree construction until 385 // a certain depth once a certain depth existiert .... 386 if (StartObjectSpaceSubdivision()) 387 { 388 cout << "reseting queue ... "; 389 ResetQueue(); 390 cout << "finished" << endl; 391 392 cout << "starting object space subdivision at maximal view space subdivison depth " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 393 394 mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 395 PrepareObjectSpaceSubdivision(sampleRays, objects); 396 } 397 386 398 DEL_PTR(mCurrentCandidate); 387 399 } 388 400 389 390 401 mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 391 402 } … … 398 409 399 410 400 int HierarchyManager::GetObjectSpaceSubdivisionType() 401 { 402 if (!ObjectSpaceSubdivisionConstructed()) 403 return NO_OBJECT_SUBDIV; 404 405 return mObjectSpaceSubdivisionType; 406 } 407 408 409 bool HierarchyManager::ObjectSpaceSubdivisionConstructed() 411 bool HierarchyManager::ObjectSpaceSubdivisionConstructed() const 410 412 { 411 413 switch (mObjectSpaceSubdivisionType) … … 489 491 490 492 // collect list of "dirty" candidates 493 long startTime = GetTime(); 494 491 495 vector<SubdivisionCandidate *> dirtyList; 492 496 CollectDirtyCandidates(dirtyList); 493 Debug << "collected " << (int)dirtyList.size() << " candidates for reevaluation" << endl;494 497 cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 498 495 499 //-- reevaluate the dirty list 496 vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end();500 SubdivisionCandidateContainer::const_iterator sit, sit_end = dirtyList.end(); 497 501 498 502 for (sit = dirtyList.begin(); sit != sit_end; ++ sit) … … 515 519 mTQueue.Push(sc); // reinsert 516 520 } 521 522 long endTime = GetTime(); 523 Real timeDiff = TimeDiff(startTime, endTime); 524 525 mHierarchyStats.repairTime += timeDiff; 526 527 cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 528 } 529 530 531 void HierarchyManager::ResetQueue() 532 { 533 SubdivisionCandidateContainer mCandidateBuffer; 534 535 // remove from queue 536 while (!mTQueue.Empty()) 537 { 538 SubdivisionCandidate *candidate = NextSubdivisionCandidate(); 539 candidate->EvalPriority(); // reevaluate 540 cout << "."; 541 mCandidateBuffer.push_back(candidate); 542 } 543 544 // put back into queue 545 SubdivisionCandidateContainer::const_iterator sit, sit_end = mCandidateBuffer.end(); 546 for (sit = mCandidateBuffer.begin(); sit != sit_end; ++ sit) 547 {cout << ":"; 548 mTQueue.Push(*sit); 549 } 517 550 } 518 551 … … 567 600 568 601 569 void HierarchyManager::PrintObjectSpaceHierarchyStatistics(ofstream &stream) const 570 { 602 void HierarchyManager::PrintHierarchyStatistics(ofstream &stream) const 603 { 604 stream << mHierarchyStats << endl; 605 606 stream << "\nview space:" << endl << endl; 607 stream << mVspTree->GetStatistics() << endl; 608 stream << "\nobject space:" << endl << endl; 571 609 switch (mObjectSpaceSubdivisionType) 572 610 { 573 611 case KD_BASED_OBJ_SUBDIV: 574 612 { 575 stream << mOspTree->GetStatistics() ;613 stream << mOspTree->GetStatistics() << endl; 576 614 break; 577 615 } 578 616 case BV_BASED_OBJ_SUBDIV: 579 617 { 580 stream << mBvHierarchy->GetStatistics() ;618 stream << mBvHierarchy->GetStatistics() << endl; 581 619 break; 582 620 } … … 626 664 627 665 628 } 666 void HierarchyStatistics::Print(ostream &app) const 667 { 668 app << "=========== Hierarchy statistics ===============\n"; 669 670 app << setprecision(4); 671 672 app << "#N_CTIME ( Construction time [s] )\n" << Time() << " \n"; 673 674 app << "#N_RTIME ( Repair time [s] )\n" << repairTime * 1e-3f << " \n"; 675 676 app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 677 678 app << "#N_INTERIORS ( Number of interior nodes )\n" << Interior() << "\n"; 679 680 app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 681 682 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 683 684 app << "========== END OF Hierarchy statistics ==========\n"; 685 } 686 687 688 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1311 r1313 68 68 /// total number of nodes 69 69 int nodes; 70 71 70 /// maximal reached depth 72 71 int maxDepth; 73 74 72 /// accumulated depth 75 73 int accumDepth; 74 75 float repairTime; 76 76 77 77 // Constructor … … 87 87 // TODO: computation wrong 88 88 double AvgDepth() const { return accumDepth / (double)Leaves();} 89 90 89 91 90 void Reset() … … 94 93 maxDepth = 0; 95 94 accumDepth = 0; 96 }97 95 repairTime = 0; 96 } 98 97 99 98 void Print(ostream &app) const; … … 169 168 /** The type of object space subdivison 170 169 */ 171 int HierarchyManager::GetObjectSpaceSubdivisionType() const170 int GetObjectSpaceSubdivisionType() const 172 171 { 173 172 return mObjectSpaceSubdivisionType; … … 187 186 float &contribution) const; 188 187 189 void Print ObjectSpaceHierarchyStatistics(ofstream &stream) const;188 void PrintHierarchyStatistics(ofstream &stream) const; 190 189 191 190 VspTree *GetVspTree() { return mVspTree; } … … 259 258 AxisAlignedBox3 *forcedViewSpace); 260 259 260 bool ObjectSpaceSubdivisionConstructed() const; 261 262 void ResetQueue(); 263 261 264 262 265 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1305 r1313 57 57 }; 58 58 59 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 60 typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer; 59 61 60 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;61 62 typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer;63 62 } 64 63 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1311 r1313 4814 4814 4815 4815 // print subdivision statistics 4816 Debug << mHierarchyManager->GetVspTree()->GetStatistics() << endl; 4817 mHierarchyManager->PrintObjectSpaceHierarchyStatistics(Debug); 4816 mHierarchyManager->PrintHierarchyStatistics(Debug); 4818 4817 4819 4818 if (0) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1308 r1313 749 749 splitCandidate.SetRenderCostDecrease(renderCostDecr); 750 750 751 #if 1751 #if 0 752 752 const float priority = (float)-splitCandidate.mParentData.mDepth; 753 753 #else … … 2677 2677 if (!obj) return; 2678 2678 2679 switch (mHierarchyManager->GetObjectSpaceSubdivis onType())2679 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 2680 2680 { 2681 2681 case HierarchyManager::KD_BASED_OBJ_SUBDIV: … … 2746 2746 int pvs = 0; 2747 2747 2748 switch (mHierarchyManager->GetObjectSpaceSubdivis onType())2748 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 2749 2749 { 2750 2750 case HierarchyManager::NO_OBJ_SUBDIV: … … 2791 2791 return 0; 2792 2792 2793 switch (mHierarchyManager->GetObjectSpaceSubdivis onType())2793 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 2794 2794 { 2795 2795 case HierarchyManager::NO_OBJ_SUBDIV: … … 2844 2844 int pvs = 0; 2845 2845 2846 switch (mHierarchyManager->GetObjectSpaceSubdivis onType())2846 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 2847 2847 { 2848 2848 case HierarchyManager::NO_OBJ_SUBDIV: … … 2895 2895 if (!obj) return; 2896 2896 2897 switch (mHierarchyManager->GetObjectSpaceSubdivis onType())2897 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 2898 2898 { 2899 2899 case HierarchyManager::NO_OBJ_SUBDIV: … … 2932 2932 int pvs = 0; 2933 2933 2934 switch(mHierarchyManager->GetObjectSpaceSubdivis onType())2934 switch(mHierarchyManager->GetObjectSpaceSubdivisionType()) 2935 2935 { 2936 2936 case HierarchyManager::NO_OBJ_SUBDIV:
Note: See TracChangeset
for help on using the changeset viewer.