Ignore:
Timestamp:
11/06/06 18:48:22 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1710 r1713  
    17471747                HierarchyNodeWrapper *nodeWrapper = tqueue.top(); 
    17481748                tqueue.pop(); 
    1749  
     1749                //cout << "priority: " << nodeWrapper->GetMergeCost() << endl; 
    17501750                // save the view cells if it is a leaf or if enough view cells have already been traversed 
    17511751                // because of the priority queue, this will be the optimal set of v 
     
    17551755                        ) 
    17561756                { 
    1757                         if (nodeWrapper->Type() == HierarchyNodeWrapper::VSP_NODE) 
     1757                        if (nodeWrapper->Type() == HierarchyNodeWrapper::VIEW_CELL) 
    17581758                        { 
     1759                                //cout << "1"; 
    17591760                                ViewCellWrapper *viewCellWrapper = dynamic_cast<ViewCellWrapper *>(nodeWrapper); 
    17601761                                viewCells.push_back(viewCellWrapper->mViewCell); 
     
    17621763                        else 
    17631764                        { 
     1765                                //cout << "0"; 
    17641766                                BvhNodeWrapper *bvhNodeWrapper = dynamic_cast<BvhNodeWrapper *>(nodeWrapper); 
    17651767                                bvhNodes.push_back(bvhNodeWrapper->mNode); 
     
    17761778 
    17771779 
    1778 bool HierarchyManager::ExtractStatistics(const int maxSplits, 
    1779                                                                                  const float maxMemoryCost, 
    1780                                                                                  float &renderCost, 
    1781                                                                                  float &memory, 
    1782                                                                                  int &pvsEntries) 
     1780int HierarchyManager::ExtractStatistics(const int maxSplits, 
     1781                                                                                const float maxMemoryCost, 
     1782                                                                                float &renderCost, 
     1783                                                                                float &memory, 
     1784                                                                                int &pvsEntries) 
    17831785{ 
    17841786        ViewCellContainer viewCells; 
     
    17871789        // collect best set of view cells for this #splits 
    17881790    CollectBestSet(maxSplits, maxMemoryCost, viewCells, bvhNodes); 
    1789  
     1791        //cout << "here5 " << bvhNodes.size() << endl; 
    17901792        vector<BvhNode *>::const_iterator bit, bit_end = bvhNodes.end(); 
    17911793         
     1794        // set new nodes to be active 
    17921795        for (bit = bvhNodes.begin(); bit != bit_end; ++ bit) 
    17931796        { 
     
    17971800        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    17981801 
    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; 
    18021807        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    18031808        { 
     1809                float rc = 0; 
    18041810                ViewCell *vc = *vit; 
    18051811                ObjectPvs pvs; 
    18061812                mVspTree->mViewCellsTree->GetPvs(vc, pvs); 
    1807  
     1813                //dummy+=pvs.GetSize(); 
    18081814                BvhNode::NewMail(); 
    18091815 
     
    18141820                { 
    18151821                        BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>((*oit).first); 
     1822 
    18161823                        BvhLeaf *leaf = intersect->GetItem(); 
    18171824                        BvhNode *activeNode = leaf->GetActiveNode(); 
     
    18211828                                activeNode->Mail(); 
    18221829 
    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); 
    18251836                        } 
    18261837                } 
    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(); 
    18301849} 
    18311850 
     
    19842003 
    19852004void HierarchyManager::EvaluateSubdivision2(ofstream &splitsStats, 
    1986                                                                                         ofstream &memStats, 
    1987                                                                                         const int splitsStepSize, 
    1988                                                                                         const float memStepSize) 
     2005                                                                                        const int splitsStepSize) 
    19892006{ 
    19902007        int splits = 0; 
    1991         float mem = 15; 
    19922008 
    19932009        float renderCost; 
     
    19972013        while (1) 
    19982014        { 
    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()) 
    20002021                        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.