Changeset 650 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 02/17/06 20:41:22 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r649 r650 1142 1142 1143 1143 //-- merge view cells 1144 int merged;1145 1146 1144 cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 1147 1145 long startTime = GetTime(); … … 1153 1151 { 1154 1152 Debug << "constructing visibility based merge tree" << endl; 1155 m erged = mViewCellsTree->ConstructMergeTree(rays, objects);1153 mViewCellsTree->ConstructMergeTree(rays, objects); 1156 1154 } 1157 1155 else … … 1159 1157 Debug << "constructing spatial merge tree" << endl; 1160 1158 // create spatial merge hierarchy 1161 merged = ConstructSpatialMergeTree(); 1162 } 1159 mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mBspTree->GetRoot())); 1160 } 1161 1162 mViewCellsTree->ExportStats(); 1163 1163 1164 1164 //-- stats and visualizations 1165 1165 cout << "finished" << endl; 1166 cout << "merged " << merged << "view cells in "1166 cout << "merged view cells in " 1167 1167 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 1168 1168 1169 Debug << "Postprocessing: Merged " << merged << "view cells in "1169 Debug << "Postprocessing: Merged view cells in " 1170 1170 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 1171 1171 … … 1240 1240 } 1241 1241 1242 return merged;1242 return 0; 1243 1243 } 1244 1244 … … 1682 1682 1683 1683 1684 int BspViewCellsManager::ConstructSpatialMergeTree() 1685 { 1686 TraversalQueue tQueue; 1687 1688 tQueue.push(TraversalData(mBspTree->GetRoot(), NULL)); 1689 1690 int merged = 0; 1691 1692 int numViewCells = (int)mViewCells.size(); 1693 1694 float var = 0; 1695 float dev = 0; 1696 int totalPvs = 0; 1697 float totalRenderCost = 0; 1698 float avgRenderCost = 0; 1699 float expCost = 0; 1700 1701 //-- compute statistics values of initial view cells 1702 EvaluateRenderStatistics(totalRenderCost, 1703 expCost, 1704 dev, 1705 var, 1706 totalPvs, 1707 avgRenderCost); 1708 1709 Debug/*mStats*/ << "#Pass\n" << 0 << endl 1710 << "#Merged\n" << merged << endl 1711 << "#ViewCells\n" << numViewCells << endl 1712 << "#RenderCostIncrease\n" << 0 << endl 1713 << "#TotalRenderCost\n" << totalRenderCost << endl 1714 << "#CurrentPvs\n" << 0 << endl 1715 << "#ExpectedCost\n" << expCost << endl 1716 << "#AvgRenderCost\n" << avgRenderCost << endl 1717 << "#Deviation\n" << dev << endl 1718 << "#TotalPvs\n" << totalPvs << endl 1719 << "#PvsSizeDecrease\n0" << endl 1720 << "#Volume\n0" << endl 1721 //<< "#Siblings\n" << mergeStats.siblings << endl 1722 << endl; 1723 1724 1725 while (!tQueue.empty()) 1726 { 1727 TraversalData tData = tQueue.top(); 1728 tQueue.pop(); 1729 1730 if (tData.mNode->IsLeaf()) 1731 { 1732 ViewCell *viewCell = dynamic_cast<BspLeaf *>(tData.mNode)->GetViewCell(); 1733 viewCell->SetMergeCost((float)tData.mNode->mTimeStamp); 1734 1735 Debug << "leaf time stamp: " << tData.mNode->mTimeStamp << endl; 1736 1737 if (tData.mParentViewCell) 1738 { 1739 tData.mParentViewCell->SetupChildLink(viewCell); 1740 // propagate up pvs: could be redone as propagepvs, which propagates pvs up and down 1741 mViewCellsTree->PropagateUpPvs(viewCell); 1742 } 1743 } 1744 else 1745 { 1746 BspInterior *interior = dynamic_cast<BspInterior *>(tData.mNode); 1747 ViewCellInterior *viewCellInterior = new ViewCellInterior(); 1748 1749 ++ merged; 1750 -- numViewCells; 1751 1752 avgRenderCost = totalPvs / numViewCells; 1753 1754 Debug//mStats 1755 << "#Pass\n" << 0 << endl 1756 << "#Merged\n" << merged << endl 1757 << "#ViewCells\n" << numViewCells << endl 1758 << "#RenderCostIncrease\n" << 0 << endl 1759 << "#TotalRenderCost\n" << totalRenderCost << endl 1760 << "#CurrentPvs\n" << 0 << endl 1761 << "#ExpectedCost\n" << 0 << endl 1762 << "#AvgRenderCost\n" << avgRenderCost << endl 1763 << "#Deviation\n" << dev << endl 1764 << "#TotalPvs\n" << totalPvs << endl 1765 << "#PvsSizeDecrease\n" << 0 << endl 1766 << "#Volume\n" << 0 << endl 1767 << endl; 1768 1769 Debug << "interior time stamp: " << tData.mNode->mTimeStamp << endl; 1770 1771 viewCellInterior->SetMergeCost((float)tData.mNode->mTimeStamp); 1772 1773 1774 tQueue.push(TraversalData(interior->GetBack(), viewCellInterior)); 1775 tQueue.push(TraversalData(interior->GetFront(), viewCellInterior)); 1776 1777 if (tData.mParentViewCell) 1778 tData.mParentViewCell->SetupChildLink(viewCellInterior); 1779 } 1780 } 1781 1782 return merged; 1783 } 1684 ViewCell *BspViewCellsManager::ConstructSpatialMergeTree(BspNode *root) 1685 { 1686 if (root->IsLeaf()) 1687 { 1688 ViewCell *viewCell = dynamic_cast<BspLeaf *>(root)->GetViewCell(); 1689 1690 viewCell->SetMergeCost(0.0f); 1691 1692 return viewCell; 1693 } 1694 1695 BspInterior *interior = dynamic_cast<BspInterior *>(root); 1696 ViewCellInterior *viewCellInterior = new ViewCellInterior(); 1697 1698 float mergeCost = 1.0f / (float)root->mTimeStamp; 1699 //Debug << "timestamp: " << root->mTimeStamp; 1700 //Debug << "merge cost: " << mergeCost << endl; 1701 1702 viewCellInterior->SetMergeCost(mergeCost); 1703 1704 float volume = 0; 1705 1706 BspNode *front = interior->GetFront(); 1707 BspNode *back = interior->GetBack(); 1708 1709 // recursivly compute child hierarchies 1710 ViewCell *backVc = ConstructSpatialMergeTree(back); 1711 ViewCell *frontVc = ConstructSpatialMergeTree(front); 1712 1713 viewCellInterior->SetupChildLink(frontVc); 1714 viewCellInterior->SetupChildLink(backVc); 1715 1716 1717 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 1718 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 1719 1720 volume += backVc->GetVolume(); 1721 volume += frontVc->GetVolume(); 1722 1723 viewCellInterior->SetVolume(volume); 1724 1725 return viewCellInterior; 1726 } 1727 1784 1728 1785 1729 /************************************************************************/ … … 2635 2579 Debug << ss << endl; 2636 2580 2637 //-- merge or subdivide view cells 2638 int merged = 0; 2581 //-- merge view cells 2582 2583 cout << "starting merge using " << mPostProcessSamples << " samples ... " << endl; 2584 long startTime = GetTime(); 2585 2586 2639 2587 if (mMergeViewCells) 2640 2588 { 2641 cout << "starting merge using " << mPostProcessSamples << " samples ... " << endl; 2642 long startTime = GetTime(); 2643 2644 2589 Debug << "merging view cells" << endl; 2645 2590 // TODO: should be done BEFORE the ray casting 2646 merged = mViewCellsTree->ConstructMergeTree(rays, objects); 2647 2648 //-- stats and visualizations 2649 cout << "finished merging" << endl; 2650 cout << "merged " << merged << " view cells in " 2651 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 2652 2653 Debug << "Postprocessing: Merged " << merged << " view cells in " 2654 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 2655 } 2591 mViewCellsTree->ConstructMergeTree(rays, objects); 2592 } 2593 else 2594 { 2595 Debug << "spatial merge" << endl; 2596 mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mVspBspTree->GetRoot())); 2597 } 2598 2599 mViewCellsTree->ExportStats(); 2600 2601 //-- stats and visualizations 2602 cout << "finished merging" << endl; 2603 cout << "merged view cells in " 2604 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 2605 2606 Debug << "Postprocessing: Merged view cells in " 2607 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 2608 2656 2609 2657 2610 int savedColorCode = mColorCode; … … 2908 2861 2909 2862 2910 int VspBspViewCellsManager::ConstructSpatialMergeTree() 2911 { 2912 TraversalQueue tQueue; 2913 tQueue.push(TraversalData(mVspBspTree->GetRoot(), NULL)); 2914 2915 int merged = 0; 2916 2917 while (!tQueue.empty()) 2918 { 2919 TraversalData tData = tQueue.top(); 2920 tQueue.pop(); 2921 2922 if (tData.mNode->IsLeaf()) 2923 { 2924 ViewCell *viewCell = dynamic_cast<BspLeaf *>(tData.mNode)->GetViewCell(); 2925 2926 if (tData.mParentViewCell) 2927 { 2928 tData.mParentViewCell->SetupChildLink(viewCell); 2929 // probagate up pvs 2930 mViewCellsTree->PropagateUpPvs(viewCell); 2931 } 2932 } 2933 else 2934 { 2935 BspInterior *interior = dynamic_cast<BspInterior *>(tData.mNode); 2936 ViewCellInterior *viewCellInterior = new ViewCellInterior(); 2937 ++ merged; 2938 2939 tQueue.push(TraversalData(interior->GetBack(), viewCellInterior)); 2940 tQueue.push(TraversalData(interior->GetFront(), viewCellInterior)); 2941 2942 if (tData.mParentViewCell) 2943 tData.mParentViewCell->SetupChildLink(viewCellInterior); 2944 } 2945 } 2946 return merged; 2863 ViewCell *VspBspViewCellsManager::ConstructSpatialMergeTree(BspNode *root) 2864 { 2865 if (root->IsLeaf()) 2866 { 2867 ViewCell *viewCell = dynamic_cast<BspLeaf *>(root)->GetViewCell(); 2868 2869 viewCell->SetMergeCost(0.0f); 2870 2871 return viewCell; 2872 } 2873 2874 BspInterior *interior = dynamic_cast<BspInterior *>(root); 2875 ViewCellInterior *viewCellInterior = new ViewCellInterior(); 2876 2877 float mergeCost = 1.0f / (float)root->mTimeStamp; 2878 //Debug << "timestamp: " << root->mTimeStamp; 2879 //Debug << "merge cost: " << mergeCost << endl; 2880 2881 viewCellInterior->SetMergeCost(mergeCost); 2882 2883 float volume = 0; 2884 2885 BspNode *front = interior->GetFront(); 2886 BspNode *back = interior->GetBack(); 2887 2888 // recursivly compute child hierarchies 2889 ViewCell *backVc = ConstructSpatialMergeTree(back); 2890 ViewCell *frontVc = ConstructSpatialMergeTree(front); 2891 2892 viewCellInterior->SetupChildLink(frontVc); 2893 viewCellInterior->SetupChildLink(backVc); 2894 2895 2896 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 2897 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 2898 2899 volume += backVc->GetVolume(); 2900 volume += frontVc->GetVolume(); 2901 2902 viewCellInterior->SetVolume(volume); 2903 2904 return viewCellInterior; 2947 2905 } 2948 2906
Note: See TracChangeset
for help on using the changeset viewer.