Changeset 1548 for GTP/trunk/Lib
- Timestamp:
- 10/02/06 08:38:25 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1522 r1548 1663 1663 mBvhStats.Reset(); 1664 1664 mBvhStats.Start(); 1665 1666 1665 mBvhStats.nodes = 1; 1667 1666 … … 1669 1668 BvhSubdivisionCandidate::sBvHierarchy = this; 1670 1669 1670 // create new root 1671 CreateRoot(objects); 1672 1671 1673 // compute bounding box from objects 1672 // note: we assume that root was already created1673 1674 mBoundingBox = mRoot->GetBoundingBox(); 1674 BvhLeaf *bvh leaf = dynamic_cast<BvhLeaf *>(mRoot);1675 BvhLeaf *bvhLeaf = dynamic_cast<BvhLeaf *>(mRoot); 1675 1676 1676 1677 // multiply termination criterium for comparison, … … 1693 1694 1694 1695 // create bvh traversal data 1695 BvhTraversalData oData(bvh leaf, 0, prop, nRays);1696 BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 1696 1697 1697 1698 // create sorted object lists for the first data … … 1709 1710 1710 1711 EvalSubdivisionCandidate(*oSubdivisionCandidate); 1711 bvh leaf->SetSubdivisionCandidate(oSubdivisionCandidate);1712 bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 1712 1713 1713 1714 const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); … … 1784 1785 1785 1786 1787 SubdivisionCandidate *BvHierarchy::Reset(const VssRayContainer &sampleRays, 1788 const ObjectContainer &objects) 1789 { 1790 // reset stats 1791 mBvhStats.Reset(); 1792 mBvhStats.Start(); 1793 mBvhStats.nodes = 1; 1794 1795 // reset root 1796 DEL_PTR(mRoot); 1797 CreateRoot(objects); 1798 1799 #if PROBABILIY_IS_BV_VOLUME 1800 mTermMinProbability *= mBoundingBox.GetVolume(); 1801 // probability that bounding volume is seen 1802 const float prop = GetBoundingBox().GetVolume(); 1803 #else 1804 mTermMinProbability *= mVspTree->GetBoundingBox().GetVolume(); 1805 // probability that volume is "seen" from the view cells 1806 const float prop = EvalViewCellsVolume(objects); 1807 #endif 1808 1809 const int nRays = CountRays(objects); 1810 BvhLeaf *bvhLeaf = dynamic_cast<BvhLeaf *>(mRoot); 1811 1812 // create bvh traversal data 1813 BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 1814 1815 /////////////////// 1816 //-- add first candidate for object space partition 1817 1818 BvhSubdivisionCandidate *oSubdivisionCandidate = 1819 new BvhSubdivisionCandidate(oData); 1820 1821 EvalSubdivisionCandidate(*oSubdivisionCandidate); 1822 bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 1823 1824 const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 1825 mTotalCost = (float)objects.size() * prop / viewSpaceVol; 1826 1827 PrintSubdivisionStats(*oSubdivisionCandidate); 1828 1829 return oSubdivisionCandidate; 1830 } 1831 1832 1786 1833 void BvhStatistics::Print(ostream &app) const 1787 1834 { -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1486 r1548 646 646 float GetMemUsage() const; 647 647 648 /** Creates new root of hierarchy. 649 */ 650 void CreateRoot(const ObjectContainer &objects); 651 648 /** Associates the objects with their bvh leaves. 649 */ 652 650 static void AssociateObjectsWithLeaf(BvhLeaf *leaf); 653 651 … … 655 653 ///////////////////////////// 656 654 // Helper functions for local cost heuristics 657 658 655 659 656 /** Prepare split candidates for cost heuristics using axis aligned splits. … … 769 766 const ObjectContainer &objects); 770 767 768 /** Resets bv hierarchy. E.g. deletes root and resets stats. 769 */ 770 SubdivisionCandidate *Reset( 771 const VssRayContainer &rays, 772 const ObjectContainer &objects); 773 771 774 /** Evaluates volume of view cells that see the objects. 772 775 */ … … 783 786 BvhTraversalData &frontData, 784 787 BvhTraversalData &backData); 785 788 789 /** Creates new root of hierarchy. 790 */ 791 void CreateRoot(const ObjectContainer &objects); 786 792 787 793 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1522 r1548 317 317 #endif 318 318 319 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 320 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 321 319 322 mHierarchyStats.Stop(); 320 323 mVspTree->mVspStats.Stop(); 321 324 FinishObjectSpaceSubdivision(objects); 322 323 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType;324 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType;325 325 } 326 326 … … 330 330 { 331 331 cout << "\nstarting view space hierarchy construction ... " << endl; 332 333 mHierarchyStats.mGlobalCostMisses = 0; // hack: reset global cost misses332 // hack: reset global cost misses 333 mHierarchyStats.mGlobalCostMisses = 0; 334 334 335 335 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); … … 367 367 368 368 cout << "preparing bv hierarchy construction ... " << endl; 369 mBvHierarchy->CreateRoot(objects); 370 369 371 370 // compute first candidate 372 371 SubdivisionCandidate *sc = … … 377 376 378 377 mTQueue.Push(sc); 379 cout << "finished bv hierarchy preparation in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 378 cout << "finished bv hierarchy preparation in " 379 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 380 380 } 381 381 … … 605 605 606 606 607 void HierarchyManager::ResetObjectSpaceSubdivision(const ObjectContainer &objects) 608 { 609 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 610 cout << "\nresetting bv hierarchy" << endl; 611 mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 612 613 DEL_PTR(mBvHierarchy); 614 mBvHierarchy = new BvHierarchy(); 615 mBvHierarchy->mHierarchyManager = this; 607 void HierarchyManager::ResetObjectSpaceSubdivision(const VssRayContainer &sampleRays, 608 const ObjectContainer &objects) 609 { 610 switch (mObjectSpaceSubdivisionType) 611 { 612 case BV_BASED_OBJ_SUBDIV: 613 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 614 cout << "\nresetting bv hierarchy" << endl; 615 mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 616 #if 0 617 DEL_PTR(mBvHierarchy); 618 mBvHierarchy = new BvHierarchy(); 619 mBvHierarchy->mHierarchyManager = this; 620 621 PrepareObjectSpaceSubdivision(sampleRays, objects); 622 #else 623 mBvHierarchy->Reset(sampleRays, objects); 624 #endif 625 break; 626 case KD_BASED_OBJ_SUBDIV: 627 // TODO 628 break; 629 default: 630 break; 631 } 616 632 } 617 633 … … 646 662 RunConstruction(false); 647 663 648 /////////////////649 // now do view space subdivison on the sah bvh nodes650 664 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 651 PrepareViewSpaceSubdivision(sampleRays, objects); 652 653 // process view space candidates 654 RunConstruction(false); 655 656 // again run object space subdivision on the view cells 657 ResetObjectSpaceSubdivision(objects); 658 PrepareObjectSpaceSubdivision(sampleRays, objects); 659 660 // process object space candidates 661 RunConstruction(false); 665 666 const int limit = 2; 667 for (int i = 0; i < limit; ++ i) 668 { 669 // again run object space subdivision on the view cells 670 ResetObjectSpaceSubdivision(sampleRays, objects); 671 672 // process object space candidates 673 RunConstruction(false); 674 675 ///////////////// 676 // now do view space subdivison using the current object space partition 677 // ResetViewSpaceSubdivision(sampleRays, objects); 678 679 // process view space candidates 680 RunConstruction(false); 681 682 cout << "íteration " << i << " of " << limit << " finished" << endl; 683 } 662 684 663 685 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1473 r1548 316 316 AxisAlignedBox3 *forcedViewSpace); 317 317 318 /** Use iteration to construct the object space hierarchy. 319 */ 318 320 void ConstructMultiLevel( 319 321 const VssRayContainer &sampleRays, … … 321 323 AxisAlignedBox3 *forcedViewSpace); 322 324 323 void ResetObjectSpaceSubdivision(const ObjectContainer &objects); 325 /** Reset the object space subdivision. 326 E.g., deletes hierarchy and resets stats. 327 so construction can be restarted. 328 */ 329 void ResetObjectSpaceSubdivision( 330 const VssRayContainer &rays, 331 const ObjectContainer &objects); 324 332 325 333 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
r1501 r1548 640 640 float sum = info.raysBack*(info.position - minBox) + info.raysFront*(maxBox - info.position); 641 641 float newCost = ct_div_ci + sum/sizeBox; 642 float oldCost = info.rays;642 float oldCost = (float)info.rays; 643 643 info.costRatio = newCost/oldCost; 644 644 break; … … 668 668 info.viewCellsFront*(maxBox - info.position); 669 669 float newCost = ct_div_ci + sum/sizeBox; 670 float oldCost = info.viewCells;670 float oldCost = (float)info.viewCells; 671 671 info.costRatio = newCost/oldCost; 672 672 break; 673 673 } 674 674 case 3: { 675 float newCost = info.raysBack*info.pvsBack + info.raysFront*info.pvsFront;675 float newCost = (float)(info.raysBack*info.pvsBack + info.raysFront*info.pvsFront); 676 676 float oldCost = (float)leaf->rays.size()*pvsSize; 677 677 info.costRatio = newCost/oldCost; … … 695 695 case 2: { 696 696 float newCost = (info.pvsBack + info.pvsFront)*0.5f; 697 float oldCost = pvsSize;697 float oldCost = (float)pvsSize; 698 698 info.costRatio = newCost/oldCost; 699 699 break; 700 700 } 701 701 case 3: { 702 float newCost = abs(info.raysBack - info.raysFront);702 float newCost = (float)abs(info.raysBack - info.raysFront); 703 703 float oldCost = (float)leaf->rays.size(); 704 704 info.costRatio = newCost/oldCost; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1545 r1548 2689 2689 } 2690 2690 2691 if (mUsePredefinedViewCells) return 0;2692 2691 ////////////////// 2693 2692 //-- merge leaves of the view cell hierarchy … … 3197 3196 mBspTree->CollectLeaves(leaves); 3198 3197 vector<BspLeaf *>::const_iterator lit, lit_end = leaves.end(); 3199 3198 ViewCell::NewMail(); 3199 3200 3200 for (lit = leaves.begin(); lit != lit_end; ++ lit) 3201 3201 { … … 3203 3203 ViewCell *vc = leaf->GetViewCell(); 3204 3204 3205 vc->SetMergeCost(0.0f); 3206 vcRoot->SetupChildLink(vc); 3207 3208 volume += vc->GetVolume(); 3209 volume += vc->GetVolume(); 3210 3211 vcRoot->SetVolume(volume); 3205 if (!vc->Mailed()) 3206 { 3207 vc->Mail(); 3208 vc->SetMergeCost(0.0f); 3209 vcRoot->SetupChildLink(vc); 3210 3211 volume += vc->GetVolume(); 3212 volume += vc->GetVolume(); 3213 vcRoot->SetVolume(volume); 3214 } 3212 3215 } 3213 3216
Note: See TracChangeset
for help on using the changeset viewer.