Changeset 2019 for GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
- Timestamp:
- 01/23/07 00:11:50 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r2015 r2019 5 5 #include <vector> 6 6 #include "common.h" 7 #include <math.h> 8 using namespace std; 7 9 8 10 namespace GtpVisibilityPreprocessor { … … 171 173 172 174 public: 173 174 Pvs(): mSamples(0), mEntries(), mLastSorted(0) {}175 176 Pvs(): mSamples(0), mEntries(), mLastSorted(0), mQueriesSinceSort(0) {} 175 177 176 178 /** creates pvs and initializes it with the given entries. … … 312 314 // the last part should not be more than log of the sorted part. this 313 315 // way we can achieve logarithmic behaviour for insertion and find 314 const int dirtySize = (int)mEntries.size() - mLastSorted; 315 return dirtySize > 500; 316 // 4*(int)(log((double)mEntries.size()) / log(2.0)); 316 const int n = mEntries.size(); 317 const int dirtySize = n - mLastSorted; 318 319 #define LOG2E 1.442695040f 320 321 const float logN = log((float)max(1, n))/LOG2E; 322 const float logS = log((float)max(1, mLastSorted))/LOG2E; 323 const float logD = log((float)max(1, dirtySize))/LOG2E; 324 325 if (8*(n + 2*dirtySize*logD) < 326 mQueriesSinceSort*((mLastSorted*logS + dirtySize*dirtySize/2)/n - logN)) { 327 // cout<<"Q="<<mQueriesSinceSort<<" N="<<n<<" D="<<dirtySize<<endl; 328 return true; 329 } 330 return false; 317 331 } 318 332 … … 342 356 343 357 /// Last sorted entry in the pvs (important for find and merge) 344 int mLastSorted; 358 int mLastSorted; 359 360 int mQueriesSinceSort; 345 361 }; 346 362 … … 367 383 sort(it, newEnd); 368 384 //sort(mEntries.begin(), mEntries.end()); 369 385 370 386 // now merge sorted ranges 371 387 ObjectPvs newPvs; 372 388 Merge(newPvs, 373 mEntries.begin(), it, 374 it, newEnd, 375 mSamples, 0); 389 mEntries.begin(), 390 it, 391 it, 392 newEnd, 393 mSamples, 394 0); 376 395 377 396 mEntries = newPvs.mEntries; 378 397 mLastSorted = (int)mEntries.size(); 398 mQueriesSinceSort = 0; 379 399 } 380 400 … … 382 402 void Pvs<T, S>::SimpleSort() 383 403 { 384 sort(mEntries.begin(), mEntries.end()); 404 // sort(mEntries.begin(), mEntries.end()); 405 std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 406 407 sort(it, mEntries.end()); 408 inplace_merge(mEntries.begin(), it, mEntries.end()); 409 385 410 mLastSorted = (int)mEntries.size(); 411 mQueriesSinceSort = 0; 386 412 } 387 413 … … 610 636 { 611 637 PvsEntry<T, S> dummy(sample, PvsData()); 638 mQueriesSinceSort++; 612 639 613 640 // only check clean part
Note: See TracChangeset
for help on using the changeset viewer.