Changeset 1750 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 11/14/06 22:32:51 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1749 r1750 1859 1859 1860 1860 1861 // TODO matt: implement this function for different storing methods 1862 void 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 1861 1895 int HierarchyManager::ExtractStatistics(const int maxSplits, 1862 1896 const float maxMemoryCost, … … 1887 1921 renderCost = 0.0f; 1888 1922 1923 ViewCell::NewMail(); 1924 1889 1925 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1890 1926 { 1927 ViewCell *vc = *vit; 1928 1891 1929 float rc = 0; 1892 ViewCell *vc = *vit; 1893 1894 ObjectPvs pvs; 1930 ObjectPvs pvs; 1895 1931 mVspTree->mViewCellsTree->GetPvs(vc, pvs); 1896 1932 1933 vc->SetPvs(pvs); 1934 1935 vc->Mail(); 1936 1897 1937 if (useFilter) 1898 1938 { 1899 ViewCellLeaf dummy;1900 dummy.SetPvs(pvs);1901 1939 ObjectPvs filteredPvs; 1902 mVspTree->mViewCellsManager->ApplyFilter2( &dummy, false, 1.0f, filteredPvs);1940 mVspTree->mViewCellsManager->ApplyFilter2(vc, false, 1.0f, filteredPvs); 1903 1941 ComputePvs(filteredPvs, rc, pvsEntries); 1904 1942 } … … 1913 1951 1914 1952 renderCost /= mVspTree->mViewCellsManager->GetViewSpaceBox().GetVolume(); 1915 1916 1953 memory = pvsEntries * ObjectPvs::GetEntrySize(); 1917 1954 1918 1955 viewSpaceSplits = (int)viewCells.size(); 1919 1956 objectSpaceSplits = (int)bvhNodes.size(); 1920 1921 1957 //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; 1922 1971 1923 1972 return viewCells.size() + bvhNodes.size(); … … 2099 2148 const bool useFilter) 2100 2149 { 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; 2104 2154 2105 2155 while (1) 2106 2156 { 2157 HierarchySubdivisionStats subStats; 2107 2158 subStats.mNumSplits = ExtractStatistics(splits, 2108 2159 99999.0, … … 2131 2182 subStats.mFullMemory = subStats.mMemoryCost + objectSpaceHierarchyMem + viewSpaceHierarchyMem; 2132 2183 2133 subStats.Print(splitsStats); 2134 splits += splitsStepSize; 2135 2136 if (subStats.mNumSplits == mHierarchyStats.Leaves()) 2184 subStatsContainer.push_back(subStats); 2185 2186 if (splits == 0) 2137 2187 break; 2138 2188 2189 splits -= splitsStepSize; 2190 2139 2191 cout << subStats.mNumSplits << " "; 2140 2192 } 2141 2193 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 2142 2213 cout << endl; 2143 2214 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1745 r1750 527 527 528 528 void ComputePvs(const ObjectPvs &pvs, float &rc, int &pvsEntries); 529 529 void GetPvsIncrementally(ViewCell *vc, ObjectPvs &pvs) const; 530 530 protected: 531 531 … … 639 639 friend ViewCellsParseHandlers; 640 640 641 ViewCellContainer mOldViewCells; 641 642 }; 642 643 -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1745 r1750 244 244 /** Clears the pvs. 245 245 */ 246 void Clear(); 246 void Clear(const bool trim = true); 247 248 void Trim(); 247 249 248 250 static int GetEntrySizeByte(); … … 438 440 mergedPvs.mEntries.push_back(*bit); 439 441 } 440 } 441 442 443 template <typename T, typename S> void Pvs<T, S>::Clear() 442 mergedPvs.mSamples = a.mSamples + b.mSamples; 443 } 444 445 446 template <typename T, typename S> void Pvs<T, S>::Clear(const bool trim = true) 444 447 { 445 448 mEntries.clear(); 449 mSamples = 0; 450 vector<PvsEntry<T,S> >().swap(mEntries); 451 } 452 453 454 template <typename T, typename S> void Pvs<T, S>::Trim() 455 { 456 vector<PvsEntry<T,S> >(mEntries).swap(mEntries);//trim vi 446 457 } 447 458 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1749 r1750 1727 1727 //////////////// 1728 1728 //-- pvs is not stored with the interiors => reconstruct 1729 Intersectable::NewMail();1730 1731 1729 ViewCell *root = vc; 1732 1730 … … 1748 1746 1749 1747 // add newly found pvs to merged pvs 1750 //cout << "samples vc: " << vc->GetPvs().GetSamples() << " samples pvs: " << pvs.GetSamples() << endl;1751 1748 pvs.MergeInPlace(vc->GetPvs()); 1752 //cout << "new samples: " << pvs.GetSamples() << endl;1749 1753 1750 if (!vc->IsLeaf()) // interior cells: go down to leaf level 1754 1751 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1749 r1750 2615 2615 float samples = (float)pvs.GetSamples(); 2616 2616 cout<<"Samples = "<<samples<<endl; 2617 cout<<"size = "<<pvs.GetSize() <<endl; 2617 2618 // cout<<"Filter size = "<<filterSize<<endl; 2618 2619 // cout<<"vbox = "<<vbox<<endl; … … 6063 6064 Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 6064 6065 6065 #if 16066 #if 0 6066 6067 //////////////////////////// 6067 6068 // filtered stats
Note: See TracChangeset
for help on using the changeset viewer.