Changeset 1919 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 12/21/06 23:52:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1918 r1919 147 147 148 148 // mix of sampling strategies 149 mStrategies.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 150 151 /*mStrategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 152 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 153 mStrategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 154 */ 155 //mStrategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 149 if (0) 150 { 151 mStrategies.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 152 } 153 else 154 { 155 /*mStrategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 156 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 157 mStrategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 158 */ 159 160 mStrategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 161 } 156 162 157 163 Debug << "casting strategies: "; … … 955 961 956 962 it = viewCells.begin(); 963 964 for (int j = 0; j < intervals; ++ j) 965 { 966 float volDif = 0; 967 int smallerDif = 0; 968 969 while ((i < (int)viewCells.size()) && 970 (viewCells[i]->GetPvsCost() < currentPvs)) 971 { 972 volDif += viewCells[i]->GetVolume(); 973 volSum += viewCells[i]->GetVolume(); 974 975 ++ i; 976 ++ smallerDif; 977 ++ smallerSum; 978 } 979 980 // if (0 && (i < (int)viewCells.size())) 981 // Debug << "new pvs cost increase: " << mViewCellsTree->GetPvsCost(viewCells[i]) 982 // << " " << currentPvs << endl; 983 984 const float volRatioDif = volDif / totalVol; 985 const float volRatioSum = volSum / totalVol; 986 987 outstream << "#Pass\n" << j << endl; 988 outstream << "#Pvs\n" << currentPvs << endl; 989 outstream << "#ViewCellsDif\n" << smallerDif << endl; 990 outstream << "#ViewCellsSum\n" << smallerSum << endl; 991 outstream << "#VolumeDif\n" << volRatioDif << endl << endl; 992 outstream << "#VolumeSum\n" << volRatioSum << endl << endl; 993 994 //-- increase current pvs size to define next interval 995 currentPvs += stepSize; 996 } 997 998 outstream.close(); 999 } 1000 1001 1002 void ViewCellsManager::EvalViewCellHistogramForPvsSize(const string filename, 1003 ViewCellContainer &viewCells) 1004 { 1005 std::ofstream outstream; 1006 outstream.open(filename.c_str()); 1007 1008 float maxPvs, maxVal, minVal; 1009 1010 // sort by pvs size 1011 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 1012 1013 maxPvs = viewCells.back()->GetPvsCost(); 1014 minVal = 0; 1015 1016 // hack: normalize pvs size 1017 int histoMaxVal; 1018 Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 1019 maxVal = max((float)histoMaxVal, maxPvs); 1020 1021 Debug << "histogram minpvssize: " << minVal << " maxpvssize: " << maxVal 1022 << " real maxpvs " << maxPvs << endl; 1023 1024 int histoIntervals; 1025 Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.intervals", histoIntervals); 1026 const int intervals = min(histoIntervals, (int)viewCells.size()); 1027 1028 const float range = maxVal - minVal; 1029 int stepSize = (int)(range / intervals); 1030 1031 // set step size to avoid endless loop 1032 if (!stepSize) stepSize = 1; 1033 1034 Debug << "intervals " << histoIntervals << endl; 1035 Debug << "stepsize: " << stepSize << endl; 1036 cout << "intervals " << histoIntervals << endl; 1037 cout << "stepsize: " << stepSize << endl; 1038 1039 const float totalRenderCost = mViewCellsTree->GetRoot()->GetRenderCost(); 1040 const float totalVol = GetViewSpaceBox().GetVolume(); 1041 1042 float currentPvs = minVal; 1043 1044 int i = 0; 1045 int j = 0; 1046 float volSum = 0; 1047 int smallerSum = 0; 1048 1049 //ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 957 1050 958 1051 for (int j = 0; j < intervals; ++ j) … … 6031 6124 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.stepSize", splitsStepSize); 6032 6125 6126 bool useHisto; 6127 int histoMem; 6128 6129 Environment::GetSingleton()->GetBoolValue("ViewCells.Evaluation.histogram", useHisto); 6130 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.histoMem", histoMem); 6131 6033 6132 Debug << "step size: " << splitsStepSize << endl; 6034 6133 Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; … … 6047 6146 6048 6147 // mix of sampling strategies 6049 evalStrats.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 6050 6051 /*evalStrats.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 6052 evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6053 evalStrats.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 6054 */ 6055 //evalStrats.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 6148 if (0) 6149 { 6150 evalStrats.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 6151 } 6152 else 6153 { 6154 /*evalStrats.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 6155 evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6156 evalStrats.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 6157 */ 6158 evalStrats.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 6159 } 6056 6160 6057 6161 Debug << "casting eval strategies: "; … … 6064 6168 cout << evalStrats[i] << " "; 6065 6169 cout << endl; 6170 6171 int pass = 0; 6066 6172 6067 6173 while (castSamples < numSamples) … … 6122 6228 6123 6229 ofstream ofstr(filename.c_str()); 6124 mHierarchyManager->EvaluateSubdivision2(ofstr, splitsStepSize, false );6230 mHierarchyManager->EvaluateSubdivision2(ofstr, splitsStepSize, false, useHisto, histoMem, pass); 6125 6231 6126 6232 timeDiff = TimeDiff(startTime, GetTime()); … … 6167 6273 << (float)pvsSize * ObjectPvs::GetEntrySize() << endl; 6168 6274 } 6275 ++ pass; 6169 6276 } 6170 6277 … … 6174 6281 //////////// 6175 6282 //-- histogram 6176 6283 #if 1 6177 6284 const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 6178 bool useHisto;6179 6285 int histoStepSize; 6180 6286 … … 6185 6291 { 6186 6292 // evaluate view cells in a histogram 6187 char s [64];6293 char str[64]; 6188 6294 6189 6295 // hack: just show final view cells … … 6195 6301 6196 6302 cout << "computing histogram for " << pass << " view cells" << endl; 6197 #if 0 6198 //-- evaluate histogram for render cost 6199 sprintf(s, "-%09d-histo.log", pass); 6200 filename = string(statsPrefix) + string(s); 6201 6202 EvalViewCellHistogram(filename, pass); 6203 6204 #endif 6303 6205 6304 ////////////////////////////////////////// 6206 6305 //-- evaluate histogram for pvs size … … 6208 6307 cout << "computing pvs histogram for " << pass << " view cells" << endl; 6209 6308 6210 sprintf(s , "-%09d-histo-pvs.log", pass);6211 filename = string(statsPrefix) + string(s );6309 sprintf(str, "-%09d-histo-pvs2.log", pass); 6310 filename = string(statsPrefix) + string(str); 6212 6311 6213 6312 EvalViewCellHistogramForPvsSize(filename, pass); 6214 6313 } 6215 6314 } 6216 }6217 6218 6315 #endif 6219 6220 6221 6222 } 6316 } 6317 6318 #endif 6319 6320 6321 6322 }
Note: See TracChangeset
for help on using the changeset viewer.