Changeset 2575 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 01/03/08 15:53:44 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2571 r2575 24 24 #include "SamplingStrategy.h" 25 25 #include "SceneGraph.h" 26 27 #ifdef PERFTIMER 26 28 #include "Timer/PerfTimer.h" 27 29 #endif // PERFTIMER 28 30 29 31 #define USE_RAY_LENGTH_AS_CONTRIBUTION 0 … … 39 41 40 42 43 #ifdef PERFTIMER 41 44 PerfTimer viewCellCastTimer; 42 45 PerfTimer pvsTimer; 43 46 PerfTimer objTimer; 44 47 #endif 48 45 49 // HACK 46 50 const static bool SAMPLE_AFTER_SUBDIVISION = true; … … 66 70 }; 67 71 72 73 74 struct SortableViewCellEntry { 75 76 SortableViewCellEntry() {} 77 SortableViewCellEntry(const float v, ViewCell *cell):mValue(v), mViewCell(cell) {} 78 79 float mValue; 80 ViewCell *mViewCell; 81 82 friend bool operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b); 83 }; 84 85 86 inline bool 87 operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b) { 88 return a.mValue < b.mValue; 89 } 68 90 69 91 ViewCellsManager::ViewCellsManager(ViewCellsTree *viewCellsTree): … … 1059 1081 int id; 1060 1082 1083 #ifdef PERFTIMER 1061 1084 PerfTimer boxTimer; 1062 1085 1063 1086 boxTimer.Start(); 1064 1087 boxTimer.Entry(); 1065 1088 #endif 1066 1089 for (int i = 0; i < numBoxes; ++ i) 1067 1090 { … … 1074 1097 1075 1098 1099 #ifdef PERFTIMER 1076 1100 boxTimer.Exit(); 1077 1101 1078 1102 Debug << numBoxes << " boxes loaded in " << boxTimer.TotalTime() << " secs" << endl; 1103 #endif 1079 1104 } 1080 1105 … … 1699 1724 inline float EvalMergeCost(ViewCell *root, ViewCell *candidate) 1700 1725 { 1701 1726 return root->GetPvs().GetPvsHomogenity(candidate->GetPvs()); 1702 1727 } 1703 1728 … … 1773 1798 } 1774 1799 1775 1776 struct SortableViewCellEntry {1777 1778 SortableViewCellEntry() {}1779 SortableViewCellEntry(const float v, ViewCell *cell):mValue(v), mViewCell(cell) {}1780 1781 float mValue;1782 ViewCell *mViewCell;1783 1784 friend bool operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b) {1785 return a.mValue < b.mValue;1786 }1787 };1788 1800 1789 1801 … … 2114 2126 } 2115 2127 2128 #ifdef PERFTIMER 2116 2129 cout << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 2117 2130 Debug << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; … … 2119 2132 cout << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 2120 2133 Debug << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 2121 2134 #endif 2122 2135 return sum; 2123 2136 } … … 2869 2882 ViewCell::NewMail(); 2870 2883 2884 #ifdef PERFTIMER 2871 2885 viewCellCastTimer.Entry(); 2872 2886 #endif 2873 2887 static ViewCellContainer viewCells; 2874 2888 static VssRay *lastVssRay = NULL; … … 2889 2903 } 2890 2904 2905 #ifdef PERFTIMER 2891 2906 viewCellCastTimer.Exit(); 2892 2907 #endif 2893 2908 mSamplesStat.mViewCells += (int)viewCells.size(); 2894 2909 … … 2908 2923 Intersectable *terminationObj; 2909 2924 2925 #ifdef PERFTIMER 2910 2926 objTimer.Entry(); 2911 2927 #endif 2912 2928 // obtain pvs entry (can be different from hit object) 2913 2929 terminationObj = ray.mTerminationObject; 2914 2930 2931 #ifdef PERFTIMER 2915 2932 objTimer.Exit(); 2916 2933 2917 2934 pvsTimer.Entry(); 2918 2935 #endif 2936 2919 2937 ViewCellContainer::const_iterator it = viewCells.begin(); 2920 2938 … … 2929 2947 } 2930 2948 2949 #ifdef PERFTIMER 2931 2950 pvsTimer.Exit(); 2932 2951 #endif 2952 2933 2953 mSamplesStat.mPvsContributions += ray.mPvsContribution; 2934 2954 if (ray.mPvsContribution) … … 3460 3480 const float filterSize, 3461 3481 ObjectPvs &pvs, 3462 vector<AxisAlignedBox3> *filteredBoxes 3482 vector<AxisAlignedBox3> *filteredBoxes, 3483 const bool onlyNewObjects 3463 3484 ) 3464 3485 { … … 3480 3501 3481 3502 if (!mUseKdPvs) 3482 { // first mark all objects from this pvs 3483 while (pit.HasMoreEntries()) 3484 pit.Next()->Mail(); 3485 } 3486 3503 { 3504 // first mark all objects from this pvs 3505 while (pit.HasMoreEntries()) 3506 pit.Next()->Mail(); 3507 } 3508 3487 3509 int pvsSize = 0; 3488 3510 int nPvsSize = 0; … … 3548 3570 3549 3571 pit = basePvs.GetIterator(); 3550 3572 3573 if (onlyNewObjects) { 3574 while (pit.HasMoreEntries()) { 3575 // mail all objects from the original not to include them in the 3576 // resulting pvs 3577 Intersectable *obj = pit.Next(pvsData); 3578 obj->Mail(); 3579 } 3580 pit = basePvs.GetIterator(); 3581 } 3582 3551 3583 while (pit.HasMoreEntries()) 3552 3584 { … … 3631 3663 stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 3632 3664 } 3633 3665 3634 3666 //Debug << " nPvs size = " << pvs.GetSize() << endl; 3635 3667 3636 if (!mUseKdPvs )3668 if (!mUseKdPvs && !onlyNewObjects) 3637 3669 { 3638 3670 PvsData pvsData; … … 7162 7194 CLEAR_CONTAINER(tmpRays); 7163 7195 7196 #ifdef PERFTIMER 7164 7197 cout << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 7165 7198 Debug << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 7166 7167 7199 cout << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 7168 7200 Debug << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 7201 #endif 7169 7202 7170 7203 return sum; … … 7174 7207 7175 7208 7176 ViewCellsManager *ViewCellsManager::LoadViewCellsBinary(const string &filename, 7177 ObjectContainer &pvsObjects, 7178 bool finalizeViewCells, 7179 BoundingBoxConverter *bconverter) 7180 { 7181 IN_STREAM stream(filename.c_str()); 7182 7183 if (!stream.is_open()) 7209 ViewCellsManager * 7210 ViewCellsManager::LoadViewCellsBinary(const string &filename, 7211 ObjectContainer &pvsObjects, 7212 bool finalizeViewCells, 7213 BoundingBoxConverter *bconverter) 7214 { 7215 IN_STREAM stream(filename.c_str()); 7216 7217 if (!stream.is_open()) 7184 7218 { 7185 7219 Debug << "View cells loading failed: could not open file" << endl;
Note: See TracChangeset
for help on using the changeset viewer.