Changeset 744 for GTP/trunk/Lib
- Timestamp:
- 04/10/06 21:09:43 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r736 r744 1232 1232 optInt, 1233 1233 "view_cells_evaluation_histo_passes=", 1234 "5 ");1234 "5000"); 1235 1235 1236 1236 RegisterOption("ViewCells.renderCostEvaluationType", … … 1974 1974 optInt, 1975 1975 "vsp_bsp_term_max_view_cells=", 1976 "1000 ");1976 "10000"); 1977 1977 1978 1978 RegisterOption("VspBspTree.Termination.maxCostRatio", -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r736 r744 1251 1251 //-- compute pvs difference 1252 1252 const float newPvs = 1253 #if 01253 #if 1 // not valid if not using const cost per object!! 1254 1254 ComputeMergedPvsSize(mc.mLeftViewCell->GetPvs(), 1255 1255 mc.mRightViewCell->GetPvs()); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r726 r744 1734 1734 !geomFront.Valid() || !geomBack.Valid())) 1735 1735 { 1736 Debug << "error f: " << pFront << " b: " << pBack << endl;1736 //Debug << "error f: " << pFront << " b: " << pBack << endl; 1737 1737 return 99999.9f; 1738 1738 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r736 r744 572 572 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 573 573 574 // count for integral 575 float volSum = 0; 576 int smallerCostSum = 0; 574 577 575 578 // note can skip computations for view cells already evaluated and delete them from vector ... 576 579 while (1) 577 580 { 578 float vol = 0; 579 int smallerCost = 0; 581 // count for histogram value 582 float volDif = 0; 583 int smallerCostDif = 0; 580 584 581 585 while ((i < (int)viewCells.size()) && (viewCells[i]->GetRenderCost() < currentRenderCost)) 582 586 { 583 vol += viewCells[i]->GetVolume(); 587 volSum += viewCells[i]->GetVolume(); 588 volDif += viewCells[i]->GetVolume(); 589 584 590 ++ i; 585 ++ smallerCost; 591 ++ smallerCostSum; 592 ++ smallerCostDif; 586 593 } 587 594 588 if (i < (int)viewCells.size()) 589 Debug << "new rc increase: " << viewCells[i]->GetRenderCost() / totalVol << " " << currentRenderCost / totalVol << endl; 590 591 if ((smallerCost >= (int)viewCells.size()) || (currentRenderCost >= maxRenderCost)) 595 if ((i >= (int)viewCells.size()) || (currentRenderCost >= maxRenderCost)) 592 596 break; 593 597 594 float rcRatio = currentRenderCost / maxRenderCost; 595 float volRatio = vol / totalVol; 598 const float rcRatio = currentRenderCost / maxRenderCost; 599 const float volRatioSum = volSum / totalVol; 600 const float volRatioDif = volDif / totalVol; 596 601 597 602 outstream << "#Pass\n" << j << endl; 598 603 outstream << "#RenderCostRatio\n" << rcRatio << endl; 599 604 outstream << "#WeightedCost\n" << currentRenderCost / totalVol << endl; 600 outstream << "#ViewCells\n" << smallerCost << endl; 601 outstream << "#Volume\n" << volRatio << endl << endl; 605 outstream << "#ViewCellsDif\n" << smallerCostDif << endl; 606 outstream << "#ViewCellsSum\n" << smallerCostSum << endl; 607 outstream << "#VolumeDif\n" << volRatioDif << endl << endl; 608 outstream << "#VolumeSum\n" << volRatioSum << endl << endl; 602 609 603 610 // increase current render cost … … 644 651 int j = 0; 645 652 653 float volSum = 0; 654 int smallerSum = 0; 655 646 656 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 647 657 648 658 while (1) 649 659 { 650 float vol = 0;651 int smaller = 0;660 float volDif = 0; 661 int smallerDif = 0; 652 662 653 663 while ((i < (int)viewCells.size()) && (viewCells[i]->GetPvs().GetSize() < currentPvsSize)) 654 664 { 655 vol += viewCells[i]->GetVolume(); 665 volDif += viewCells[i]->GetVolume(); 666 volSum += viewCells[i]->GetVolume(); 656 667 ++ i; 657 ++ smaller; 668 ++ smallerDif; 669 ++ smallerSum; 658 670 } 659 671 660 if (i < (int)viewCells.size())661 Debug << "new pvs size increase: " << viewCells[i]->GetPvs().GetSize() << " " << currentPvsSize << endl;672 //if (i < (int)viewCells.size()) 673 // Debug << "new pvs size increase: " << viewCells[i]->GetPvs().GetSize() << " " << currentPvsSize << endl; 662 674 663 675 if ((i >= (int)viewCells.size()) || (currentPvsSize >= maxPvsSize)) 664 676 break; 665 677 666 float volRatio = vol / totalVol; 678 const float volRatioDif = volDif / totalVol; 679 const float volRatioSum = volSum / totalVol; 667 680 668 681 outstream << "#Pass\n" << j ++ << endl; 669 682 outstream << "#Pvs\n" << currentPvsSize << endl; 670 outstream << "#ViewCells\n" << smaller << endl; 671 outstream << "#Volume\n" << volRatio << endl << endl; 672 683 outstream << "#ViewCellsDif\n" << smallerDif << endl; 684 outstream << "#ViewCellsSum\n" << smallerSum << endl; 685 outstream << "#VolumeDif\n" << volRatioDif << endl << endl; 686 outstream << "#VolumeSum\n" << volRatioSum << endl << endl; 673 687 674 688 // increase current pvs size … … 701 715 bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 702 716 703 cout << " Evaluating view cell partition" << endl;717 cout << "collect leaf view cells and reseting pvs ... "; 704 718 705 719 ViewCellContainer leaves; 706 720 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 707 721 cout << " ... "; 708 722 bool startFromZero = true; 709 723 … … 723 737 } 724 738 725 739 cout << "finished" << endl; 740 741 cout << "Evaluating view cell partition" << endl; 742 726 743 while (castSamples < numSamples) 727 744 { … … 734 751 */ 735 752 //-- construction rays => we use uniform samples for this 753 cout << "casting " << samplesPerPass << " samples " << endl; 736 754 CastPassSamples(samplesPerPass, samplingType, evaluationSamples); 737 755 738 756 castSamples += samplesPerPass; 739 757 740 cout << "c asting" << (int)evaluationSamples.size() << " samples " << endl;758 cout << "computing sample contributions of " << (int)evaluationSamples.size() << " samples " << endl; 741 759 742 760 ComputeSampleContributions(evaluationSamples, true, false); … … 768 786 environment->GetIntValue("ViewCells.Evaluation.histoPasses", histoPasses); 769 787 770 int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot());788 const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 771 789 772 790 Debug << "number of leaves: " << numLeaves << endl; … … 777 795 // evaluate view cells in a histogram 778 796 char s[64]; 779 797 #if 0 780 798 for (int passes = 1; passes <= histoPasses; ++ passes) 781 799 { … … 800 818 EvalViewCellHistogramForPvsSize(filename, n); 801 819 } 820 #else 821 for (int pass = histoPasses; pass < numLeaves; pass += histoPasses) 822 { 823 cout << "computing histogram for " << pass << " view cells" << endl; 824 825 //-- evaluate histogram for render cost 826 sprintf(s, "-%09d-histo.log", pass); 827 string filename = string(statsPrefix) + string(s); 828 829 EvalViewCellHistogram(filename, pass); 830 831 ////////////////////////////////////////// 832 // --evaluate histogram for pvs size 833 834 cout << "computing pvs histogram for " << pass << " view cells" << endl; 835 836 sprintf(s, "-%09d-histo-pvs.log", pass); 837 filename = string(statsPrefix) + string(s); 838 839 EvalViewCellHistogramForPvsSize(filename, pass); 840 } 841 #endif 802 842 } 803 843 … … 2013 2053 mColorCode = 0; 2014 2054 2015 Exporter *exporter = Exporter::GetExporter("merged_view_cells. x3d");2055 Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 2016 2056 2017 2057 … … 2037 2077 mColorCode = 1; 2038 2078 2039 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs. x3d");2079 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 2040 2080 2041 2081 cout << "exporting view cells after merge (pvs size) ... "; … … 3235 3275 case 2: // merged leaves 3236 3276 { 3237 int lSize = mViewCellsTree->GetNumInitialViewCells(vc);3277 const int lSize = mViewCellsTree->GetNumInitialViewCells(vc); 3238 3278 importance = (float)lSize / 3239 3279 (float)mCurrentViewCellsStats.maxLeaves; … … 3474 3514 { 3475 3515 mColorCode = 0; 3476 Exporter *exporter = Exporter::GetExporter("merged_view_cells. x3d");3516 Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 3477 3517 3478 3518 cout << "exporting view cells after merge ... "; … … 3506 3546 mColorCode = 1; 3507 3547 3508 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs. x3d");3548 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 3509 3549 3510 3550 cout << "exporting view cells after merge (pvs size) ... "; … … 4157 4197 { 4158 4198 importance = (float)vc->GetPvs().GetSize() / 4199 #if 1 // hack for result 4159 4200 (float)mCurrentViewCellsStats.maxPvs; 4160 4201 #else 4202 463.0f; 4203 #endif 4161 4204 } 4162 4205 break; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r735 r744 1032 1032 backData.mProbability = tData.mProbability - frontData.mProbability; 1033 1033 1034 if (frontData.mProbability < -0.00001) 1035 Debug << "fatal error f: " << frontData.mProbability << endl; 1036 if (backData.mProbability < -0.00001) 1037 Debug << "fatal error b: " << backData.mProbability << endl; 1038 1039 // clamp because of precision issues 1034 // should never come here: wrong volume !!! 1040 1035 if (0) 1041 1036 { 1037 if (frontData.mProbability < -0.00001) 1038 Debug << "fatal error f: " << frontData.mProbability << endl; 1039 if (backData.mProbability < -0.00001) 1040 Debug << "fatal error b: " << backData.mProbability << endl; 1041 1042 // clamp because of precision issues 1042 1043 if (frontData.mProbability < 0) frontData.mProbability = 0; 1043 1044 if (backData.mProbability < 0) backData.mProbability = 0; … … 2089 2090 return; 2090 2091 2092 const float renderCost = mViewCellsManager->EvalRenderCost(obj); 2093 2091 2094 // new object 2092 2095 if ((obj->mMailbox != sFrontId) && … … 2094 2097 (obj->mMailbox != sFrontAndBackId)) 2095 2098 { 2096 totalPvs += mViewCellsManager->EvalRenderCost(obj);2099 totalPvs += renderCost; 2097 2100 } 2098 2101 … … 2106 2109 (obj->mMailbox != sFrontAndBackId)) 2107 2110 { 2108 frontPvs += mViewCellsManager->EvalRenderCost(obj);2111 frontPvs += renderCost; 2109 2112 2110 2113 if (obj->mMailbox == sBackId) … … 2120 2123 (obj->mMailbox != sFrontAndBackId)) 2121 2124 { 2122 backPvs += mViewCellsManager->EvalRenderCost(obj);;2125 backPvs += renderCost; 2123 2126 2124 2127 if (obj->mMailbox == sFrontId) … … 2197 2200 if (data.mDepth >= mTermMaxDepth) 2198 2201 { 2199 ++ mBspStats.maxDepthNodes; 2202 ++ mBspStats.maxDepthNodes; 2203 //Debug << "new max depth: " << mBspStats.maxDepthNodes << endl; 2200 2204 } 2201 2205 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspKdTree.cpp
r728 r744 1125 1125 1126 1126 if (data.mDepth >= mTermMaxDepth) 1127 { 1127 1128 ++ mStat.maxDepthNodes; 1129 } 1128 1130 1129 1131 if (leaf->GetPvsSize() < mTermMinPvs) -
GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp
r737 r744 8 8 #include <iostream> 9 9 #include <fstream> 10 10 #include <math.h> 11 #include <algorithm> 11 12 12 13 using namespace std; … … 111 112 112 113 114 inline bool vlt(const RenderStats &c1, const RenderStats &c2) 115 { 116 return c1.mRenderCost > c2.mRenderCost; 117 } 118 119 120 // evaluate number of view cells needed for same rendercost 113 121 void EvalNumViewCells(ofstream &outstream, 114 122 const StatsContainer &firstStats, 115 123 const StatsContainer ¤tStats) 116 // vector<float> &ratios)117 124 { 118 125 … … 130 137 for (it = currentStats.begin(); it != it_end; ++ it, ++ i) 131 138 { 132 //if (i > 200) break;133 134 int j = 0;135 139 136 137 140 const float renderCost = (*it).mRenderCost; 138 141 … … 140 143 // don't stop until cursor is placed one element behind 141 144 // or end of vector is reached 142 // note: use stl for this 143 while ((j < n) && (renderCost <= firstStats[j].mRenderCost)) 144 { 145 //cout << "!!rendercost: " << renderCost << " " << firstStats[j].mRenderCost << endl; 146 ++ j; 147 } 145 StatsContainer::const_iterator equalCostIt = std::upper_bound(firstStats.begin(), firstStats.end(), *it, vlt); 146 147 int j = (int)(equalCostIt - firstStats.begin()); 148 148 149 149 float val; … … 154 154 val = (float)j; 155 155 } 156 else if (j == n)156 else if (j >= n) 157 157 { 158 158 val = (float)(j - 1); 159 159 } 160 else // interpolate linearly. NOTE: probably big error because of steep curve 161 { 160 else 161 // interpolate linearly. NOTE: probably big error because of steep curve 162 // => intepolate logarithmically 163 { 164 #if 1 165 const float rcu = log(firstStats[j - 1].mRenderCost); 166 const float rcl = log(firstStats[j].mRenderCost); 167 const float rc = log(renderCost); 168 #else 162 169 const float rcu = firstStats[j - 1].mRenderCost; 163 170 const float rcl = firstStats[j].mRenderCost; 164 171 const float rc = renderCost; 172 #endif 165 173 const float factor = (rcu - rcl != 0) ? 166 (rcu - renderCost) / (rcu - rcl) : 1; 167 174 (rcu - rc) / (rcu - rcl) : 1; 175 176 // view cells needed for same render cost 168 177 val = (float)j - 1 + factor; 169 178 } … … 171 180 // lower bound 172 181 //int j = max (0, i - 1); 173 cout << "i: " << i << " j: " << j << endl;182 //cout << "i: " << i << " j: " << j << endl; 174 183 float ratio = (i && val) ? (float)i / val : 1; 175 184 176 cout << "ratio: " << ratio << endl;185 //cout << "ratio: " << ratio << endl; 177 186 outstream << "#Pass\n" << i << endl; 178 187 outstream << "#RenderCost\n" << renderCost << endl; 179 188 outstream << "#ViewCellsRatio\n" << ratio << endl << endl; 180 181 //cout << "#Pass " << i ++ << endl;182 //cout << "#RenderCost " << renderCost << endl;183 //cout << "#ViewCellsRatio " << ratio << endl;184 189 } 185 190 } … … 263 268 for (int i = 0; i < n; ++ i) 264 269 { 265 cout << "rc: " << (*it)[i].mRenderCost << endl;270 //cout << "rc: " << (*it)[i].mRenderCost << endl; 266 271 ComputeStats(statsOut, firstStats[i], (*it)[i], i); 267 272 } 268 #if 0 269 const int vc = ComputeNoViewCells(firstStats, *it); 270 cout << "need " << vc << " view cells to reach rendercost of method " << i << " with " << n << " view cells" << endl; 271 #endif 273 274 // evaluate number of view cells needed for same rendercost 272 275 EvalNumViewCells(statsOut2, firstStats, (*it)); 273 276
Note: See TracChangeset
for help on using the changeset viewer.