Changeset 1877 for GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
- Timestamp:
- 12/11/06 08:31:01 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1867 r1877 184 184 int Compress() {return 0;} 185 185 int GetSize() const {return (int)mEntries.size();} 186 bool Empty() const {return mEntries.empty();} 187 186 bool Empty() const {return mEntries.empty();} 187 188 void Reserve(const int n) { mEntries.reserve(n); } 188 189 /** Normalize the visibility of entries in order to get 189 190 comparable results. … … 231 232 */ 232 233 void Sort(); 234 235 /** Sort pvs entries assume that the pvs contains unique entries 236 */ 237 void SimpleSort(); 233 238 234 239 /** Adds sample to PVS. Assumes that the pvs is sorted … … 307 312 // way we can achieve logarithmic behaviour for insertion and find 308 313 const int dirtySize = (int)mEntries.size() - mLastSorted; 309 return dirtySize > (int)(log((double)mEntries.size()) / log(2.0));314 return dirtySize > 4*(int)(log((double)mEntries.size()) / log(2.0)); 310 315 } 311 316 … … 362 367 mEntries = newPvs.mEntries; 363 368 mLastSorted = (int)mEntries.size(); 369 } 370 371 template <typename T, typename S> 372 void Pvs<T, S>::SimpleSort() 373 { 374 sort(mEntries.begin(), mEntries.end()); 375 mLastSorted = (int)mEntries.size(); 364 376 } 365 377 … … 587 599 const bool checkDirty) 588 600 { 589 bool found = false; 590 591 PvsEntry<T, S> dummy(sample, PvsData()); 592 593 // only check clean part 594 // $$ TMP JB 595 // mLastSorted = 0; 596 vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 597 598 // binary search 599 it = lower_bound(mEntries.begin(), sorted_end, dummy); 600 601 if ((it != mEntries.end()) && ((*it).mObject == sample)) 602 found = true; 603 604 // sample not found yet => search further in the unsorted part 605 if (!found && checkDirty) 606 { 607 vector<PvsEntry<T, S> >::const_iterator dit, dit_end = mEntries.end(); 608 609 for (dit = sorted_end; (dit != dit_end) && ((*dit).mObject != sample); ++ dit) ; 610 611 if ((dit != mEntries.end()) && ((*dit).mObject == sample)) 612 found = true; 613 } 614 615 return found; 601 bool found = false; 602 603 PvsEntry<T, S> dummy(sample, PvsData()); 604 605 // only check clean part 606 vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 607 608 // binary search 609 it = lower_bound(mEntries.begin(), sorted_end, dummy); 610 611 if ((it != mEntries.end()) && ((*it).mObject == sample)) 612 found = true; 613 614 // sample not found yet => search further in the unsorted part 615 if (!found && checkDirty) { 616 vector<PvsEntry<T, S> >::const_iterator dit, dit_end = mEntries.end(); 617 618 for (dit = sorted_end; (dit != dit_end) && ((*dit).mObject != sample); ++ dit) ; 619 620 if (dit != dit_end) 621 found = true; 622 } 623 624 return found; 616 625 } 617 626 … … 698 707 const bool entryFound = Find(sample, it); 699 708 700 if (entryFound) 701 { 702 S &data = (*it).mData; 703 704 data.mSumPdf += pdf; 705 //contribution = pdf / data.mSumPdf; 706 707 return false; 708 } 709 else 710 { 711 AddSampleDirty(sample, pdf); 712 //contribution = 1.0f; 713 714 return true; 709 if (entryFound) { 710 S &data = (*it).mData; 711 712 data.mSumPdf += pdf; 713 //contribution = pdf / data.mSumPdf; 714 715 return false; 716 } 717 else { 718 AddSampleDirty(sample, pdf); 719 //contribution = 1.0f; 720 return true; 715 721 } 716 722 }
Note: See TracChangeset
for help on using the changeset viewer.