Ignore:
Timestamp:
07/28/06 09:37:05 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1166 r1168  
    254254 
    255255        // update pvs size scalar 
    256         mPvsSize = mPvs.GetSize(); 
    257         mPvsSizeValid = true; 
     256        //mPvsSize = mPvs.GetSize(); 
     257        mPvsSizeValid = false; // recompute pvs size 
    258258 
    259259        return result; 
     
    886886                const int upper = mViewCellsManager->GetMaxPvsSize(); 
    887887 
    888                 const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountPvs(), lower, upper); 
     888                const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountObjectsInPvs(), lower, upper); 
    889889                 
    890890                mDeviation += fabs(mAvgRenderCost - penalty); 
     
    978978        vc->Mail(); 
    979979 
    980         const int pvs1 = left->GetPvs().CountPvs(); 
    981         const int pvs2 = right->GetPvs().CountPvs(); 
     980        const int pvs1 = left->GetPvs().CountObjectsInPvs(); 
     981        const int pvs2 = right->GetPvs().CountObjectsInPvs(); 
    982982 
    983983 
     
    985985        mMergedViewCells.push_back(vc); 
    986986 
    987         pvsDiff = vc->GetPvs().CountPvs() - pvs1 - pvs2; 
     987        pvsDiff = vc->GetPvs().CountObjectsInPvs() - pvs1 - pvs2; 
    988988 
    989989 
     
    991991        if (mViewCellsStorage == PVS_IN_LEAVES) 
    992992        { 
    993                 left->mPvsSize = left->GetPvs().GetSize();  
    994                 left->mPvsSizeValid = true; 
    995                  
     993                // set scalars 
     994                mViewCellsManager->UpdateScalarPvsSize(left,  
     995                        left->GetPvs().CountObjectsInPvs(),  
     996                        left->GetPvs().GetSize()); 
     997                         
    996998                // remove pvs, we don't store interior pvss 
    997999                if (!left->IsLeaf()) 
     
    10001002                } 
    10011003 
    1002                 right->mPvsSize = right->GetPvs().CountPvs();  
     1004                // set scalars 
     1005                mViewCellsManager->UpdateScalarPvsSize(right,  
     1006                        right->GetPvs().CountObjectsInPvs(),  
     1007                        right->GetPvs().GetSize()); 
     1008 
    10031009                right->mPvsSizeValid = true; 
    10041010                 
     
    12851291        if (1) 
    12861292        { 
    1287                 const float penalty = EvalPvsPenalty(vc->GetPvs().CountPvs(), lower, upper); 
     1293                const float penalty = EvalPvsPenalty(vc->GetPvs().CountObjectsInPvs(), lower, upper); 
    12881294                return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    12891295        } 
     
    12981304        if (mUseAreaForPvs) 
    12991305        { 
    1300                 return vc->GetPvs().CountPvs() * vc->GetArea(); 
    1301         } 
    1302  
    1303         return vc->GetPvs().CountPvs() * vc->GetVolume(); 
     1306                return vc->GetPvs().CountObjectsInPvs() * vc->GetArea(); 
     1307        } 
     1308 
     1309        return vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 
    13041310} 
    13051311 
     
    14691475        const int rootEntries = GetPvsEntries(mRoot); 
    14701476 
     1477        Debug << "******** Export stats **********" << endl; 
    14711478        /*Debug << "vsb volume: " << vol << endl; 
    14721479        Debug << "root volume: " << mRoot->GetVolume() << endl; 
     
    15171524 
    15181525                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    1519  
     1526Debug << "\nhere92" << endl; 
    15201527                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    15211528                        { 
     1529                                Debug << "here15" << endl; 
    15221530                                ViewCell *vc = *it; 
     1531 
    15231532                                const int pvsSize = GetPvsSize(vc); 
    15241533                                const int pvsEntries = GetPvsEntries(vc); 
     
    15321541                        } 
    15331542 
    1534                  
     1543Debug << "\nhere1005" << endl; 
    15351544                        const float costDecr = (parentCost - childCost) / vol; 
    15361545 
     
    16551664} 
    16561665 
     1666 
    16571667// TODO matt: implement this function for different storing methods 
    16581668void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const 
     
    17081718int ViewCellsTree::GetPvsSizeForLeafStorage(ViewCell *vc) const 
    17091719{ 
    1710         int pvsSize = 0; 
    1711  
    17121720        // pvs is always stored directly in leaves 
    17131721        if (vc->IsLeaf()) 
    17141722        { 
    1715                 pvsSize = vc->GetPvs().CountPvs(); 
    1716                 //int pvsSize1 = vc->GetPvs().GetSize(); 
    1717                 //Debug << "entries num: " << pvsSize1 << " size: "" << pvsSize << endl; 
    1718         } 
    1719         else // interior node 
    1720         { 
    1721                 // interior nodes: pvs is either stored as a scalar or 
    1722                 // has to be reconstructed from the leaves 
    1723  
    1724                 // the stored pvs size is the valid pvs size => just return scalar 
    1725                 if (vc->mPvsSizeValid) 
    1726                 { 
    1727                         pvsSize = vc->mPvsSize; 
    1728                 } 
    1729                  
    1730                 // if no valid pvs size stored as a scalar =>  
    1731                 // compute current pvs size of interior from it's leaf nodes 
    1732                 ViewCellContainer leaves; 
    1733                 CollectLeaves(vc, leaves); 
    1734  
    1735                 ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    1736  
    1737                 Intersectable::NewMail(); 
    1738  
    1739                 // sum different intersectables 
    1740                 for (it = leaves.begin(); it != it_end; ++ it) 
    1741                 { 
    1742                         pvsSize = GetPvsSizeForLeafStorage(*it); 
    1743                 } 
    1744         } 
    1745  
    1746         return pvsSize; 
     1723                return vc->GetPvs().CountObjectsInPvs(); 
     1724        } 
     1725         
     1726        // interior node 
     1727         
     1728        // interior nodes: pvs is either stored as a scalar or 
     1729        // has to be reconstructed from the leaves 
     1730 
     1731        // the stored pvs size is the valid pvs size => just return scalar 
     1732        if (vc->mPvsSizeValid) 
     1733        { 
     1734                Debug << "here5"<<endl; 
     1735                return vc->mPvsSize; 
     1736        } 
     1737         
     1738        Debug << "here2"<<endl; 
     1739 
     1740        // if no valid pvs size stored as a scalar =>  
     1741        // compute current pvs size of interior from it's leaf nodes 
     1742        ViewCellContainer leaves; 
     1743        CollectLeaves(vc, leaves); 
     1744 
     1745        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1746 
     1747        Intersectable::NewMail(); 
     1748        ObjectPvs newPvs; 
     1749 
     1750        // sum different intersectables 
     1751        for (it = leaves.begin(); it != it_end; ++ it) 
     1752        { 
     1753                ObjectPvsMap::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 
     1754 
     1755                for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1756                { 
     1757                        Intersectable *intersect = (*oit).first; 
     1758 
     1759                        if (!intersect->Mailed()) 
     1760                        { 
     1761                                intersect->Mail(); 
     1762                                newPvs.AddSample(intersect, (*oit).second.mSumPdf); 
     1763                        } 
     1764                } 
     1765        } 
     1766 
     1767        return newPvs.CountObjectsInPvs(); 
    17471768} 
    17481769 
     
    17501771int ViewCellsTree::GetEntriesInPvsForLeafStorage(ViewCell *vc) const 
    17511772{ 
    1752         int pvsSize = 0; 
    1753  
    17541773        // pvs is always stored directly in leaves 
    17551774        if (vc->IsLeaf()) 
    17561775        { 
    1757                 pvsSize = vc->GetPvs().GetSize(); 
    1758         } 
    1759         else // interior node 
    1760         { 
    1761                 // interior nodes: pvs is either stored as a scalar or 
    1762                 // has to be reconstructed from the leaves 
    1763  
    1764                 // the stored pvs size is the valid pvs size => just return scalar 
    1765                 if (vc->mPvsSizeValid) 
    1766                 { 
    1767                         pvsSize = vc->mEntriesInPvs; 
    1768                 } 
    1769                  
    1770                 // if no valid pvs size stored as a scalar =>  
    1771                 // compute current pvs size of interior from it's leaf nodes 
    1772                 ViewCellContainer leaves; 
    1773                 CollectLeaves(vc, leaves); 
    1774  
    1775                 ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    1776  
    1777                 Intersectable::NewMail(); 
    1778  
    1779                 // sum different intersectables 
    1780                 for (it = leaves.begin(); it != it_end; ++ it) 
    1781                 { 
    1782                         pvsSize = GetEntriesInPvsForLeafStorage(*it); 
     1776                return vc->GetPvs().GetSize(); 
     1777        } 
     1778         
     1779        // interior node 
     1780 
     1781        // interior nodes: pvs is either stored as a scalar or 
     1782        // has to be reconstructed from the leaves 
     1783 
     1784        // the stored pvs size is the valid pvs size => just return scalar 
     1785        if (vc->mPvsSizeValid) 
     1786        { 
     1787                return vc->mEntriesInPvs; 
     1788        } 
     1789         
     1790        int pvsSize = 0; 
     1791 
     1792        // if no valid pvs size stored as a scalar =>  
     1793        // compute current pvs size of interior from it's leaf nodes 
     1794        ViewCellContainer leaves; 
     1795        CollectLeaves(vc, leaves); 
     1796 
     1797        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1798        Intersectable::NewMail(); 
     1799 
     1800        // sum different intersectables 
     1801        for (it = leaves.begin(); it != it_end; ++ it) 
     1802        { 
     1803                ObjectPvsMap::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 
     1804 
     1805                for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     1806                { 
     1807                        Intersectable *intersect = (*oit).first; 
     1808 
     1809                        if (!intersect->Mailed()) 
     1810                        { 
     1811                                intersect->Mail(); 
     1812                                ++ pvsSize; 
     1813                        } 
    17831814                } 
    17841815        } 
     
    19161947                // pvs is stored consistently in the tree up to the root 
    19171948                // just return pvs size  
    1918                 pvsSize = vc->GetPvs().CountPvs();       
     1949                pvsSize = vc->GetPvs().CountObjectsInPvs();      
    19191950                break; 
    19201951        } 
Note: See TracChangeset for help on using the changeset viewer.