Changeset 1709 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 11/02/06 19:09:30 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1708 r1709 296 296 int stype; 297 297 298 const int numStrategies = 3; 299 298 300 stype = SamplingStrategy::OBJECT_BASED_DISTRIBUTION; 299 mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays);301 mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 300 302 301 303 stype = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 302 mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays); 303 304 stype = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 305 mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays); 304 mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 305 306 if (0) 307 { 308 stype = SamplingStrategy::DIRECTION_BASED_DISTRIBUTION; 309 mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 310 } 306 311 307 312 stype = SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION; 308 mPreprocessor->GenerateRays(samplesPerPass / 4, sampleType, simpleRays);313 mPreprocessor->GenerateRays(samplesPerPass / numStrategies, sampleType, simpleRays); 309 314 310 315 cout << "generated " << samplesPerPass << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 516 521 if (mEvaluateViewCells) 517 522 { 518 cout << "here42 ***********" << endl;519 523 EvalViewCellPartition(); 520 524 } … … 794 798 mViewCellsTree->CollectBestViewCellSet(viewCells, nViewCells); 795 799 796 int maxPvs, maxVal, minVal;800 float maxPvs, maxVal, minVal; 797 801 798 802 // sort by pvs size 799 803 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 800 804 801 maxPvs = mViewCellsTree->GetPvs Size(viewCells.back());805 maxPvs = mViewCellsTree->GetPvsCost(viewCells.back()); 802 806 minVal = 0; 803 807 … … 805 809 int histoMaxVal; 806 810 Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 807 maxVal = max( histoMaxVal, maxPvs);811 maxVal = max((float)histoMaxVal, maxPvs); 808 812 809 813 Debug << "histogram minpvssize: " << minVal << " maxpvssize: " << maxVal … … 814 818 const int intervals = min(histoIntervals, (int)viewCells.size()); 815 819 816 const int range = maxVal - minVal;817 int stepSize = range / intervals;820 const float range = maxVal - minVal; 821 int stepSize = (int)(range / intervals); 818 822 819 823 // set step size to avoid endless loop … … 825 829 const float totalVol = GetViewSpaceBox().GetVolume(); 826 830 827 int currentPvs = minVal;//(int)ceil(minRenderCost);831 float currentPvs = minVal; 828 832 829 833 int i = 0; … … 840 844 841 845 while ((i < (int)viewCells.size()) && 842 (mViewCellsTree->GetPvs Size(viewCells[i]) < currentPvs))846 (mViewCellsTree->GetPvsCost(viewCells[i]) < currentPvs)) 843 847 { 844 848 volDif += viewCells[i]->GetVolume(); … … 851 855 852 856 if (0 && (i < (int)viewCells.size())) 853 Debug << "new pvs size increase: " << mViewCellsTree->GetPvsSize(viewCells[i])857 Debug << "new pvs cost increase: " << mViewCellsTree->GetPvsCost(viewCells[i]) 854 858 << " " << currentPvs << endl; 855 859 … … 864 868 outstream << "#VolumeSum\n" << volRatioSum << endl << endl; 865 869 866 //if ((i >= (int)viewCells.size()) || (currentPvs >= maxPvs)) break;867 868 870 //-- increase current pvs size to define next interval 869 871 currentPvs += stepSize; … … 1009 1011 ObjectPvs pvs; 1010 1012 1011 cout << "updating pvs for contribution ... " << endl;1013 cout << "updating pvs for evaluation ... " << endl; 1012 1014 1013 1015 UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); … … 1499 1501 float &deviation, 1500 1502 float &variance, 1501 int &totalPvs,1503 float &totalCost, 1502 1504 float &avgRenderCost) 1503 1505 { … … 1506 1508 1507 1509 totalRenderCost = 0; 1508 total Pvs= 0;1510 totalCost = 0; 1509 1511 1510 1512 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); … … 1514 1516 ViewCell *vc = *it; 1515 1517 totalRenderCost += vc->GetPvs().EvalPvsCost() * vc->GetVolume(); 1516 total Pvs+= (int)vc->GetPvs().EvalPvsCost();1518 totalCost += (int)vc->GetPvs().EvalPvsCost(); 1517 1519 } 1518 1520 … … 1520 1522 totalRenderCost /= mViewSpaceBox.GetVolume(); 1521 1523 expectedRenderCost = totalRenderCost / (float)mViewCells.size(); 1522 avgRenderCost = total Pvs/ (float)mViewCells.size();1524 avgRenderCost = totalCost / (float)mViewCells.size(); 1523 1525 1524 1526 … … 1744 1746 void ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 1745 1747 { 1746 // update pvs of view cells tree if necessary 1747 UpdatePvs(); 1748 1749 ViewCellContainer::const_iterator it = mViewCells.begin(); 1750 1751 stat.viewcells = 0; 1752 stat.minPvs = 100000000; 1753 stat.maxPvs = 0; 1754 stat.avgPvs = 0.0f; 1755 1756 for (; it != mViewCells.end(); ++ it) 1757 { 1758 ViewCell *viewcell = *it; 1759 1760 // bool mCountKdPvs = false; 1761 const int pvsSize = mViewCellsTree->GetPvsSize(viewcell); 1762 1763 1764 if (pvsSize < stat.minPvs) 1765 stat.minPvs = pvsSize; 1766 if (pvsSize > stat.maxPvs) 1767 stat.maxPvs = pvsSize; 1768 1769 stat.avgPvs += pvsSize; 1770 1771 ++ stat.viewcells; 1772 } 1773 1774 if (stat.viewcells) 1775 stat.avgPvs/=stat.viewcells; 1748 // update pvs of view cells tree if necessary 1749 UpdatePvs(); 1750 1751 ViewCellContainer::const_iterator it = mViewCells.begin(); 1752 1753 stat.viewcells = 0; 1754 stat.minPvs = 100000000; 1755 stat.maxPvs = 0; 1756 stat.avgPvs = 0.0f; 1757 1758 for (; it != mViewCells.end(); ++ it) 1759 { 1760 ViewCell *viewcell = *it; 1761 1762 const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 1763 1764 if (pvsCost < stat.minPvs) 1765 stat.minPvs = pvsCost; 1766 if (pvsCost > stat.maxPvs) 1767 stat.maxPvs = pvsCost; 1768 1769 stat.avgPvs += pvsCost; 1770 1771 ++ stat.viewcells; 1772 } 1773 1774 if (stat.viewcells) 1775 stat.avgPvs/=stat.viewcells; 1776 1776 } 1777 1777 … … 2053 2053 float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 2054 2054 { 2055 return (float)mViewCellsTree->GetPvs Size(viewCell);2055 return (float)mViewCellsTree->GetPvsCost(viewCell); 2056 2056 } 2057 2057 … … 2327 2327 2328 2328 void ViewCellsManager::UpdateScalarPvsSize(ViewCell *vc, 2329 const int pvsSize,2329 const float pvsCost, 2330 2330 const int entriesInPvs) const 2331 2331 { 2332 vc->mPvs Size = pvsSize;2332 vc->mPvsCost = pvsCost; 2333 2333 vc->mEntriesInPvs = entriesInPvs; 2334 2334 … … 2525 2525 { 2526 2526 importance = 2527 (float)mViewCellsTree->GetPvs Size(vc) /2527 (float)mViewCellsTree->GetPvsCost(vc) / 2528 2528 (float)mCurrentViewCellsStats.maxPvs; 2529 2529 } … … 2578 2578 if (root->IsLeaf()) 2579 2579 { 2580 //cout << "updating leaf" << endl; 2580 2581 // we assume that pvs is explicitly stored in leaves 2581 2582 pvs = root->GetPvs(); 2582 2583 UpdateScalarPvsSize(root, pvs.EvalPvsCost(), pvs.GetSize()); 2583 2584 2584 return; 2585 2585 } 2586 2586 2587 //cout << "recursivly updating pvs" << endl; 2588 2587 2589 //////////////// 2588 2590 //-- interior node => propagate pvs up the tree … … 2597 2599 // pvss of child nodes 2598 2600 vector<ObjectPvs> pvsList; 2601 pvsList.resize((int)interior->mChildren.size()); 2599 2602 2600 2603 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 2601 pvsList.resize((int)interior->mChildren.size());2604 2602 2605 int i = 0; 2606 2603 2607 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ i) 2604 2608 { 2605 //ObjectPvs objPvs;2606 2607 2609 ////////////////// 2608 2610 //-- recursivly compute child pvss 2609 2610 2611 UpdatePvsForEvaluation(*vit, pvsList[i]/*objPvs*/); 2611 2612 // store pvs in vector2613 //pvsList.push_back(objPvs);2614 2612 } 2615 2613 … … 3047 3045 Exporter *exporter = Exporter::GetExporter(s); 3048 3046 3049 cout << "view cell " << idx << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl;3047 cout << "view cell " << idx << ": pvs cost=" << (int)mViewCellsTree->GetPvsCost(vc) << endl; 3050 3048 3051 3049 if (exportRays) … … 4400 4398 Exporter *exporter = Exporter::GetExporter(s); 4401 4399 4402 const int pvsSize = (int)mViewCellsTree->GetPvsSize(vc);4403 cout << "view cell " << vc->GetId() << ": pvs size=" << pvsSize<< endl;4400 const float pvsCost = mViewCellsTree->GetPvsCost(vc); 4401 cout << "view cell " << vc->GetId() << ": pvs cost=" << pvsCost << endl; 4404 4402 4405 4403 if (exportRays) … … 5285 5283 Exporter *exporter = Exporter::GetExporter(s); 5286 5284 5287 cout << "view cell " << vc->GetId() << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl;5285 cout << "view cell " << vc->GetId() << ": pvs cost=" << mViewCellsTree->GetPvsCost(vc) << endl; 5288 5286 5289 5287 if (exportPvs) … … 5661 5659 5662 5660 5663 #if 05661 #if 1 5664 5662 #if TEST_EVALUATION 5665 5663 void VspOspViewCellsManager::EvalViewCellPartition() … … 5730 5728 { 5731 5729 ViewCell *vc = *vit; 5732 int pvs= vc->GetPvs().EvalPvsCost();5733 float vol = vc->GetVolume();5734 rc += pvs * vol;5730 const float pvsCost = vc->GetPvs().EvalPvsCost(); 5731 const float vol = vc->GetVolume(); 5732 rc += pvsCost * vol; 5735 5733 } 5736 5734 … … 5826 5824 sprintf(str, "-%09d-eval.log", castSamples); 5827 5825 string filename = string(statsPrefix) + string(str); 5828 5829 mHierarchyManager->EvaluateSubdivision (evaluationSamples, mPreprocessor->mObjects, filename);5826 ofstream ofstr(filename.c_str()); 5827 mHierarchyManager->EvaluateSubdivision2(ofstr); 5830 5828 5831 5829 timeDiff = TimeDiff(startTime, GetTime()); … … 5833 5831 Debug << "statistis compted in " << timeDiff * 1e-3 << " secs" << endl; 5834 5832 5835 //disposeRays(evaluationSamples, NULL); 5836 } 5837 5838 disposeRays(evaluationSamples, NULL); 5839 5833 disposeRays(evaluationSamples, NULL); 5834 } 5840 5835 } 5841 5836 #endif
Note: See TracChangeset
for help on using the changeset viewer.