Ignore:
Timestamp:
04/10/06 21:09:43 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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; 
Note: See TracChangeset for help on using the changeset viewer.