Changeset 1713 for GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
- Timestamp:
- 11/06/06 18:48:22 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1710 r1713 1747 1747 HierarchyNodeWrapper *nodeWrapper = tqueue.top(); 1748 1748 tqueue.pop(); 1749 1749 //cout << "priority: " << nodeWrapper->GetMergeCost() << endl; 1750 1750 // save the view cells if it is a leaf or if enough view cells have already been traversed 1751 1751 // because of the priority queue, this will be the optimal set of v … … 1755 1755 ) 1756 1756 { 1757 if (nodeWrapper->Type() == HierarchyNodeWrapper::V SP_NODE)1757 if (nodeWrapper->Type() == HierarchyNodeWrapper::VIEW_CELL) 1758 1758 { 1759 //cout << "1"; 1759 1760 ViewCellWrapper *viewCellWrapper = dynamic_cast<ViewCellWrapper *>(nodeWrapper); 1760 1761 viewCells.push_back(viewCellWrapper->mViewCell); … … 1762 1763 else 1763 1764 { 1765 //cout << "0"; 1764 1766 BvhNodeWrapper *bvhNodeWrapper = dynamic_cast<BvhNodeWrapper *>(nodeWrapper); 1765 1767 bvhNodes.push_back(bvhNodeWrapper->mNode); … … 1776 1778 1777 1779 1778 boolHierarchyManager::ExtractStatistics(const int maxSplits,1779 1780 1781 1782 1780 int HierarchyManager::ExtractStatistics(const int maxSplits, 1781 const float maxMemoryCost, 1782 float &renderCost, 1783 float &memory, 1784 int &pvsEntries) 1783 1785 { 1784 1786 ViewCellContainer viewCells; … … 1787 1789 // collect best set of view cells for this #splits 1788 1790 CollectBestSet(maxSplits, maxMemoryCost, viewCells, bvhNodes); 1789 1791 //cout << "here5 " << bvhNodes.size() << endl; 1790 1792 vector<BvhNode *>::const_iterator bit, bit_end = bvhNodes.end(); 1791 1793 1794 // set new nodes to be active 1792 1795 for (bit = bvhNodes.begin(); bit != bit_end; ++ bit) 1793 1796 { … … 1797 1800 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1798 1801 1799 int numEntries = 0; 1800 float pvsCost = 0.0f; 1801 1802 pvsEntries = 0; 1803 renderCost = 0.0f; 1804 1805 //BvhNode::NewMail(); 1806 //int dummy = 0; 1802 1807 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1803 1808 { 1809 float rc = 0; 1804 1810 ViewCell *vc = *vit; 1805 1811 ObjectPvs pvs; 1806 1812 mVspTree->mViewCellsTree->GetPvs(vc, pvs); 1807 1813 //dummy+=pvs.GetSize(); 1808 1814 BvhNode::NewMail(); 1809 1815 … … 1814 1820 { 1815 1821 BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>((*oit).first); 1822 1816 1823 BvhLeaf *leaf = intersect->GetItem(); 1817 1824 BvhNode *activeNode = leaf->GetActiveNode(); … … 1821 1828 activeNode->Mail(); 1822 1829 1823 ++ numEntries; 1824 pvsCost += mBvHierarchy->EvalAbsCost(leaf->mObjects); 1830 ObjectContainer objects; 1831 activeNode->CollectObjects(objects); 1832 1833 ++ pvsEntries; 1834 rc += mBvHierarchy->EvalAbsCost(objects); 1835 //cout << " pvs: " << mBvHierarchy->EvalAbsCost(leaf->mObjects); 1825 1836 } 1826 1837 } 1827 } 1828 1829 return ((int)(viewCells.size() + bvhNodes.size()) < mHierarchyStats.Leaves()); 1838 1839 rc *= vc->GetVolume(); 1840 renderCost += rc; 1841 } 1842 1843 renderCost /= mVspTree->mViewCellsManager->GetViewSpaceBox().GetVolume(); 1844 1845 memory = pvsEntries * ObjectPvs::GetEntrySize(); 1846 //cout << "viewCells: " << (int)viewCells.size() << " nodes: " << (int)bvhNodes.size() << " rc: " << renderCost << " entries: " << pvsEntries << endl; 1847 1848 return viewCells.size() + bvhNodes.size(); 1830 1849 } 1831 1850 … … 1984 2003 1985 2004 void HierarchyManager::EvaluateSubdivision2(ofstream &splitsStats, 1986 ofstream &memStats, 1987 const int splitsStepSize, 1988 const float memStepSize) 2005 const int splitsStepSize) 1989 2006 { 1990 2007 int splits = 0; 1991 float mem = 15;1992 2008 1993 2009 float renderCost; … … 1997 2013 while (1) 1998 2014 { 1999 if (!ExtractStatistics(splits, 99999.0, renderCost, memory, pvsEntries)) 2015 const int numSplits = ExtractStatistics(splits, 99999.0, renderCost, memory, pvsEntries); 2016 2017 UpdateStats(splitsStats, numSplits, renderCost, pvsEntries, memory, 0); 2018 splits += splitsStepSize; 2019 2020 if (numSplits == mHierarchyStats.Leaves()) 2000 2021 break; 2001 2002 UpdateStats(splitsStats, splits, renderCost, pvsEntries, memory, 0); 2003 2004 splits += splitsStepSize; 2005 } 2006 2007 while (1) 2008 { 2009 if (!ExtractStatistics(99999999, mem, renderCost, memory, pvsEntries)) 2010 break; 2011 2012 UpdateStats(splitsStats, splits, renderCost, pvsEntries, memory, 0); 2013 2014 mem += memStepSize; 2015 } 2016 2017 } 2018 2019 } 2022 } 2023 } 2024 2025 }
Note: See TracChangeset
for help on using the changeset viewer.