Changeset 1750


Ignore:
Timestamp:
11/14/06 22:32:51 (18 years ago)
Author:
mattausch
Message:

improved evaluation speed

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

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

    r1749 r1750  
    18591859 
    18601860 
     1861// TODO matt: implement this function for different storing methods 
     1862void HierarchyManager::GetPvsIncrementally(ViewCell *vc, ObjectPvs &pvs) const 
     1863{ 
     1864        //////////////// 
     1865        //-- pvs is not stored with the interiors => reconstruct 
     1866        ViewCell *root = vc; 
     1867         
     1868        // add pvs from leaves 
     1869        stack<ViewCell *> tstack; 
     1870        tstack.push(vc); 
     1871 
     1872        while (!tstack.empty()) 
     1873        { 
     1874                vc = tstack.top(); 
     1875                tstack.pop(); 
     1876         
     1877                // add newly found pvs to merged pvs: break here even for interior 
     1878                if (!vc->GetPvs().Empty()) 
     1879                { 
     1880                        pvs.MergeInPlace(vc->GetPvs()); 
     1881                } 
     1882                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
     1883                { 
     1884                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1885                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1886 
     1887                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1888                        { 
     1889                                tstack.push(*it); 
     1890                        }                
     1891                } 
     1892        } 
     1893} 
     1894 
    18611895int HierarchyManager::ExtractStatistics(const int maxSplits, 
    18621896                                                                                const float maxMemoryCost, 
     
    18871921        renderCost = 0.0f; 
    18881922 
     1923        ViewCell::NewMail(); 
     1924 
    18891925        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    18901926        { 
     1927                ViewCell *vc = *vit; 
     1928 
    18911929                float rc = 0; 
    1892                 ViewCell *vc = *vit; 
    1893  
    1894                 ObjectPvs pvs; 
     1930        ObjectPvs pvs; 
    18951931                mVspTree->mViewCellsTree->GetPvs(vc, pvs); 
    18961932 
     1933                vc->SetPvs(pvs); 
     1934 
     1935                vc->Mail(); 
     1936 
    18971937                if (useFilter) 
    18981938                { 
    1899                         ViewCellLeaf dummy; 
    1900                         dummy.SetPvs(pvs); 
    19011939                        ObjectPvs filteredPvs; 
    1902                         mVspTree->mViewCellsManager->ApplyFilter2(&dummy, false, 1.0f, filteredPvs); 
     1940                        mVspTree->mViewCellsManager->ApplyFilter2(vc, false, 1.0f, filteredPvs); 
    19031941                        ComputePvs(filteredPvs, rc, pvsEntries); 
    19041942                } 
     
    19131951 
    19141952        renderCost /= mVspTree->mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    1915  
    19161953        memory = pvsEntries * ObjectPvs::GetEntrySize(); 
    19171954 
    19181955        viewSpaceSplits = (int)viewCells.size(); 
    19191956        objectSpaceSplits = (int)bvhNodes.size(); 
    1920  
    19211957        //cout << "viewCells: " << (int)viewCells.size() << " nodes: " << (int)bvhNodes.size() << " rc: " << renderCost << " entries: " << pvsEntries << endl; 
     1958 
     1959        // delete old "base" view cells if they are not leaves 
     1960        ViewCellContainer::const_iterator oit, oit_end = mOldViewCells.end(); 
     1961 
     1962        for (oit = mOldViewCells.begin(); oit != oit_end; ++ oit) 
     1963        { 
     1964                if (!(*oit)->Mailed() && !(*oit)->IsLeaf()) 
     1965                { 
     1966                        (*oit)->GetPvs().Clear(); 
     1967                } 
     1968        } 
     1969 
     1970        mOldViewCells = viewCells; 
    19221971 
    19231972        return viewCells.size() + bvhNodes.size(); 
     
    20992148                                                                                        const bool useFilter) 
    21002149{ 
    2101         HierarchySubdivisionStats subStats; 
    2102          
    2103         int splits = 0; 
     2150        vector<HierarchySubdivisionStats> subStatsContainer; 
     2151 
     2152        int splits = (1 + mHierarchyStats.Leaves() / splitsStepSize) * splitsStepSize; 
     2153        cout << "splits: " << splits << endl; 
    21042154 
    21052155        while (1) 
    21062156        { 
     2157                HierarchySubdivisionStats subStats; 
    21072158                subStats.mNumSplits = ExtractStatistics(splits,  
    21082159                                                                                                99999.0,  
     
    21312182                subStats.mFullMemory = subStats.mMemoryCost + objectSpaceHierarchyMem + viewSpaceHierarchyMem; 
    21322183                 
    2133                 subStats.Print(splitsStats); 
    2134                 splits += splitsStepSize; 
    2135  
    2136                 if (subStats.mNumSplits == mHierarchyStats.Leaves()) 
     2184                subStatsContainer.push_back(subStats); 
     2185                 
     2186                if (splits == 0) 
    21372187                        break; 
    21382188 
     2189                splits -= splitsStepSize; 
     2190 
    21392191                cout << subStats.mNumSplits << " "; 
    21402192        } 
    21412193 
     2194        vector<HierarchySubdivisionStats>::const_reverse_iterator hit, hit_end = subStatsContainer.rend(); 
     2195 
     2196        for (hit = subStatsContainer.rbegin(); hit != hit_end; ++ hit) 
     2197        { 
     2198                (*hit).Print(splitsStats); 
     2199        } 
     2200 
     2201        // delete old "base" view cells: only pvss in the leaves are allowed 
     2202        ViewCellContainer::const_iterator oit, oit_end = mOldViewCells.end(); 
     2203        for (oit = mOldViewCells.begin(); oit != oit_end; ++ oit) 
     2204        { 
     2205                if (!(*oit)->IsLeaf()) 
     2206                { 
     2207                        (*oit)->GetPvs().Clear(); 
     2208                } 
     2209        } 
     2210 
     2211        mOldViewCells.clear(); 
     2212 
    21422213        cout << endl; 
    21432214} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1745 r1750  
    527527 
    528528        void ComputePvs(const ObjectPvs &pvs, float &rc, int &pvsEntries); 
    529  
     529        void GetPvsIncrementally(ViewCell *vc, ObjectPvs &pvs) const; 
    530530protected: 
    531531 
     
    639639        friend ViewCellsParseHandlers; 
    640640 
     641        ViewCellContainer mOldViewCells; 
    641642}; 
    642643 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1745 r1750  
    244244        /** Clears the pvs. 
    245245        */ 
    246         void Clear(); 
     246        void Clear(const bool trim = true); 
     247 
     248        void Trim(); 
    247249 
    248250        static int GetEntrySizeByte();  
     
    438440                mergedPvs.mEntries.push_back(*bit); 
    439441        } 
    440 } 
    441  
    442  
    443 template <typename T, typename S> void Pvs<T, S>::Clear() 
     442        mergedPvs.mSamples = a.mSamples + b.mSamples; 
     443} 
     444 
     445 
     446template <typename T, typename S> void Pvs<T, S>::Clear(const bool trim = true) 
    444447{ 
    445448        mEntries.clear(); 
     449        mSamples = 0; 
     450        vector<PvsEntry<T,S> >().swap(mEntries); 
     451} 
     452 
     453 
     454template <typename T, typename S> void Pvs<T, S>::Trim() 
     455{ 
     456        vector<PvsEntry<T,S> >(mEntries).swap(mEntries);//trim vi 
    446457} 
    447458 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1749 r1750  
    17271727        //////////////// 
    17281728        //-- pvs is not stored with the interiors => reconstruct 
    1729         Intersectable::NewMail(); 
    1730  
    17311729        ViewCell *root = vc; 
    17321730         
     
    17481746         
    17491747                // add newly found pvs to merged pvs 
    1750                 //cout << "samples vc: " << vc->GetPvs().GetSamples() << " samples pvs: " << pvs.GetSamples() << endl; 
    17511748                pvs.MergeInPlace(vc->GetPvs()); 
    1752                 //cout << "new samples: " << pvs.GetSamples() << endl; 
     1749                 
    17531750                if (!vc->IsLeaf()) // interior cells: go down to leaf level 
    17541751                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1749 r1750  
    26152615  float samples = (float)pvs.GetSamples(); 
    26162616  cout<<"Samples = "<<samples<<endl; 
     2617   cout<<"size = "<<pvs.GetSize() <<endl; 
    26172618  //  cout<<"Filter size = "<<filterSize<<endl; 
    26182619  //  cout<<"vbox = "<<vbox<<endl; 
     
    60636064                        Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 
    60646065 
    6065 #if 1 
     6066#if 0 
    60666067                        //////////////////////////// 
    60676068                        // filtered stats 
Note: See TracChangeset for help on using the changeset viewer.