Changeset 1786 for GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
- Timestamp:
- 11/24/06 00:24:41 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1784 r1786 29 29 #define USE_FIXEDPOINT_T 0 30 30 31 31 #define STUPID_METHOD 0 32 32 33 33 /*******************************************************************/ … … 1787 1787 // hack for choosing which node to account for 1788 1788 if (intersect->IsLeaf()) 1789 { 1789 1790 activeNode = dynamic_cast<BvhLeaf *>(intersect)->GetActiveNode(); 1791 } 1790 1792 else 1793 { 1791 1794 activeNode = intersect; 1795 } 1792 1796 1793 1797 if (!activeNode->Mailed()) … … 1795 1799 activeNode->Mail(); 1796 1800 1801 #if STUPID_METHOD 1802 1797 1803 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 1800 1809 ++ pvsEntries; 1801 rc += mBvHierarchy->EvalAbsCost(objects);1802 1810 } 1803 1811 } … … 1810 1818 //////////////// 1811 1819 //-- pvs is not stored with the interiors => reconstruct 1812 ViewCell *root = vc;1813 1820 1814 1821 // add pvs from leaves … … 1824 1831 if (!vc->GetPvs().Empty()) 1825 1832 { 1833 if (vc->IsLeaf()) cout << " l " << pvs.GetSize(); 1834 else cout << " i " << pvs.GetSize(); 1826 1835 pvs.MergeInPlace(vc->GetPvs()); 1827 1836 } 1828 1837 else if (!vc->IsLeaf()) // interior cells: go down to leaf level 1829 1838 { 1839 cout <<" t"; 1830 1840 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1831 1841 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); … … 1836 1846 } 1837 1847 } 1838 } 1839 } 1848 else cout <<"k"; 1849 } 1850 } 1851 1852 1853 // TODO matt: implement this function for different storing methods 1854 void 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 1900 void 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 1840 1935 1841 1936 int HierarchyManager::ExtractStatistics(const int maxSplits, … … 1868 1963 ViewCell::NewMail(); 1869 1964 1965 cout << "\n**************viewcells: " << viewCells.size() << endl; 1870 1966 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1871 1967 { 1872 1968 ViewCell *vc = *vit; 1873 1969 1970 //cout << "\nhere5: "; 1874 1971 float rc = 0; 1875 ObjectPvs pvs;1876 1877 //mVspTree->mViewCellsTree->GetPvs(vc, pvs);1972 1973 #if STUPID_METHOD 1974 ObjectPvs pvs; 1878 1975 GetPvsIncrementally(vc, pvs); 1879 1880 1976 vc->SetPvs(pvs); 1977 #else 1978 //PullUpPvsIncrementally(vc); 1979 ObjectPvs pvs; 1980 GetPvsRecursive(vc, pvs); 1981 vc->SetPvs(pvs); 1982 #endif 1881 1983 1882 1984 vc->Mail(); … … 1884 1986 if (useFilter) 1885 1987 { 1988 const long startT = GetTime(); 1886 1989 ObjectPvs filteredPvs; 1887 1990 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; 1888 1994 ComputePvs(filteredPvs, rc, pvsEntries); 1889 1995 } 1890 1996 else 1891 1997 { 1892 ComputePvs( pvs, rc, pvsEntries);1998 ComputePvs(vc->GetPvs(), rc, pvsEntries); 1893 1999 } 1894 2000 … … 1915 2021 } 1916 2022 2023 // store current level 1917 2024 mOldViewCells = viewCells; 1918 2025 … … 2098 2205 vector<HierarchySubdivisionStats> subStatsContainer; 2099 2206 2100 int splits = (1 + mHierarchyStats.Leaves() / splitsStepSize) * splitsStepSize;2207 int splits = (1 + (mHierarchyStats.Leaves() - 1) / splitsStepSize) * splitsStepSize; 2101 2208 cout << "splits: " << splits << endl; 2102 2209 … … 2133 2240 2134 2241 if (splits == 0) 2242 { 2135 2243 break; 2136 2244 } 2137 2245 splits -= splitsStepSize; 2138 2246 2139 cout << subStats.mNumSplits << " ";2247 cout << "splits: " << subStats.mNumSplits << " "; 2140 2248 } 2141 2249
Note: See TracChangeset
for help on using the changeset viewer.