Changeset 1707 for GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
- Timestamp:
- 11/01/06 23:20:53 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1706 r1707 21 21 #include "OspTree.h" 22 22 #include "BvHierarchy.h" 23 #include "ViewCell.h" 23 24 24 25 … … 1683 1684 // reinstall old bv refs 1684 1685 vector<BvhLeaf *> leaves; 1685 mBvHierarchy->CollectLeaves( leaves);1686 mBvHierarchy->CollectLeaves(mBvHierarchy->GetRoot(), leaves); 1686 1687 vector<BvhLeaf *>::const_iterator bit, bit_end = leaves.end(); 1687 1688 … … 1788 1789 { 1789 1790 public: 1790 enum {VSP_NODE, BVH_NODE };1791 enum {VSP_NODE, BVH_NODE, VIEW_CELL}; 1791 1792 1792 1793 virtual float GetMergeCost() const = 0; … … 1850 1851 1851 1852 1853 class ViewCellWrapper: public HierarchyNodeWrapper 1854 { 1855 public: 1856 1857 ViewCellWrapper(ViewCell *vc): mViewCell(vc) {} 1858 1859 int Type() const { return VIEW_CELL; } 1860 1861 float GetMergeCost() const { return mViewCell->GetMergeCost(); }; 1862 1863 bool IsLeaf() const { return mViewCell->IsLeaf(); } 1864 1865 void PushChildren(HierarchyNodeQueue &tQueue) 1866 { 1867 if (!mViewCell->IsLeaf()) 1868 { 1869 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(mViewCell); 1870 1871 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1872 1873 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1874 { 1875 tQueue.push(new ViewCellWrapper(*it)); 1876 } 1877 } 1878 } 1879 1880 ViewCell *mViewCell; 1881 }; 1882 1883 1852 1884 void HierarchyManager::CollectBestSet(const int maxSplits, 1853 1885 const float maxMemoryCost, 1854 vector<VspNode *> &vspNodes, 1886 // vector<VspNode *> &vspNodes, 1887 ViewCellContainer &viewCells, 1855 1888 vector<BvhNode *> &bvhNodes) 1856 1889 { 1857 1890 HierarchyNodeQueue tqueue; 1858 tqueue.push(new VspNodeWrapper(mVspTree->GetRoot())); 1891 //tqueue.push(new VspNodeWrapper(mVspTree->GetRoot())); 1892 tqueue.push(new ViewCellWrapper(mVspTree->mViewCellsTree->GetRoot())); 1859 1893 tqueue.push(new BvhNodeWrapper(mBvHierarchy->GetRoot())); 1860 1894 … … 1869 1903 // because of the priority queue, this will be the optimal set of v 1870 1904 if (nodeWrapper->IsLeaf() || 1871 ((v spNodes.size() + bvhNodes.size() + tqueue.size() + 1) >= maxSplits) ||1905 ((viewCells.size() + bvhNodes.size() + tqueue.size() + 1) >= maxSplits) || 1872 1906 (memCost > maxMemoryCost) 1873 1907 ) … … 1875 1909 if (nodeWrapper->Type() == HierarchyNodeWrapper::VSP_NODE) 1876 1910 { 1877 V spNodeWrapper *vspNodeWrapper = dynamic_cast<VspNodeWrapper *>(nodeWrapper);1878 v spNodes.push_back(vspNodeWrapper->mNode);1911 ViewCellWrapper *viewCellWrapper = dynamic_cast<ViewCellWrapper *>(nodeWrapper); 1912 viewCells.push_back(viewCellWrapper->mViewCell); 1879 1913 } 1880 1914 else … … 1900 1934 int &pvsEntries) 1901 1935 { 1936 //vector<VspNode *> vspNodes; 1937 ViewCellContainer viewCells; 1938 vector<BvhNode *> bvhNodes; 1939 1940 CollectBestSet(maxSplits, maxMemoryCost, viewCells, bvhNodes); 1941 1942 vector<BvhNode *>::const_iterator bit, bit_end = bvhNodes.end(); 1943 1944 for (bit = bvhNodes.begin(); bit != bit_end; ++ bit) 1945 { 1946 mBvHierarchy->SetActive(*bit); 1947 } 1948 1949 //vector<VspNode *>::const_iterator vit, vit_end = vspNodes.end(); 1950 1951 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1952 1953 int numEntries = 0; 1954 float pvsCost = 0.0f; 1955 1956 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1957 { 1958 ViewCell *vc = *vit; 1959 ObjectPvs pvs; 1960 mVspTree->mViewCellsTree->GetPvs(vc, pvs); 1961 1962 BvhNode::NewMail(); 1963 1964 // hack: should not be done here 1965 ObjectPvsMap::const_iterator oit, oit_end = pvs.mEntries.end(); 1966 1967 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 1968 { 1969 BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>((*oit).first); 1970 BvhLeaf *leaf = intersect->GetItem(); 1971 BvhNode *activeNode = leaf->GetActiveNode(); 1972 1973 if (!activeNode->Mailed()) 1974 { 1975 activeNode->Mail(); 1976 1977 ++ numEntries; 1978 pvsCost += mBvHierarchy->EvalAbsCost(leaf->mObjects); 1979 } 1980 } 1981 } 1982 1902 1983 /*TraversalQueue tqueue; 1903 1984 tqueue.push(mRoot);
Note: See TracChangeset
for help on using the changeset viewer.