Ignore:
Timestamp:
05/29/06 18:54:02 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r897 r991  
    99{ 
    1010  environment->GetIntValue("RenderSampler.samples", mSamples); 
    11   cout<<"mspamples"<<mSamples<<endl; 
     11  cout << "number of render samples: " << mSamples << endl; 
    1212} 
    1313 
     
    1515RenderSampler::ComputeVisibility() 
    1616{ 
     17        long startTime = GetTime(); 
     18         
     19        int histoMaxVal = 0; 
     20        int histoIntervals = 0; 
     21         
     22    environment->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 
     23        environment->GetIntValue("Preprocessor.histogram.intervals", histoIntervals); 
     24 
     25        const int intervals = histoIntervals; 
     26 
     27        cout << "starting sampling of render cost ... "; 
     28 
     29        vector<RenderCostSample> samples; 
    1730   
    18   cout<<"HERE I WAS!\n"; 
     31        if (renderer) 
     32        {cout << "here18 " << mSamples << endl; 
     33                renderer->SampleRenderCost(mSamples, samples); 
     34        } 
    1935 
    20   vector<RenderCostSample> samples; 
    21    
    22   if (renderer) 
    23         renderer->SampleRenderCost( 
    24                                                            mSamples, 
    25                                                            samples 
    26                                                            ); 
     36        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    2737 
    2838 
    29   // compute histogram from the samples 
    30   int bins = 100; 
    31   int maxPvs = 0; 
     39        //-- Evaluate properties 
     40         
    3241 
    33   vector<int> histogram(bins); 
     42        //-- compute histogram from the samples 
     43        int avgPvs = 0; 
     44        int maxPvs = 0; 
     45 
     46        vector<int> histogram(intervals); 
    3447   
    35   int i; 
    36   for (i = 0; i < bins; i++) 
    37         histogram[i] = 0; 
     48        int i; 
     49 
     50        /// initialise histogram 
     51        for (i = 0; i < intervals; ++ i) 
     52        { 
     53                histogram[i] = 0; 
     54        } 
     55 
     56         
     57 
     58        for (i = 0; i < mSamples; ++ i)  
     59        { 
     60                if (samples[i].mVisibleObjects > maxPvs) 
     61                { 
     62                        maxPvs = samples[i].mVisibleObjects; 
     63                } 
     64 
     65                avgPvs += samples[i].mVisibleObjects; 
     66        } 
     67 
     68        // sometimes need need to unifiy maximum pvs to compare with other method's histograms 
     69        // => choose histoMaxPvs accordingly (higher than all pvsss) 
     70        const int maxVal = max(histoMaxVal, maxPvs); 
     71         
     72        for (i = 0; i < mSamples; ++ i)  
     73        { 
     74                const int bin = (samples[i].mVisibleObjects * intervals) / maxVal; 
     75 
     76                ++ histogram[bin]; 
     77        } 
     78 
     79 
     80        //-- output the histogram 
     81 
     82        const string filename("fromPointHisto.log"); 
     83        std::ofstream outstream; 
     84        outstream.open(filename.c_str()); 
     85 
     86 
     87 
     88        Debug << "****************************************" << endl; 
     89        Debug << "From point queries: " << endl; 
     90 
     91        for (i = 0; i < intervals; ++ i)  
     92        { 
     93                outstream << "#Pass\n" << i << endl; 
     94                outstream << "#Pvs\n" << histogram[i] << endl; 
     95                //cout << histogram[i] << endl; 
     96        } 
     97 
     98        outstream.close(); 
     99 
     100        avgPvs /= mSamples; 
     101                 
     102        Debug << "max pvs: " << maxPvs << endl; 
     103        Debug << "avg pvs: " << avgPvs << endl; 
    38104   
    39   for (i = 0; i < mSamples; i++) { 
    40         if (samples[i].mVisibleObjects > maxPvs) 
    41           maxPvs = samples[i].mVisibleObjects; 
    42   } 
    43    
    44   for (i = 0; i < mSamples; i++) { 
    45         int bin = (samples[i].mVisibleObjects*bins)/maxPvs; 
    46         histogram[bin]++; 
    47   } 
    48  
    49   // output the histogram 
    50   for (i = 0; i < bins; i++) { 
    51         cout<<histogram[i]<<endl; 
    52   } 
    53  
    54    
    55   return true; 
     105        return true; 
    56106} 
    57107 
     108 
     109 
    58110} 
Note: See TracChangeset for help on using the changeset viewer.