Ignore:
Timestamp:
04/08/06 23:35:12 (18 years ago)
Author:
mattausch
Message:

completed histogram

File:
1 edited

Legend:

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

    r735 r736  
    552552        maxRenderCost = viewCells.back()->GetRenderCost(); 
    553553 
     554        Debug << "histogram minrc: " << minRenderCost << " maxrc: " << maxRenderCost << endl; 
     555 
    554556        const int intervals = min(10000, (int)viewCells.size()); 
    555557 
     
    561563        const float totalRenderCost = mViewCellsTree->GetRoot()->GetRenderCost(); 
    562564        const float totalVol = GetViewSpaceBox().GetVolume(); 
    563  
    564         float vol = 0; 
    565         int smallerCost = 0; 
     565        //const float totalVol = mViewCellsTree->GetRoot()->GetVolume(); 
     566 
     567        //float vol = 0; 
     568        //int smallerCost = 0; 
     569        int j = 0; 
    566570        int i = 0; 
    567         int j = 0; 
    568  
    569571         
    570572        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end();              
     
    574576    while (1) 
    575577        { 
     578                float vol = 0; 
     579                int smallerCost = 0; 
     580 
    576581                while ((i < (int)viewCells.size()) && (viewCells[i]->GetRenderCost() < currentRenderCost)) 
    577582                { 
     
    580585                        ++ smallerCost; 
    581586                } 
    582  
    583                 if ((i >= (int)viewCells.size()) || (currentRenderCost >= maxRenderCost)) 
     587                 
     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)) 
    584592                        break; 
    585  
     593                 
    586594                float rcRatio = currentRenderCost / maxRenderCost; 
    587595                float volRatio = vol / totalVol; 
    588596 
    589                 outstream << "#Pass\n" << j ++ << endl; 
    590                 outstream << "#RenderCost\n" << rcRatio << endl; 
    591                 //fprintf(outstream, "#RenderCost\n%3.3f", rcRatio); 
    592                 outstream << "#ViewCells\n" << i << endl;                
     597                outstream << "#Pass\n" << j << endl; 
     598                outstream << "#RenderCostRatio\n" << rcRatio << endl; 
     599                outstream << "#WeightedCost\n" << currentRenderCost / totalVol << endl; 
     600                outstream << "#ViewCells\n" << smallerCost << endl;              
    593601                outstream << "#Volume\n" << volRatio << endl << endl; 
    594602 
    595603                // increase current render cost 
    596604                currentRenderCost += stepSize; 
     605                ++ j; 
    597606        } 
    598607 
     
    617626        minPvsSize = viewCells.front()->GetPvs().GetSize(); 
    618627        maxPvsSize = viewCells.back()->GetPvs().GetSize(); 
     628         
     629        Debug << "histogram minpvssize: " << minPvsSize << " maxpvssize: " << maxPvsSize << endl; 
    619630 
    620631        const int intervals = min(10000, (int)viewCells.size()); 
     
    629640        int currentPvsSize = minPvsSize;//(int)ceil(minRenderCost); 
    630641 
    631         float vol = 0; 
    632         int smallerCost = 0; 
    633  
     642        //float vol = 0; 
    634643        int i = 0; 
    635644        int j = 0; 
    636645 
    637          
    638646        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end();              
    639647         
    640         // note can skip computations for view cells already evaluated and delete them from vector ... 
    641     while (1) 
    642         { 
     648        while (1) 
     649        { 
     650                float vol = 0; 
     651                int smaller = 0; 
     652 
    643653                while ((i < (int)viewCells.size()) && (viewCells[i]->GetPvs().GetSize() < currentPvsSize)) 
    644654                { 
    645655                        vol += viewCells[i]->GetVolume(); 
    646656                        ++ i; 
    647                         ++ smallerCost; 
    648                 } 
     657                        ++ smaller; 
     658                } 
     659                 
     660                if (i < (int)viewCells.size()) 
     661                        Debug << "new pvs size increase: " << viewCells[i]->GetPvs().GetSize() << " " << currentPvsSize << endl; 
    649662 
    650663                if ((i >= (int)viewCells.size()) || (currentPvsSize >= maxPvsSize)) 
     
    655668                outstream << "#Pass\n" << j ++ << endl; 
    656669                outstream << "#Pvs\n" << currentPvsSize << endl; 
    657                 //fprintf(outstream, "#RenderCost\n%3.3f", rcRatio); 
    658                 outstream << "#ViewCells\n" << i << endl;                
     670                outstream << "#ViewCells\n" << smaller << endl;          
    659671                outstream << "#Volume\n" << volRatio << endl << endl; 
    660672 
     
    756768        environment->GetIntValue("ViewCells.Evaluation.histoPasses", histoPasses); 
    757769 
     770        int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 
     771 
     772        Debug << "number of leaves: " << numLeaves << endl; 
     773        cout << "number of leaves: " << numLeaves << endl; 
     774 
    758775        if (useHisto) 
    759776        { 
     
    763780                for (int passes = 1; passes <= histoPasses; ++ passes) 
    764781                { 
    765                         int n = (int)mViewCells.size() * passes / histoPasses; 
     782                        int n = numLeaves * passes / histoPasses; 
    766783                 
    767784                        cout << "computing histogram for " << n << " view cells" << endl; 
     
    22922309        case 2: // merges 
    22932310                { 
    2294             int lSize = mViewCellsTree->GetSize(vc); 
     2311            int lSize = mViewCellsTree->GetNumInitialViewCells(vc); 
    22952312                        importance = (float)lSize / (float)mCurrentViewCellsStats.maxLeaves; 
    22962313                } 
     
    32183235        case 2: // merged leaves 
    32193236                { 
    3220                 int lSize = mViewCellsTree->GetSize(vc); 
     3237                int lSize = mViewCellsTree->GetNumInitialViewCells(vc); 
    32213238                        importance = (float)lSize / 
    32223239                                (float)mCurrentViewCellsStats.maxLeaves; 
     
    41464163        case 2: // merges 
    41474164                { 
    4148             int lSize = mViewCellsTree->GetSize(vc); 
     4165            int lSize = mViewCellsTree->GetNumInitialViewCells(vc); 
    41494166                        importance = (float)lSize / (float)mCurrentViewCellsStats.maxLeaves; 
    41504167                } 
Note: See TracChangeset for help on using the changeset viewer.