Ignore:
Timestamp:
11/03/05 18:49:59 (19 years ago)
Author:
mattausch
Message:

added bsp view cells statistics

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj

    r373 r375  
    255255                        </File> 
    256256                        <File 
     257                                RelativePath="..\src\Statistics.h"> 
     258                        </File> 
     259                        <File 
    257260                                RelativePath="..\src\Triangle3.cpp"> 
    258261                        </File> 
     
    286289                        <File 
    287290                                RelativePath="..\src\VisibilityVector3.h"> 
     291                        </File> 
     292                        <File 
     293                                RelativePath="..\src\VssPreprocessor.cpp"> 
     294                        </File> 
     295                        <File 
     296                                RelativePath="..\src\VssPreprocessor.h"> 
     297                        </File> 
     298                        <File 
     299                                RelativePath="..\src\VssRay.cpp"> 
     300                        </File> 
     301                        <File 
     302                                RelativePath="..\src\VssRay.h"> 
     303                        </File> 
     304                        <File 
     305                                RelativePath="..\src\VssTree.cpp"> 
     306                        </File> 
     307                        <File 
     308                                RelativePath="..\src\VssTree.h"> 
    288309                        </File> 
    289310                        <File 
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r371 r375  
    6868        maxViewCells 0 
    6969         
    70         minPvsDif 100 
     70        minPvsDif 1000 
    7171#       maxPvsSize 200 
    7272         
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r372 r375  
    414414} 
    415415 
    416 int Polygon3::CountIntersectables(const PolygonContainer &polys) 
     416int Polygon3::ParentObjectsSize(const PolygonContainer &polys) 
    417417{ 
    418418        int count = 0; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h

    r372 r375  
    122122        /** Counts the number of different intersectables associated with the polygons. 
    123123        */ 
    124         static int CountIntersectables(const PolygonContainer &polys); 
     124        static int ParentObjectsSize(const PolygonContainer &polys); 
    125125}; 
    126126 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r374 r375  
    514514                                 << "k   #SampleContributions=" << passSampleContributions << " ("  
    515515                                 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 
    516                                  << pvsSize/(float)objects.size() << endl  
     516                                 << pvsSize /(float)objects.size() << endl  
    517517                                 << "avg ray contrib=" << avgRayContrib << endl 
    518518                                 << "reverse samples [%]" << reverseSamples/(float)passSamples*100.0f << endl; 
     
    531531                cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    532532   
     533        //-- post processing of bsp view cells 
    533534        if (mBspTree) 
    534535        { 
     536                int vcSize = 0; 
     537                int pvsSize = 0; 
     538 
     539                BspViewCellsStatistics stat; 
     540                 
     541                Debug << "overall scene size: " << objects.size() << endl; 
     542                mBspTree->EvaluateViewCellsStats(stat); 
     543                 
     544                Debug << "original view cell partition:\n" << stat << endl; 
     545                 
    535546                cout << "starting post processing using " << mSampleRays.size() << " samples ... "; 
    536  
    537                 Debug << "original pvs size: " << mBspTree->CountViewCellPvs() << endl; 
    538  
    539                 // merge or subdivide view cells 
     547                 
    540548                long startTime = GetTime(); 
    541549                int merged = PostprocessViewCells(mSampleRays); 
     
    545553                         << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
    546554 
     555                cout << "evaluating render time heuristics ... "; 
     556 
    547557                //-- recount pvs 
    548                 Debug << "merged pvs size: " << mBspTree->CountViewCellPvs() << endl; 
    549  
    550  
    551                 cout << "evaluating render time heuristics ... "; 
     558                mBspTree->EvaluateViewCellsStats(stat); 
     559                 
     560                Debug << "after post processing:\n" << stat << endl; 
     561 
    552562                Real rt = SimulateRendering(); 
    553563                cout << "finished" << endl; 
     
    591601 
    592602                // export the bsp splits 
     603                cout << "exporting splits ... "; 
    593604                if (exportSplits) 
    594605                        ExportSplits(objects); 
    595                  
     606                cout << "finished" << endl; 
     607 
    596608                ExportBspPvs(objects); 
    597609        } 
     
    686698{ 
    687699        int merged = 0; 
     700 
    688701        RayContainer::const_iterator rit, rit_end = rays.end(); 
    689702        vector<Ray::BspIntersection>::const_iterator iit; 
     
    708721                        {                        
    709722                                mBspTree->MergeViewCells(leaf, previousLeaf); 
     723 
    710724                                ++ merged; 
    711725                        } 
     
    723737        if (exporter)  
    724738        {        
    725                 cout << "exporting splits ... "; 
    726  
    727739                Material m;  
    728740                m.mDiffuseColor = RgbColor(1, 0, 0); 
     
    769781 
    770782                delete exporter; 
    771  
    772                 cout << "finished" << endl; 
    773783        } 
    774784} 
     
    787797        const int raysOut = min((int)mSampleRays.size(), 20000); 
    788798 
    789         // check whether we can add the current ray to the output rays 
    790         for (int k = 0; k < raysOut; ++ k)  
     799        ViewCell::NewMail(); 
     800 
     801        for (int i = 0; i < bspLeaves.size(); ++ i) 
    791802        { 
    792                 Ray *ray = mSampleRays[k]; 
    793  
    794                 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
    795                 { 
    796                         BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 
    797  
    798                         for (int i = 0; i < (int)bspLeaves.size(); ++ i) 
     803                cout << "creating output for view cell " << i << " ... "; 
     804                // check whether we can add the current ray to the output rays 
     805                for (int k = 0; k < raysOut; ++ k)  
     806                { 
     807                        Ray *ray = mSampleRays[k]; 
     808 
     809                        for     (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
    799810                        { 
     811                                BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 
     812 
    800813                                if (bspLeaves[i]->GetViewCell() == leaf->GetViewCell())  
    801814                                { 
     
    804817                        } 
    805818                } 
    806         } 
    807  
    808         ViewCell::NewMail(); 
    809  
    810         for (int i = 0; i < bspLeaves.size(); ++ i) 
    811         { 
     819 
    812820                Intersectable::NewMail(); 
    813821 
     
    883891                } 
    884892                DEL_PTR(exporter); 
     893                cout << "finished" << endl; 
    885894        } 
    886895 
    887896        if (1) // export view cells and leaves 
    888897        { 
     898                cout << "exporting view cells and leaves ... "; 
    889899                Exporter *exporter = Exporter::GetExporter("viewCells.x3d"); 
    890900                if (exporter) 
     
    901911                        delete exporter; 
    902912                } 
     913                cout << "finished" << endl; 
    903914        } 
    904915 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r374 r375  
    343343} 
    344344 
     345void BspViewCellsStatistics::Print(ostream &app) const 
     346{ 
     347        app << "===== BspViewCells statistics ===============\n"; 
     348 
     349        app << setprecision(4); 
     350 
     351        app << "#N_PMAXPVS ( largest PVS )\n" << maxPvs << endl; 
     352 
     353        app << "#N_PMINPVS ( smallest PVS )\n" << minPvs << endl; 
     354 
     355        app << "#N_PAVGPVS ( average PVS )\n" << AvgPvs() << endl; 
     356 
     357        app << "#N_PEMPTYPVS ( view cells with PVS smaller 2 )\n" << emptyPvs << endl; 
     358 
     359        app << "#N_VIEWCELLS ( number of view cells)\n" << viewCells << endl; 
     360 
     361        app << "#N_AVGBSPLEAVES (average number of BSP leaves per view cell )\n" << AvgBspLeaves() << endl; 
     362 
     363        app << "#N_MAXBSPLEAVES ( maximal number of BSP leaves per view cell )\n" << maxBspLeaves << endl; 
     364         
     365        app << "===== END OF BspViewCells statistics ==========\n"; 
     366} 
     367 
    345368void BspTreeStatistics::Print(ostream &app) const 
    346369{ 
     
    368391        app << "#N_INPUT_POLYGONS (number of input polygons )\n" <<     polys << endl; 
    369392 
    370         app << "#N_PVS: " << pvs << endl; 
     393        //app << "#N_PVS: " << pvs << endl; 
    371394 
    372395        app << "#N_ROUTPUT_INPUT_POLYGONS ( ratio polygons after subdivision / input polygons )\n" << 
     
    375398        app << "===== END OF BspTree statistics ==========\n"; 
    376399} 
     400 
    377401 
    378402BspTree::~BspTree() 
     
    10441068                ((int)rays.size() > sTermMaxRaysForAxisAligned) && 
    10451069                ((sTermMaxObjectsForAxisAligned < 0) ||  
    1046                   (Polygon3::CountIntersectables(polys) > sTermMaxObjectsForAxisAligned))) 
     1070                  (Polygon3::ParentObjectsSize(polys) > sTermMaxObjectsForAxisAligned))) 
    10471071        { 
    10481072                Plane3 plane; 
     
    15291553        if (data.mDepth >= sTermMaxDepth) 
    15301554                ++ mStat.maxDepthNodes; 
     1555         
    15311556        // store maximal and minimal depth 
    15321557        if (data.mDepth > mStat.maxDepth) 
    15331558                mStat.maxDepth = data.mDepth; 
     1559 
    15341560        if (data.mDepth < mStat.minDepth) 
    15351561                mStat.minDepth = data.mDepth; 
     
    15371563        // accumulate depth to compute average 
    15381564        mStat.accumDepth += data.mDepth; 
    1539  
    1540         if (leaf->mViewCell != mRootCell) 
    1541         {        
    1542                 ++ mStat.viewCells; 
    1543                 mStat.pvs += leaf->mViewCell->GetPvs().GetSize(); 
    1544         } 
    15451565         
    15461566#ifdef _DEBUG 
     
    16951715} 
    16961716 
    1697 int BspTree::CountViewCellPvs() const 
    1698 { 
    1699         int count = 0; 
     1717void BspTree::EvaluateViewCellsStats(BspViewCellsStatistics &stat) const 
     1718{ 
     1719        stat.Reset(); 
     1720 
    17001721        stack<BspNode *> nodeStack; 
    17011722        nodeStack.push(mRoot); 
     
    17131734                if (node->IsLeaf())  
    17141735                { 
    1715                         ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->mViewCell; 
     1736                        ++ stat.bspLeaves; 
     1737 
     1738                        BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->mViewCell; 
    17161739 
    17171740                        if (!viewCell->Mailed())  
    17181741                        { 
    17191742                                viewCell->Mail(); 
    1720                                 count += viewCell->GetPvs().GetSize(); 
     1743                                 
     1744                                ++ stat.viewCells; 
     1745                                int pvsSize = viewCell->GetPvs().GetSize(); 
     1746 
     1747                stat.pvs += pvsSize; 
     1748 
     1749                                if (pvsSize < 2) 
     1750                                        ++ stat.emptyPvs; 
     1751 
     1752                                if (pvsSize > stat.maxPvs) 
     1753                                        stat.maxPvs = pvsSize; 
     1754 
     1755                                if (pvsSize < stat.minPvs) 
     1756                                        stat.minPvs = pvsSize; 
     1757 
     1758                                if ((int)viewCell->mBspLeaves.size() > stat.maxBspLeaves) 
     1759                                        stat.maxBspLeaves = (int)viewCell->mBspLeaves.size();            
    17211760                        } 
    17221761                } 
     
    17291768                } 
    17301769        } 
    1731         return count; 
    17321770} 
    17331771 
     
    23082346                Ray *ray = (*rit)->mRay; 
    23092347                 
    2310                 for (iit = ray->bspIntersections.begin(); iit != ray->bspIntersections.end(); ++ iit) 
     2348                for (iit = ray->bspIntersections.begin();  
     2349                         iit != ray->bspIntersections.end(); ++ iit) 
    23112350                { 
    23122351                        BspViewCell *vc = (*iit).mLeaf->mViewCell; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r373 r375  
    6868  // number of initial polygons 
    6969  int polys; 
    70   /// number of view cells different to the view cell representing unbounded space. 
    71   int viewCells; 
    72   /// size of the VPS 
    73   int pvs; 
    7470  /// samples contributing to pvs 
    7571  int contributingSamples; 
    7672   /// sample contributions to pvs 
    7773  int sampleContributions; 
     74  /// largest pvs 
     75  int largestPvs; 
    7876 
    7977  // Constructor 
     
    9795          polys = 0; 
    9896          accumDepth = 0; 
    99           viewCells = 0; 
    100           pvs = 0; 
     97                 
    10198          contributingSamples = 0; 
    10299          sampleContributions = 0; 
     
    107104 
    108105  friend ostream &operator<<(ostream &s, const BspTreeStatistics &stat) { 
     106    stat.Print(s); 
     107    return s; 
     108  } 
     109   
     110}; 
     111 
     112class BspViewCellsStatistics 
     113{ 
     114public: 
     115   
     116  /// number of view cells 
     117  int viewCells; 
     118 
     119  /// size of the PVS 
     120  int pvs; 
     121   
     122  /// largest PVS of all view cells 
     123  int maxPvs; 
     124 
     125  /// smallest PVS of all view cells 
     126  int minPvs; 
     127 
     128  /// view cells with empty PVS 
     129  int emptyPvs; 
     130 
     131  /// number of bsp leaves covering the view space 
     132  int bspLeaves; 
     133 
     134  /// largest number of leaves covered by one view cell 
     135  int maxBspLeaves; 
     136 
     137   
     138  // Constructor 
     139  BspViewCellsStatistics()  
     140  { 
     141          Reset(); 
     142  } 
     143 
     144  double AvgBspLeaves() const {return (double)bspLeaves / (double)viewCells;}; 
     145  double AvgPvs() const {return (double)pvs / (double)viewCells;}; 
     146   
     147   
     148  void Reset()  
     149  { 
     150          viewCells = 0; 
     151          pvs = 0; 
     152          maxPvs = 0; 
     153          minPvs = 999999; 
     154          emptyPvs = 0; 
     155          bspLeaves = 0; 
     156          maxBspLeaves = 0; 
     157  } 
     158 
     159  void 
     160  Print(ostream &app) const; 
     161 
     162  friend ostream &operator<<(ostream &s, const BspViewCellsStatistics &stat) { 
    109163    stat.Print(s); 
    110164    return s; 
     
    422476        bool MergeViewCells(BspLeaf *front, BspLeaf *back) const; 
    423477 
    424         /** Traverses tree and counts PVS size of all view cells 
    425         */ 
    426         int CountViewCellPvs() const; 
     478        /** Traverses tree and counts all view cells as well as their PVS size. 
     479        */ 
     480        void EvaluateViewCellsStats(BspViewCellsStatistics &stat) const; 
    427481 
    428482protected: 
     
    667721        BspNode *mRoot; 
    668722 
    669         /// Pointer to the root cell of the viewspace 
    670         // ViewCell *mRootCell; 
    671723                 
    672724        BspTreeStatistics mStat; 
Note: See TracChangeset for help on using the changeset viewer.