Ignore:
Timestamp:
11/01/06 18:36:21 (18 years ago)
Author:
mattausch
Message:

worked on full evaluation framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1694 r1706  
    2929class PvsData { 
    3030public: 
    31   // sum of probability density of visible sample rays 
    32   float mSumPdf; 
    33  
    34   PvsData() {} 
    35   PvsData(const float sumPdf): 
     31        /// sum of probability density of visible sample rays 
     32        float mSumPdf; 
     33 
     34        PvsData() {} 
     35        PvsData(const float sumPdf): 
    3636        mSumPdf(sumPdf) {} 
    3737 
    38   // $$JB in order to return meaningfull values 
    39   // it assumes that the sum pdf has been normalized somehow!!! 
    40   float GetVisibility()  
    41   {  
    42           return mSumPdf;  
    43   } 
     38        // $$JB in order to return meaningfull values 
     39        // it assumes that the sum pdf has been normalized somehow!!! 
     40        float GetVisibility()  
     41        {  
     42                return mSumPdf;  
     43        } 
    4444}; 
    4545 
     
    4747class MailablePvsData  
    4848{ 
    49 //////////////////////////// 
    50 //  Mailing stuff 
     49        //////////////////////////// 
     50        //  Mailing stuff 
    5151protected: 
    5252        int mMailbox; 
    5353 
    5454public: 
    55   // last mail id -> warning not thread safe! 
    56   // both mailId and mailbox should be unique for each thread!!! 
    57   static int sMailId; 
    58   static int sReservedMailboxes; 
    59    
    60    
     55        // last mail id -> warning not thread safe! 
     56        // both mailId and mailbox should be unique for each thread!!! 
     57        static int sMailId; 
     58        static int sReservedMailboxes; 
     59 
     60 
    6161        static void NewMail(const int reserve = 1) { 
    6262                sMailId += sReservedMailboxes; 
    6363                sReservedMailboxes = reserve; 
    6464        } 
    65          
     65 
    6666        void Mail() { mMailbox = sMailId; } 
    6767        bool Mailed() const { return mMailbox == sMailId; } 
     
    7171 
    7272        int IncMail() { return ++ mMailbox - sMailId; } 
    73 ////////////////////////////////////////// 
    74  
    75   // sum of probability density of visible sample rays 
    76   float mSumPdf; 
    77   int mCounter; 
    78  
    79   MailablePvsData() {} 
    80   MailablePvsData(const float sumPdf): 
     73        ////////////////////////////////////////// 
     74 
     75        // sum of probability density of visible sample rays 
     76        float mSumPdf; 
     77        int mCounter; 
     78 
     79        MailablePvsData() {} 
     80        MailablePvsData(const float sumPdf): 
    8181        mSumPdf(sumPdf) {} 
    8282 
    83   // $$JB in order to return meaningfull values 
    84   // it assumes that the sum pdf has been normalized somehow!!! 
    85   float GetVisibility()  
    86   {  
    87           return mSumPdf;  
    88   } 
     83        // $$JB in order to return meaningfull values 
     84        // it assumes that the sum pdf has been normalized somehow!!! 
     85        float GetVisibility()  
     86        {  
     87                return mSumPdf;  
     88        } 
    8989}; 
    9090 
     
    9797{ 
    9898public: 
    99   Pvs(): /*mSamples(0), */mEntries() {} 
    100    
    101   //virtual ~Pvs(); 
    102      
    103   /** Compresses PVS lossless or lossy. 
    104   */ 
    105   int Compress() {return 0;} 
    106   int GetSize() const {return (int)mEntries.size();} 
    107   bool Empty() const {return mEntries.empty();} 
    108  
    109   /** Normalize the visibility of entries in order to get comparable 
    110           results  
    111   */ 
    112   void NormalizeMaximum(); 
    113    
    114   /** Merges pvs of a into this pvs. 
    115    */ 
    116   void Merge(const Pvs<T, S> &a); 
    117    
    118   /** Difference of pvs to pvs b. 
    119           @returns number of different entries. 
    120   */ 
    121   int Diff(const Pvs<T, S> &b); 
    122    
    123   /** Finds sample in PVS. 
    124           @returns sample if found, NULL otherwise. 
    125   */ 
    126   S *Find(T sample); 
    127  
    128   bool GetSampleContribution(T sample, const float pdf, float &contribution); 
    129    
    130   /** Adds sample to PVS.  
    131           @contribution contribution of sample (0 or 1) 
    132           @returns true if sample was not already in PVS. 
    133   */ 
    134   bool AddSample(T sample, const float pdf, float &contribution); 
    135  
    136   /** Adds sample to PVS. 
    137           @returns contribution of sample (0 or 1) 
    138   */ 
    139   float AddSample(T sample, const float pdf); 
    140    
    141   /** Adds sample to PVS. 
    142           @returns PvsData 
    143   */ 
    144   S *AddSample2(T sample, const float pdf); 
    145  
    146   /** Adds one pvs to another one. 
    147           @returns new pvs size 
    148   */ 
    149   int AddPvs(const Pvs<T, S> &pvs); 
    150  
    151   /** Subtracts one pvs from another one. 
    152   WARNING: could contains bugs 
    153           @returns new pvs size 
    154   */ 
    155   int SubtractPvs(const Pvs<T, S> &pvs); 
    156   /** Returns PVS data, i.e., how often it was seen from the view cell,  
    157           and the object itsef. 
    158   */ 
    159   void GetData(const int index, T &entry, S &data); 
    160  
    161   /** Collects the PVS entries and returns them in the vector. 
    162   */ 
    163   void CollectEntries(std::vector<T> &entries); 
    164  
    165   /** Removes sample from PVS if reference count is zero. 
    166           @param visibleSamples number of references to be removed 
    167   */ 
    168   bool RemoveSample(T sample, const float pdf); 
    169  
    170   /** Compute continuous PVS difference */ 
    171   void ComputeContinuousPvsDifference(Pvs<T, S> &pvs, 
    172                                                                           float &pvsReduction, 
    173                                                                           float &pvsEnlargement); 
    174    
    175  
    176   /** Clears the pvs. 
    177   */ 
    178   void Clear(); 
    179  
    180   static int GetEntrySizeByte();  
    181   static float GetEntrySize(); 
    182  
    183   /** Compute continuous PVS difference */ 
    184   float GetPvsHomogenity(Pvs<T, S> &pvs) { 
    185         float  
    186           pvsReduction, 
    187           pvsEnlargement; 
    188          
    189         ComputeContinuousPvsDifference(pvs, 
    190                                                                    pvsReduction, 
    191                                                                    pvsEnlargement); 
    192          
    193         return pvsReduction + pvsEnlargement; 
    194   } 
    195    
    196   int Size() { return mEntries.size(); } 
    197                                            
    198   /// Map of PVS entries 
    199   std::map<T, S, LtSample<T> > mEntries; 
     99        Pvs(): /*mSamples(0), */mEntries() {} 
     100 
     101        //virtual ~Pvs(); 
     102 
     103        /** Compresses PVS lossless or lossy. 
     104        */ 
     105        int Compress() {return 0;} 
     106        int GetSize() const {return (int)mEntries.size();} 
     107        bool Empty() const {return mEntries.empty();} 
     108 
     109        /** Normalize the visibility of entries in order to get comparable 
     110                results  
     111        */ 
     112        void NormalizeMaximum(); 
     113 
     114        /** Merges pvs of a into this pvs. 
     115        */ 
     116        void Merge(const Pvs<T, S> &a); 
     117 
     118        /** Difference of pvs to pvs b. 
     119                @returns number of different entries. 
     120        */ 
     121        int Diff(const Pvs<T, S> &b); 
     122 
     123        /** Finds sample in PVS. 
     124                @returns sample if found, NULL otherwise. 
     125        */ 
     126        S *Find(T sample); 
     127 
     128        bool GetSampleContribution(T sample, const float pdf, float &contribution); 
     129 
     130        /** Adds sample to PVS.  
     131                @contribution contribution of sample (0 or 1) 
     132                @returns true if sample was not already in PVS. 
     133        */ 
     134        bool AddSample(T sample, const float pdf, float &contribution); 
     135 
     136        /** Adds sample to PVS. 
     137                @returns contribution of sample (0 or 1) 
     138        */ 
     139        float AddSample(T sample, const float pdf); 
     140 
     141        /** Adds sample to PVS. 
     142                @returns PvsData 
     143        */ 
     144        S *AddSample2(T sample, const float pdf); 
     145 
     146        /** Adds one pvs to another one. 
     147                @returns new pvs size 
     148        */ 
     149        int AddPvs(const Pvs<T, S> &pvs); 
     150 
     151        /** Subtracts one pvs from another one. 
     152                WARNING: could contains bugs 
     153                @returns new pvs size 
     154        */ 
     155        int SubtractPvs(const Pvs<T, S> &pvs); 
     156        /** Returns PVS data, i.e., how often it was seen from the view cell,  
     157                and the object itsef. 
     158        */ 
     159        void GetData(const int index, T &entry, S &data); 
     160 
     161        /** Collects the PVS entries and returns them in the vector. 
     162        */ 
     163        void CollectEntries(std::vector<T> &entries); 
     164 
     165        /** Removes sample from PVS if reference count is zero. 
     166                @param visibleSamples number of references to be removed 
     167        */ 
     168        bool RemoveSample(T sample, const float pdf); 
     169 
     170        /** Compute continuous PVS difference  
     171        */ 
     172        void ComputeContinuousPvsDifference(Pvs<T, S> &pvs, 
     173                float &pvsReduction, 
     174                float &pvsEnlargement); 
     175 
     176 
     177        /** Clears the pvs. 
     178        */ 
     179        void Clear(); 
     180 
     181        static int GetEntrySizeByte();  
     182        static float GetEntrySize(); 
     183 
     184        /** Compute continuous PVS difference */ 
     185        float GetPvsHomogenity(Pvs<T, S> &pvs) { 
     186                float  
     187                        pvsReduction, 
     188                        pvsEnlargement; 
     189 
     190                ComputeContinuousPvsDifference(pvs, 
     191                        pvsReduction, 
     192                        pvsEnlargement); 
     193 
     194                return pvsReduction + pvsEnlargement; 
     195        } 
     196 
     197        int Size() { return mEntries.size(); } 
     198 
     199        /// Map of PVS entries 
     200        std::map<T, S, LtSample<T> > mEntries; 
    200201}; 
    201202 
Note: See TracChangeset for help on using the changeset viewer.