Changeset 1706 for GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
- Timestamp:
- 11/01/06 18:36:21 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1694 r1706 29 29 class PvsData { 30 30 public: 31 32 33 34 35 31 /// sum of probability density of visible sample rays 32 float mSumPdf; 33 34 PvsData() {} 35 PvsData(const float sumPdf): 36 36 mSumPdf(sumPdf) {} 37 37 38 39 40 41 42 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 } 44 44 }; 45 45 … … 47 47 class MailablePvsData 48 48 { 49 ////////////////////////////50 // Mailing stuff49 //////////////////////////// 50 // Mailing stuff 51 51 protected: 52 52 int mMailbox; 53 53 54 54 public: 55 56 57 58 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 61 61 static void NewMail(const int reserve = 1) { 62 62 sMailId += sReservedMailboxes; 63 63 sReservedMailboxes = reserve; 64 64 } 65 65 66 66 void Mail() { mMailbox = sMailId; } 67 67 bool Mailed() const { return mMailbox == sMailId; } … … 71 71 72 72 int IncMail() { return ++ mMailbox - sMailId; } 73 //////////////////////////////////////////74 75 76 77 78 79 80 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): 81 81 mSumPdf(sumPdf) {} 82 82 83 84 85 86 87 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 } 89 89 }; 90 90 … … 97 97 { 98 98 public: 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; 200 201 }; 201 202
Note: See TracChangeset
for help on using the changeset viewer.