Changeset 737


Ignore:
Timestamp:
04/09/06 13:38:39 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp

    r736 r737  
    114114                                          const StatsContainer &firstStats,  
    115115                                          const StatsContainer &currentStats) 
    116                 //                        vector<float> &ratios) 
    117 { 
    118         //const int n = min((int)firstStats.size(), (int)currentStats.size()); 
    119         const int n = (int)firstStats.size(); 
     116                                          // vector<float> &ratios) 
     117{ 
     118         
     119        const int n = min((int)firstStats.size(), (int)currentStats.size()); 
     120        //const int n = (int)firstStats.size(); 
    120121         
    121122        StatsContainer::const_iterator it, it_end = currentStats.end(); 
     
    123124        int i = 0; 
    124125 
    125         // currentStats would be the other (necessarily worse?) method 
    126         // firstStats would be our method 
    127         // compare render cost of current view cell with render cost  
    128         // of other view cells. 
     126        // currentStats would be the other (necessarily worse?) method, firstStats would be our method 
     127        // loop through view cells of currentStats 
     128        // Compare render cost with render cost of other view cell 
     129        // compute ratio of view cells 
    129130        for (it = currentStats.begin(); it != it_end; ++ it, ++ i) 
    130131        { 
     132                //if (i > 200)  break; 
     133 
    131134                int j = 0; 
     135                 
    132136 
    133137                const float renderCost = (*it).mRenderCost; 
     
    136140                // don't stop until cursor is placed one element behind 
    137141                // or end of vector is reached 
    138                 while ((j < n) && (renderCost > (int)firstStats[j ++].mRenderCost)); 
    139          
     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                } 
     148 
     149                float val; 
     150 
     151                // soecial cases 
     152                if (j == 0) 
     153                { 
     154                        val = (float)j; 
     155                } 
     156                else if (j == n) 
     157                { 
     158                        val = (float)(j - 1); 
     159                } 
     160                else // interpolate linearly. NOTE: probably big error because of steep curve 
     161                { 
     162                        const float rcu = firstStats[j - 1].mRenderCost; 
     163                        const float rcl = firstStats[j].mRenderCost; 
     164 
     165                        const float factor = (rcu - rcl != 0) ? 
     166                                (rcu - renderCost) / (rcu - rcl) : 1; 
     167 
     168                        val = (float)j - 1 + factor; 
     169                } 
     170 
    140171                // lower bound 
    141172                //int j = max (0, i - 1); 
    142                 float ratio = (float)i / (float)j; 
    143  
     173                cout << "i: " << i << " j: " << j << endl; 
     174                float ratio = (i && val) ? (float)i / val : 1; 
     175 
     176                cout << "ratio: " << ratio << endl; 
    144177                outstream << "#Pass\n" << i << endl; 
    145178                outstream << "#RenderCost\n" << renderCost << endl; 
     
    230263                for (int i = 0; i < n; ++ i) 
    231264                { 
     265                        cout << "rc: " << (*it)[i].mRenderCost << endl; 
    232266                        ComputeStats(statsOut, firstStats[i], (*it)[i], i); 
    233267                } 
Note: See TracChangeset for help on using the changeset viewer.