Changeset 744


Ignore:
Timestamp:
04/10/06 21:09:43 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r736 r744  
    12321232                                        optInt, 
    12331233                                        "view_cells_evaluation_histo_passes=", 
    1234                                         "5"); 
     1234                                        "5000"); 
    12351235 
    12361236        RegisterOption("ViewCells.renderCostEvaluationType", 
     
    19741974                optInt, 
    19751975                "vsp_bsp_term_max_view_cells=", 
    1976                 "1000"); 
     1976                "10000"); 
    19771977 
    19781978        RegisterOption("VspBspTree.Termination.maxCostRatio", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r736 r744  
    12511251        //-- compute pvs difference 
    12521252        const float newPvs =  
    1253 #if 0 
     1253#if 1 // not valid if not using const cost per object!! 
    12541254                ComputeMergedPvsSize(mc.mLeftViewCell->GetPvs(),  
    12551255                                                         mc.mRightViewCell->GetPvs()); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r726 r744  
    17341734                        !geomFront.Valid() || !geomBack.Valid())) 
    17351735                { 
    1736                         Debug << "error f: " << pFront << " b: " << pBack << endl; 
     1736                        //Debug << "error f: " << pFront << " b: " << pBack << endl; 
    17371737                        return 99999.9f; 
    17381738                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r736 r744  
    572572        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end();              
    573573 
     574        // count for integral 
     575        float volSum = 0; 
     576        int smallerCostSum = 0; 
    574577         
    575578        // note can skip computations for view cells already evaluated and delete them from vector ... 
    576579    while (1) 
    577580        { 
    578                 float vol = 0; 
    579                 int smallerCost = 0; 
     581                // count for histogram value 
     582                float volDif = 0; 
     583                int smallerCostDif = 0; 
    580584 
    581585                while ((i < (int)viewCells.size()) && (viewCells[i]->GetRenderCost() < currentRenderCost)) 
    582586                { 
    583                         vol += viewCells[i]->GetVolume(); 
     587                        volSum += viewCells[i]->GetVolume(); 
     588                        volDif += viewCells[i]->GetVolume(); 
     589 
    584590                        ++ i; 
    585                         ++ smallerCost; 
     591                        ++ smallerCostSum; 
     592                        ++ smallerCostDif; 
    586593                } 
    587594                 
    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)) 
    592596                        break; 
    593597                 
    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; 
    596601 
    597602                outstream << "#Pass\n" << j << endl; 
    598603                outstream << "#RenderCostRatio\n" << rcRatio << endl; 
    599604                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; 
    602609 
    603610                // increase current render cost 
     
    644651        int j = 0; 
    645652 
     653        float volSum = 0; 
     654        int smallerSum = 0; 
     655 
    646656        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end();              
    647657         
    648658        while (1) 
    649659        { 
    650                 float vol = 0; 
    651                 int smaller = 0; 
     660                float volDif = 0; 
     661                int smallerDif = 0; 
    652662 
    653663                while ((i < (int)viewCells.size()) && (viewCells[i]->GetPvs().GetSize() < currentPvsSize)) 
    654664                { 
    655                         vol += viewCells[i]->GetVolume(); 
     665                        volDif += viewCells[i]->GetVolume(); 
     666                        volSum += viewCells[i]->GetVolume(); 
    656667                        ++ i; 
    657                         ++ smaller; 
     668                        ++ smallerDif; 
     669                        ++ smallerSum; 
    658670                } 
    659671                 
    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; 
    662674 
    663675                if ((i >= (int)viewCells.size()) || (currentPvsSize >= maxPvsSize)) 
    664676                        break; 
    665677 
    666                 float volRatio = vol / totalVol; 
     678                const float volRatioDif = volDif / totalVol; 
     679                const float volRatioSum = volSum / totalVol; 
    667680 
    668681                outstream << "#Pass\n" << j ++ << endl; 
    669682                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; 
    673687 
    674688                // increase current pvs size 
     
    701715        bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
    702716 
    703         cout << "Evaluating view cell partition" << endl; 
     717        cout << "collect leaf view cells and reseting pvs ... "; 
    704718 
    705719        ViewCellContainer leaves; 
    706720        mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
    707  
     721        cout << " ... "; 
    708722        bool startFromZero = true; 
    709723 
     
    723737        } 
    724738         
    725          
     739        cout << "finished" << endl; 
     740 
     741        cout << "Evaluating view cell partition" << endl; 
     742 
    726743        while (castSamples < numSamples) 
    727744        { 
     
    734751                */ 
    735752                //-- construction rays => we use uniform samples for this 
     753                cout << "casting " << samplesPerPass << " samples " << endl; 
    736754                CastPassSamples(samplesPerPass, samplingType, evaluationSamples); 
    737755                 
    738756                castSamples += samplesPerPass; 
    739757 
    740                 cout << "casting " << (int)evaluationSamples.size() << " samples " << endl; 
     758                cout << "computing sample contributions of " << (int)evaluationSamples.size() << " samples " << endl; 
    741759 
    742760                ComputeSampleContributions(evaluationSamples, true, false); 
     
    768786        environment->GetIntValue("ViewCells.Evaluation.histoPasses", histoPasses); 
    769787 
    770         int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 
     788        const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 
    771789 
    772790        Debug << "number of leaves: " << numLeaves << endl; 
     
    777795                // evaluate view cells in a histogram            
    778796                char s[64]; 
    779  
     797#if 0 
    780798                for (int passes = 1; passes <= histoPasses; ++ passes) 
    781799                { 
     
    800818                        EvalViewCellHistogramForPvsSize(filename, n); 
    801819                } 
     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 
    802842        } 
    803843 
     
    20132053                mColorCode = 0; 
    20142054                 
    2015                 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 
     2055                Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 
    20162056                 
    20172057 
     
    20372077                mColorCode = 1; 
    20382078 
    2039                 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.x3d"); 
     2079                Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 
    20402080         
    20412081                cout << "exporting view cells after merge (pvs size) ... ";      
     
    32353275        case 2: // merged leaves 
    32363276                { 
    3237                 int lSize = mViewCellsTree->GetNumInitialViewCells(vc); 
     3277                const int lSize = mViewCellsTree->GetNumInitialViewCells(vc); 
    32383278                        importance = (float)lSize / 
    32393279                                (float)mCurrentViewCellsStats.maxLeaves; 
     
    34743514        { 
    34753515                mColorCode = 0; 
    3476                 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 
     3516                Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 
    34773517                 
    34783518                cout << "exporting view cells after merge ... "; 
     
    35063546                mColorCode = 1; 
    35073547 
    3508                 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.x3d"); 
     3548                Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 
    35093549         
    35103550                cout << "exporting view cells after merge (pvs size) ... ";      
     
    41574197                { 
    41584198                        importance = (float)vc->GetPvs().GetSize() / 
     4199#if 1 // hack for result                         
    41594200                                (float)mCurrentViewCellsStats.maxPvs; 
    4160  
     4201#else 
     4202                                463.0f; 
     4203#endif 
    41614204                } 
    41624205                break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r735 r744  
    10321032                        backData.mProbability = tData.mProbability - frontData.mProbability; 
    10331033 
    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 !!! 
    10401035                        if (0) 
    10411036                        { 
     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 
    10421043                                if (frontData.mProbability < 0) frontData.mProbability = 0; 
    10431044                                if (backData.mProbability < 0) backData.mProbability = 0; 
     
    20892090                return; 
    20902091 
     2092        const float renderCost = mViewCellsManager->EvalRenderCost(obj); 
     2093 
    20912094        // new object 
    20922095        if ((obj->mMailbox != sFrontId) && 
     
    20942097                (obj->mMailbox != sFrontAndBackId)) 
    20952098        { 
    2096                 totalPvs += mViewCellsManager->EvalRenderCost(obj); 
     2099                totalPvs += renderCost; 
    20972100        } 
    20982101 
     
    21062109                        (obj->mMailbox != sFrontAndBackId)) 
    21072110                { 
    2108                         frontPvs += mViewCellsManager->EvalRenderCost(obj); 
     2111                        frontPvs += renderCost; 
    21092112                 
    21102113                        if (obj->mMailbox == sBackId) 
     
    21202123                        (obj->mMailbox != sFrontAndBackId)) 
    21212124                { 
    2122                         backPvs += mViewCellsManager->EvalRenderCost(obj);; 
     2125                        backPvs += renderCost; 
    21232126                 
    21242127                        if (obj->mMailbox == sFrontId) 
     
    21972200        if (data.mDepth >= mTermMaxDepth) 
    21982201        { 
    2199                 ++ mBspStats.maxDepthNodes; 
     2202        ++ mBspStats.maxDepthNodes; 
     2203                //Debug << "new max depth: " << mBspStats.maxDepthNodes << endl; 
    22002204        } 
    22012205 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspKdTree.cpp

    r728 r744  
    11251125 
    11261126        if (data.mDepth >= mTermMaxDepth) 
     1127        { 
    11271128                ++ mStat.maxDepthNodes; 
     1129        } 
    11281130 
    11291131        if (leaf->GetPvsSize() < mTermMinPvs) 
  • GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp

    r737 r744  
    88#include <iostream> 
    99#include <fstream> 
    10  
     10#include <math.h> 
     11#include <algorithm> 
    1112 
    1213using namespace std; 
     
    111112 
    112113 
     114inline 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 
    113121void EvalNumViewCells(ofstream &outstream, 
    114122                                          const StatsContainer &firstStats,  
    115123                                          const StatsContainer &currentStats) 
    116                                           // vector<float> &ratios) 
    117124{ 
    118125         
     
    130137        for (it = currentStats.begin(); it != it_end; ++ it, ++ i) 
    131138        { 
    132                 //if (i > 200)  break; 
    133  
    134                 int j = 0; 
    135139                 
    136  
    137140                const float renderCost = (*it).mRenderCost; 
    138141     
     
    140143                // don't stop until cursor is placed one element behind 
    141144                // 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()); 
    148148 
    149149                float val; 
     
    154154                        val = (float)j; 
    155155                } 
    156                 else if (j == n) 
     156                else if (j >= n) 
    157157                { 
    158158                        val = (float)(j - 1); 
    159159                } 
    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 
    162169                        const float rcu = firstStats[j - 1].mRenderCost; 
    163170                        const float rcl = firstStats[j].mRenderCost; 
    164  
     171                        const float rc = renderCost; 
     172#endif 
    165173                        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 
    168177                        val = (float)j - 1 + factor; 
    169178                } 
     
    171180                // lower bound 
    172181                //int j = max (0, i - 1); 
    173                 cout << "i: " << i << " j: " << j << endl; 
     182                //cout << "i: " << i << " j: " << j << endl; 
    174183                float ratio = (i && val) ? (float)i / val : 1; 
    175184 
    176                 cout << "ratio: " << ratio << endl; 
     185                //cout << "ratio: " << ratio << endl; 
    177186                outstream << "#Pass\n" << i << endl; 
    178187                outstream << "#RenderCost\n" << renderCost << endl; 
    179188                outstream << "#ViewCellsRatio\n" << ratio << endl << endl;       
    180  
    181                 //cout << "#Pass " << i ++ << endl; 
    182                 //cout << "#RenderCost " << renderCost << endl; 
    183                 //cout << "#ViewCellsRatio " << ratio << endl;   
    184189        } 
    185190} 
     
    263268                for (int i = 0; i < n; ++ i) 
    264269                { 
    265                         cout << "rc: " << (*it)[i].mRenderCost << endl; 
     270                        //cout << "rc: " << (*it)[i].mRenderCost << endl; 
    266271                        ComputeStats(statsOut, firstStats[i], (*it)[i], i); 
    267272                } 
    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 
    272275                EvalNumViewCells(statsOut2, firstStats, (*it)); 
    273276 
Note: See TracChangeset for help on using the changeset viewer.