Ignore:
Timestamp:
01/03/08 15:53:44 (17 years ago)
Author:
bittner
Message:

big merge: preparation for havran ray caster, check if everything works

File:
1 edited

Legend:

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

    r2571 r2575  
    2424#include "SamplingStrategy.h" 
    2525#include "SceneGraph.h" 
     26 
     27#ifdef PERFTIMER   
    2628#include "Timer/PerfTimer.h" 
    27  
     29#endif // PERFTIMER 
    2830 
    2931#define USE_RAY_LENGTH_AS_CONTRIBUTION 0 
     
    3941 
    4042 
     43#ifdef PERFTIMER   
    4144PerfTimer viewCellCastTimer; 
    4245PerfTimer pvsTimer; 
    4346PerfTimer objTimer; 
    44  
     47#endif 
     48   
    4549// HACK 
    4650const static bool SAMPLE_AFTER_SUBDIVISION = true; 
     
    6670}; 
    6771 
     72 
     73 
     74struct SortableViewCellEntry { 
     75 
     76        SortableViewCellEntry() {} 
     77        SortableViewCellEntry(const float v, ViewCell *cell):mValue(v), mViewCell(cell) {} 
     78 
     79        float mValue; 
     80        ViewCell *mViewCell; 
     81 
     82  friend bool operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b); 
     83}; 
     84 
     85 
     86inline bool 
     87operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b) { 
     88  return a.mValue < b.mValue; 
     89} 
    6890 
    6991ViewCellsManager::ViewCellsManager(ViewCellsTree *viewCellsTree): 
     
    10591081        int id; 
    10601082 
     1083#ifdef PERFTIMER   
    10611084        PerfTimer boxTimer; 
    10621085 
    10631086        boxTimer.Start(); 
    10641087        boxTimer.Entry(); 
    1065          
     1088#endif   
    10661089        for (int i = 0; i < numBoxes; ++ i) 
    10671090        { 
     
    10741097 
    10751098 
     1099#ifdef PERFTIMER   
    10761100        boxTimer.Exit(); 
    10771101 
    10781102        Debug << numBoxes << " boxes loaded in " << boxTimer.TotalTime() << " secs" << endl; 
     1103#endif 
    10791104} 
    10801105 
     
    16991724inline float EvalMergeCost(ViewCell *root, ViewCell *candidate) 
    17001725{ 
    1701         return root->GetPvs().GetPvsHomogenity(candidate->GetPvs()); 
     1726  return root->GetPvs().GetPvsHomogenity(candidate->GetPvs()); 
    17021727} 
    17031728 
     
    17731798} 
    17741799 
    1775  
    1776 struct SortableViewCellEntry { 
    1777  
    1778         SortableViewCellEntry() {} 
    1779         SortableViewCellEntry(const float v, ViewCell *cell):mValue(v), mViewCell(cell) {} 
    1780  
    1781         float mValue; 
    1782         ViewCell *mViewCell; 
    1783  
    1784         friend bool operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b) { 
    1785                 return a.mValue < b.mValue; 
    1786         } 
    1787 }; 
    17881800 
    17891801 
     
    21142126        } 
    21152127 
     2128#ifdef PERFTIMER   
    21162129        cout << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 
    21172130        Debug << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 
     
    21192132        cout << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 
    21202133        Debug << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 
    2121          
     2134#endif   
    21222135        return sum; 
    21232136} 
     
    28692882        ViewCell::NewMail(); 
    28702883 
     2884#ifdef PERFTIMER   
    28712885        viewCellCastTimer.Entry(); 
    2872  
     2886#endif 
    28732887        static ViewCellContainer viewCells; 
    28742888        static VssRay *lastVssRay = NULL; 
     
    28892903        } 
    28902904 
     2905#ifdef PERFTIMER   
    28912906        viewCellCastTimer.Exit(); 
    2892  
     2907#endif 
    28932908        mSamplesStat.mViewCells += (int)viewCells.size(); 
    28942909 
     
    29082923        Intersectable *terminationObj; 
    29092924 
     2925#ifdef PERFTIMER   
    29102926        objTimer.Entry(); 
    2911  
     2927#endif 
    29122928        // obtain pvs entry (can be different from hit object) 
    29132929        terminationObj = ray.mTerminationObject; 
    29142930 
     2931#ifdef PERFTIMER   
    29152932        objTimer.Exit(); 
    29162933 
    29172934        pvsTimer.Entry(); 
    2918  
     2935#endif 
     2936         
    29192937        ViewCellContainer::const_iterator it = viewCells.begin(); 
    29202938 
     
    29292947        } 
    29302948 
     2949#ifdef PERFTIMER   
    29312950        pvsTimer.Exit(); 
    2932  
     2951#endif 
     2952         
    29332953        mSamplesStat.mPvsContributions += ray.mPvsContribution; 
    29342954        if (ray.mPvsContribution) 
     
    34603480                                                           const float filterSize, 
    34613481                                                           ObjectPvs &pvs, 
    3462                                                            vector<AxisAlignedBox3> *filteredBoxes 
     3482                                                           vector<AxisAlignedBox3> *filteredBoxes, 
     3483                                                           const bool onlyNewObjects 
    34633484                                                           ) 
    34643485{ 
     
    34803501 
    34813502        if (!mUseKdPvs) 
    3482         {       // first mark all objects from this pvs 
    3483                 while (pit.HasMoreEntries())     
    3484                         pit.Next()->Mail(); 
    3485         } 
    3486  
     3503        { 
     3504          // first mark all objects from this pvs 
     3505          while (pit.HasMoreEntries())   
     3506                pit.Next()->Mail(); 
     3507        } 
     3508         
    34873509        int pvsSize = 0; 
    34883510        int nPvsSize = 0; 
     
    35483570 
    35493571                pit = basePvs.GetIterator(); 
    3550  
     3572                 
     3573                if (onlyNewObjects) { 
     3574                  while (pit.HasMoreEntries()) { 
     3575                        // mail all objects from the original not to include them in the 
     3576                        // resulting pvs 
     3577                        Intersectable *obj = pit.Next(pvsData); 
     3578                        obj->Mail(); 
     3579                  } 
     3580                  pit = basePvs.GetIterator(); 
     3581                } 
     3582                 
    35513583                while (pit.HasMoreEntries())  
    35523584                {                
     
    36313663                stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
    36323664        } 
    3633  
     3665         
    36343666        //Debug << " nPvs size = " << pvs.GetSize() << endl; 
    36353667 
    3636         if (!mUseKdPvs) 
     3668        if (!mUseKdPvs && !onlyNewObjects) 
    36373669        { 
    36383670                PvsData pvsData; 
     
    71627194        CLEAR_CONTAINER(tmpRays); 
    71637195 
     7196#ifdef PERFTIMER   
    71647197        cout << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 
    71657198        Debug << "view cell cast time: " << viewCellCastTimer.TotalTime() << " s" << endl; 
    7166  
    71677199        cout << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 
    71687200        Debug << "pvs time: " << pvsTimer.TotalTime() << " s" << endl; 
     7201#endif 
    71697202         
    71707203        return sum; 
     
    71747207 
    71757208 
    7176 ViewCellsManager *ViewCellsManager::LoadViewCellsBinary(const string &filename,  
    7177                                                                                                                 ObjectContainer &pvsObjects, 
    7178                                                                                                                 bool finalizeViewCells, 
    7179                                                                                                                 BoundingBoxConverter *bconverter)                                                                                                 
    7180 { 
    7181         IN_STREAM stream(filename.c_str()); 
    7182  
    7183         if (!stream.is_open()) 
     7209ViewCellsManager * 
     7210ViewCellsManager::LoadViewCellsBinary(const string &filename,  
     7211                                                                          ObjectContainer &pvsObjects, 
     7212                                                                          bool finalizeViewCells, 
     7213                                                                          BoundingBoxConverter *bconverter)                                                                                               
     7214{ 
     7215  IN_STREAM stream(filename.c_str()); 
     7216   
     7217  if (!stream.is_open()) 
    71847218        { 
    71857219                Debug << "View cells loading failed: could not open file" << endl; 
Note: See TracChangeset for help on using the changeset viewer.