Ignore:
Timestamp:
11/24/06 00:24:41 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1784 r1786  
    2929#define USE_FIXEDPOINT_T 0 
    3030 
    31  
     31#define STUPID_METHOD 0 
    3232 
    3333/*******************************************************************/ 
     
    17871787                // hack for choosing which node to account for 
    17881788                if (intersect->IsLeaf()) 
     1789                { 
    17891790                        activeNode = dynamic_cast<BvhLeaf *>(intersect)->GetActiveNode(); 
     1791                } 
    17901792                else 
     1793                { 
    17911794                        activeNode = intersect; 
     1795                } 
    17921796 
    17931797                if (!activeNode->Mailed()) 
     
    17951799                        activeNode->Mail(); 
    17961800 
     1801#if STUPID_METHOD 
     1802 
    17971803                        ObjectContainer objects; 
    1798                         activeNode->CollectObjects(objects); 
    1799  
     1804            activeNode->CollectObjects(objects); 
     1805                        rc += mBvHierarchy->EvalAbsCost(objects); 
     1806#else 
     1807                        rc += mBvHierarchy->GetRenderCostIncrementially(activeNode); 
     1808#endif 
    18001809                        ++ pvsEntries; 
    1801                         rc += mBvHierarchy->EvalAbsCost(objects); 
    18021810                } 
    18031811        } 
     
    18101818        //////////////// 
    18111819        //-- pvs is not stored with the interiors => reconstruct 
    1812         ViewCell *root = vc; 
    18131820         
    18141821        // add pvs from leaves 
     
    18241831                if (!vc->GetPvs().Empty()) 
    18251832                { 
     1833                        if (vc->IsLeaf()) cout << " l " << pvs.GetSize(); 
     1834                        else cout << " i " << pvs.GetSize(); 
    18261835                        pvs.MergeInPlace(vc->GetPvs()); 
    18271836                } 
    18281837                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
    18291838                { 
     1839                        cout <<" t"; 
    18301840                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    18311841                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     
    18361846                        }                
    18371847                } 
    1838         } 
    1839 } 
     1848                else cout <<"k"; 
     1849        } 
     1850} 
     1851 
     1852 
     1853// TODO matt: implement this function for different storing methods 
     1854void HierarchyManager::PullUpPvsIncrementally(ViewCell *viewCell) const 
     1855{ 
     1856        //////////////// 
     1857        //-- pvs is not stored with the interiors => reconstruct 
     1858         
     1859        // early exit: pvs is already pulled up to this view cell 
     1860        if (!viewCell->GetPvs().Empty()) 
     1861                return; 
     1862 
     1863        // add pvs from leaves 
     1864        stack<ViewCell *> tstack; 
     1865        tstack.push(viewCell); 
     1866 
     1867        ViewCell *vc = viewCell; 
     1868 
     1869        while (!tstack.empty()) 
     1870        { 
     1871                vc = tstack.top(); 
     1872                tstack.pop(); 
     1873         
     1874                // add newly found pvs to merged pvs: break here even for interior 
     1875                if (!vc->GetPvs().Empty()) 
     1876                { 
     1877                        /*if (vc->IsLeaf())  
     1878                                cout << " l " << viewCell->GetPvs().GetSize(); 
     1879                        else cout << " i " << viewCell->GetPvs().GetSize(); 
     1880                        */ 
     1881                                viewCell->GetPvs().MergeInPlace(vc->GetPvs()); 
     1882                } 
     1883                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
     1884                { 
     1885                        //cout <<" t"; 
     1886                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1887                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1888 
     1889                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1890                        { 
     1891                                tstack.push(*it); 
     1892                        }                
     1893                } 
     1894        } 
     1895} 
     1896 
     1897 
     1898 
     1899// TODO matt: implement this function for different storing methods 
     1900void HierarchyManager::GetPvsRecursive(ViewCell *vc, ObjectPvs &pvs) const 
     1901{ 
     1902        //////////////// 
     1903        //-- pvs is not stored with the interiors => reconstruct 
     1904        if (vc->IsLeaf() || !vc->GetPvs().Empty()) 
     1905        { 
     1906                pvs = vc->GetPvs(); 
     1907        } 
     1908        else 
     1909        { 
     1910                ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1911#if 0 
     1912                ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1913                const int childPvsSize = (int)interior->mChildren.size(); 
     1914                vector<ObjectPvs> childPvs; 
     1915                childPvs.resize((int)interior->mChildren.size()); 
     1916 
     1917                int i = 0; 
     1918                for (it = interior->mChildren.begin(); it != it_end; ++ it, ++ i) 
     1919                { 
     1920                        GetPvsRecursive(*it, childPvs[i]); 
     1921                        pvs.MergeInPlace(childPvs[i]); 
     1922                } 
     1923#else 
     1924 
     1925                ObjectPvs leftPvs, rightPvs; 
     1926 
     1927                GetPvsRecursive(interior->mChildren[0], leftPvs); 
     1928                GetPvsRecursive(interior->mChildren[1], rightPvs); 
     1929 
     1930                ObjectPvs::Merge(pvs, leftPvs, rightPvs); 
     1931#endif 
     1932        } 
     1933} 
     1934 
    18401935 
    18411936int HierarchyManager::ExtractStatistics(const int maxSplits, 
     
    18681963        ViewCell::NewMail(); 
    18691964 
     1965        cout << "\n**************viewcells: " << viewCells.size() << endl; 
    18701966        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    18711967        { 
    18721968                ViewCell *vc = *vit; 
    18731969 
     1970                //cout << "\nhere5: "; 
    18741971                float rc = 0; 
    1875         ObjectPvs pvs; 
    1876                  
    1877                 //mVspTree->mViewCellsTree->GetPvs(vc, pvs); 
     1972         
     1973#if STUPID_METHOD        
     1974                ObjectPvs pvs; 
    18781975                GetPvsIncrementally(vc, pvs); 
    1879                  
    18801976                vc->SetPvs(pvs); 
     1977#else 
     1978                //PullUpPvsIncrementally(vc); 
     1979                ObjectPvs pvs; 
     1980                GetPvsRecursive(vc, pvs); 
     1981                vc->SetPvs(pvs); 
     1982#endif 
    18811983 
    18821984                vc->Mail(); 
     
    18841986                if (useFilter) 
    18851987                { 
     1988                        const long startT = GetTime(); 
    18861989                        ObjectPvs filteredPvs; 
    18871990                        mVspTree->mViewCellsManager->ApplyFilter2(vc, false, 1.0f, filteredPvs); 
     1991                        const long endT = GetTime(); 
     1992 
     1993                        cout << "filter computed in " << TimeDiff(startT, endT) * 1e-3f << " secs" << endl; 
    18881994                        ComputePvs(filteredPvs, rc, pvsEntries); 
    18891995                } 
    18901996                else 
    18911997                { 
    1892                         ComputePvs(pvs, rc, pvsEntries); 
     1998                        ComputePvs(vc->GetPvs(), rc, pvsEntries); 
    18931999                } 
    18942000 
     
    19152021        } 
    19162022 
     2023        // store current level 
    19172024        mOldViewCells = viewCells; 
    19182025 
     
    20982205        vector<HierarchySubdivisionStats> subStatsContainer; 
    20992206 
    2100         int splits = (1 + mHierarchyStats.Leaves() / splitsStepSize) * splitsStepSize; 
     2207        int splits = (1 + (mHierarchyStats.Leaves() - 1) / splitsStepSize) * splitsStepSize; 
    21012208        cout << "splits: " << splits << endl; 
    21022209 
     
    21332240                 
    21342241                if (splits == 0) 
     2242                { 
    21352243                        break; 
    2136  
     2244                } 
    21372245                splits -= splitsStepSize; 
    21382246 
    2139                 cout << subStats.mNumSplits << " "; 
     2247                cout << "splits: " << subStats.mNumSplits << " "; 
    21402248        } 
    21412249 
Note: See TracChangeset for help on using the changeset viewer.