Changeset 1738 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 11/10/06 02:09:56 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1736 r1738 266 266 { 267 267 SubdivisionCandidate *splitCandidate = splitQueue.Top(); 268 269 if (splitCandidate->IsDirty()) 270 splitCandidate->EvalCandidate(); 271 268 272 splitQueue.Pop(); 269 273 … … 1837 1841 1838 1842 // hack: should not be done here 1839 ObjectPvs Map::const_iterator oit, oit_end = pvs.mEntries.end();1843 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 1840 1844 1841 1845 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) … … 1937 1941 { 1938 1942 subStats.mTotalRenderCost -= subStats.mRenderCostDecrease; 1939 subStats.mEntriesInPvs += entriesIncr;1943 //subStats.mEntriesInPvs += entriesIncr; 1940 1944 1941 1945 // if (rcDecr <= 0) -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1707 r1738 131 131 132 132 133 134 133 float ObjectPvs::EvalPvsCost() const 135 134 { … … 140 139 BvhLeaf::NewMail(); 141 140 142 ObjectPvs Map::const_iterator it, it_end = mEntries.end();141 ObjectPvsEntries::const_iterator it, it_end = mEntries.end(); 143 142 144 143 for (it = mEntries.begin(); it != it_end; ++ it) -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1737 r1738 89 89 }; 90 90 91 92 91 /** Template class representing the Potentially Visible Set (PVS) 93 92 mainly from a view cell, but also e.g., from objects. … … 97 96 { 98 97 public: 98 //vector<pair<T, S> >::iterator mItEnd; 99 template<typename T, typename S> 100 class Iterator 101 { 102 //template<typename T, typename S> friend Pvs<T, S>; 103 private: 104 //std::vector<std::pair<T, S> >::iterator mIt; 105 //vector<pair<T, S> >::iterator mItEnd; 106 }; 107 108 template<typename T, typename S> 109 class ConstIterator 110 { 111 // template<typename T, typename S> friend Pvs<T, S>; 112 private: 113 //vector<pair<T, S> >::const_iterator mIt; 114 //vector<pair<T, S> >::const_iteator mItEnd; 115 }; 116 99 117 Pvs(): mSamples(0), mEntries() {} 100 118 … … 185 203 /** Compute continuous PVS difference */ 186 204 float GetPvsHomogenity(Pvs<T, S> &pvs) { 187 float 188 pvsReduction, 189 pvsEnlargement; 205 float pvsReduction, pvsEnlargement; 190 206 191 207 ComputeContinuousPvsDifference(pvs, … … 198 214 int Size() { return mEntries.size(); } 199 215 200 /// Map of PVS entries 201 std::map<T, S, LtSample<T> > mEntries; 202 //vector<pair<T, S> > mEntries; 216 //vector<pair<T, S> >::const_iterator &GetConstIterator() const { return mEntries.begin(); } 217 //vector<pair<T, S> >::iterator &GetIterator() { return mEntries.begin(); } 218 219 //protected: 220 221 /// vector of PVS entries 222 vector<pair<T, S> > mEntries; 203 223 204 224 /// Number of samples used to create the PVS … … 221 241 pvsReduction = 0.0f; 222 242 pvsEnlargement = 0.0f; 223 224 std::map<T, S, LtSample<T> >::iterator it;225 226 227 228 float bSumPdf = (*it).second.mSumPdf;229 float aSumPdf = 0.0f;230 S *data = Find((*it).first);231 232 if (data)233 {234 aSumPdf = data->mSumPdf;235 // mark this entry as processed to avoid double counting236 data->mSumPdf = -aSumPdf;237 }243 // Uses sum of log differences, which corresponds to entropy 244 std::vector<pair<T, S> >::iterator it; 245 246 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) 247 { 248 float bSumPdf = (*it).second.mSumPdf; 249 float aSumPdf = 0.0f; 250 S *data = Find((*it).first); 251 252 if (data) 253 { 254 aSumPdf = data->mSumPdf; 255 // mark this entry as processed to avoid double counting 256 data->mSumPdf = -aSumPdf; 257 } 238 258 239 259 #if 0 240 float diff = bSumPdf - aSumPdf;241 242 if (diff > 0.0f) {243 244 } else {245 246 }260 float diff = bSumPdf - aSumPdf; 261 262 if (diff > 0.0f) { 263 pvsEnlargement += diff; 264 } else { 265 pvsReduction += -diff; 266 } 247 267 #else 248 if (!data)249 250 #endif 251 252 253 254 float aSumPdf = (*it).second.mSumPdf;255 float bSumPdf = 0.0f;256 if (aSumPdf < 0.0f) {257 258 259 260 } else {261 262 263 bSumPdf = data->mSumPdf;264 268 if (!data) 269 pvsEnlargement += 1.0f; 270 #endif 271 } 272 273 for (it = mEntries.begin(); it != mEntries.end(); ++ it) { 274 float aSumPdf = (*it).second.mSumPdf; 275 float bSumPdf = 0.0f; 276 if (aSumPdf < 0.0f) { 277 // this entry was already accounted for! 278 // just revert it back 279 (*it).second.mSumPdf = -aSumPdf; 280 } else { 281 S *data = b.Find((*it).first); 282 if (data) { 283 bSumPdf = data->mSumPdf; 284 } 265 285 #if 0 266 267 268 269 pvsEnlargement += diff;270 271 pvsReduction += -diff;272 286 float diff = bSumPdf - aSumPdf; 287 288 if (diff > 0.0f) { 289 pvsEnlargement += diff; 290 } else { 291 pvsReduction += -diff; 292 } 273 293 274 294 #else 275 if (!data) 276 pvsReduction += 1.0f; 277 #endif 278 } 279 } 280 } 295 if (!data) 296 pvsReduction += 1.0f; 297 #endif 298 } 299 } 300 } 301 281 302 282 303 template <typename T, typename S> … … 285 306 int dif = 0; 286 307 287 std:: map<T, S, LtSample<T> >::const_iterator it;308 std::vector<pair<T, S> >::const_iterator it; 288 309 289 310 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) … … 298 319 template <typename T, typename S> void Pvs<T, S>::Merge(const Pvs<T, S> &a) 299 320 { 300 301 std::map<T, S, LtSample<T> >::const_iterator it; 302 int samples = mSamples + a.mSamples; 303 304 for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 305 { 306 AddSample((*it).first, (*it).second.mSumPdf); 307 } 308 mSamples = samples; 321 #if TODO 322 const int samples = mSamples + a.mSamples; 323 324 std::vector<pair<T, S>> >::const_iterator it; 325 326 for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 327 { 328 AddSample((*it).first, (*it).second.mSumPdf); 329 } 330 331 mSamples = samples; 332 #endif 309 333 } 310 334 … … 319 343 S *Pvs<T, S>::Find(T sample) 320 344 { 321 std::map<T, S, LtSample<T> >::iterator i = mEntries.find(sample); 345 #if TODO 346 std::vector<pair<T, S>, LtSample<T> >::iterator i = mEntries.find(sample); 322 347 323 348 if (i != mEntries.end()) … … 329 354 return NULL; 330 355 } 356 #else 357 return NULL; 358 #endif 331 359 } 332 360 … … 336 364 S &data) 337 365 { 338 std::map<T, S, LtSample<T> >::iterator i = mEntries.begin();339 for (int k = 0; k != index && i != mEntries.end(); i++, k++);340 341 342 343 344 } 366 std::vector<pair<T, S> >::iterator i = mEntries.begin(); 367 for (int k = 0; k != index && i != mEntries.end(); ++ i, ++ k); 368 369 entry = (*i).first; 370 data = (*i).second; 371 } 372 345 373 346 374 template <typename T, typename S> … … 348 376 Pvs<T, S>::AddSample(T sample, const float pdf) 349 377 { 350 mSamples++; 351 S *data = Find(sample); 352 353 if (data) 354 { 355 data->mSumPdf += pdf; 356 return data->mSumPdf; 357 } 358 else 359 { 360 mEntries[sample] = S(pdf); 361 return pdf; 362 } 378 #if TODO 379 ++ mSamples; 380 S *data = Find(sample); 381 382 if (data) 383 { 384 data->mSumPdf += pdf; 385 return data->mSumPdf; 386 } 387 else 388 { 389 mEntries[sample] = S(pdf); 390 return pdf; 391 } 392 #else 393 return 0; 394 #endif 363 395 } 364 396 … … 388 420 float &contribution) 389 421 { 390 mSamples++; 391 S *data = Find(sample); 392 393 if (data) 394 { 395 data->mSumPdf += pdf; 396 contribution = pdf / data->mSumPdf; 397 return false; 398 } 399 else { 400 mEntries[sample] = S(pdf); 401 contribution = 1.0f; 422 ++ mSamples; 423 S *data = Find(sample); 424 #if TODO 425 if (data) 426 { 427 data->mSumPdf += pdf; 428 contribution = pdf / data->mSumPdf; 429 return false; 430 } 431 else { 432 mEntries[sample] = S(pdf); 433 contribution = 1.0f; 434 return true; 435 } 436 #else 402 437 return true; 403 } 438 #endif 404 439 } 405 440 … … 424 459 template <typename T, typename S> 425 460 bool Pvs<T, S>::RemoveSample(T sample, 426 461 const float pdf) 427 462 { 428 463 -- mSamples; 429 430 std::map<T, S, LtSample<T> >:: 431 iterator it = mEntries.find(sample); 464 #if TODO 465 std::vector<pair<T, S> >::iterator it = mEntries.find(sample); 432 466 433 467 if (it == mEntries.end()) … … 442 476 mEntries.erase(it); 443 477 } 444 478 #endif 445 479 return true; 446 480 } … … 450 484 { 451 485 int samples = mSamples + pvs.mSamples; 452 std:: map<T, S, LtSample<T> >::486 std::vector<pair<T, S> >:: 453 487 const_iterator it, it_end = pvs.mEntries.end(); 454 488 … … 468 502 int Pvs<T, S>::SubtractPvs(const Pvs<T, S> &pvs) 469 503 { 470 471 int samples = mSamples - pvs.mSamples; 472 std::map<T, S, LtSample<T> >:: 473 const_iterator it, it_end = pvs.mEntries.end(); 474 475 // output PVS of view cell 476 for (it = pvs.mEntries.begin(); it != it_end; ++ it) 477 RemoveSample((*it).first, (*it).second.mSumPdf); 478 479 mSamples = samples; 480 return GetSize(); 504 const int samples = mSamples - pvs.mSamples; 505 #if TODO 506 std::vector<pair<T, S> >:: 507 const_iterator it, it_end = pvs.mEntries.end(); 508 509 // output PVS of view cell 510 for (it = pvs.mEntries.begin(); it != it_end; ++ it) 511 RemoveSample((*it).first, (*it).second.mSumPdf); 512 513 mSamples = samples; 514 #endif 515 return GetSize(); 481 516 } 482 517 … … 484 519 void Pvs<T, S>::CollectEntries(std::vector<T> &entries) 485 520 { 486 std:: map<T, S, LtSample<T> >::521 std::vector<pair<T, S> >:: 487 522 const_iterator it, it_end = mEntries.end(); 488 523 … … 495 530 void Pvs<T, S>::NormalizeMaximum() 496 531 { 497 std:: map<T, S, LtSample<T> >::532 std::vector<pair<T, S> >:: 498 533 const_iterator it, it_end = mEntries.end(); 499 534 … … 555 590 //-- typedefs 556 591 557 typedef std::map<KdNode *, PvsData, LtSample<KdNode *> > KdPvsMap; 558 typedef std::map<Intersectable *, PvsData, LtSample<Intersectable *> > ObjectPvsMap; 559 typedef std::map<ViewCell *, MailablePvsData, LtSample<ViewCell *> > ViewCellPvsMap; 560 592 //typedef std::map<KdNode *, PvsData, LtSample<KdNode *> > KdPvsMap; 593 //typedef std::map<Intersectable *, PvsData, LtSample<Intersectable *> > ObjectPvsEntries; 594 //typedef std::map<ViewCell *, MailablePvsData, LtSample<ViewCell *> > ViewCellPvsEntries; 595 596 597 typedef std::vector<pair<Intersectable *, PvsData> > ObjectPvsEntries; 561 598 562 599 typedef Pvs<ViewCell *, MailablePvsData> ViewCellPvs; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1713 r1738 61 61 int count = 0; 62 62 63 ObjectPvs Map::const_iterator it, it_end = vc->GetPvs().mEntries.end();63 ObjectPvsEntries::const_iterator it, it_end = vc->GetPvs().mEntries.end(); 64 64 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 65 65 { … … 81 81 float pvs = (float)pvs1.GetSize(); 82 82 83 ObjectPvs Map::const_iterator it, it_end =pvs1.mEntries.end();83 ObjectPvsEntries::const_iterator it, it_end = pvs1.mEntries.end(); 84 84 85 85 Intersectable::NewMail(); … … 830 830 831 831 // compute new pvs size 832 ObjectPvs Map::const_iterator it, it_end = pvs1.mEntries.end();832 ObjectPvsEntries::const_iterator it, it_end = pvs1.mEntries.end(); 833 833 834 834 Intersectable::NewMail(); … … 1638 1638 ViewCellContainer::const_iterator cit, cit_end = interior->mChildren.end(); 1639 1639 1640 ObjectPvs Map::const_iterator oit;1640 ObjectPvsEntries::const_iterator oit; 1641 1641 1642 1642 // mail all objects in the leaf sets … … 1647 1647 ViewCell *vc = *cit; 1648 1648 1649 ObjectPvs Map::const_iterator oit_end = vc->GetPvs().mEntries.end();1649 ObjectPvsEntries::const_iterator oit_end = vc->GetPvs().mEntries.end(); 1650 1650 1651 1651 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 1669 1669 ViewCell *vc = *cit; 1670 1670 1671 ObjectPvs Map::const_iterator oit_end = vc->GetPvs().mEntries.end();1671 ObjectPvsEntries::const_iterator oit_end = vc->GetPvs().mEntries.end(); 1672 1672 1673 1673 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 1682 1682 1683 1683 // delete all the objects from the leaf sets which were moved to parent pvs 1684 ObjectPvs Map::const_iterator oit_end = interior->GetPvs().mEntries.end();1684 ObjectPvsEntries::const_iterator oit_end = interior->GetPvs().mEntries.end(); 1685 1685 1686 1686 for (oit = interior->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 1775 1775 for (it = leaves.begin(); it != it_end; ++ it) 1776 1776 { 1777 ObjectPvs Map::iterator oit, oit_end = (*it)->GetPvs().mEntries.end();1777 ObjectPvsEntries::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 1778 1778 1779 1779 for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 1825 1825 for (it = leaves.begin(); it != it_end; ++ it) 1826 1826 { 1827 ObjectPvs Map::iterator oit, oit_end = (*it)->GetPvs().mEntries.end();1827 ObjectPvsEntries::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 1828 1828 1829 1829 for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 2339 2339 void ViewCellsTree::ExportPvs(ViewCell *viewCell, OUT_STREAM &stream) 2340 2340 { 2341 ObjectPvs Map::iterator it, it_end = viewCell->GetPvs().mEntries.end();2341 ObjectPvsEntries::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 2342 2342 2343 2343 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1737 r1738 2475 2475 Intersectable::NewMail(); 2476 2476 2477 ObjectPvs Map::const_iterator oi;2477 ObjectPvsEntries::const_iterator oi; 2478 2478 2479 2479 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++ oi) … … 2527 2527 2528 2528 Intersectable::NewMail(); 2529 ObjectPvs Map::const_iterator oi;2529 ObjectPvsEntries::const_iterator oi; 2530 2530 // first mark all object from this pvs 2531 2531 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++ oi) { … … 2537 2537 int pvsSize = 0; 2538 2538 int nPvsSize = 0; 2539 float samples = pvs.mSamples;2539 float samples = (float)pvs.mSamples; 2540 2540 cout<<"Samples = "<<samples<<endl; 2541 2541 // cout<<"Filter size = "<<filterSize<<endl; … … 2595 2595 2596 2596 // update samples and globalC 2597 samples = pvs.mSamples;2597 samples = (float)pvs.mSamples; 2598 2598 globalC = 2.0f*filterSize/sqrt(samples); 2599 2599 cout<<"neighboring viewcells = "<<i-1<<endl; … … 2780 2780 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 2781 2781 { 2782 ObjectPvs Map::iterator pit, pit_end = (*oit).mEntries.end();2782 ObjectPvsEntries::iterator pit, pit_end = (*oit).mEntries.end(); 2783 2783 2784 2784 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) … … 3268 3268 { 3269 3269 Intersectable::NewMail(); 3270 ObjectPvs Map::const_iterator oit, oit_end = pvs.mEntries.end();3270 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 3271 3271 3272 3272 // output PVS of view cell … … 3769 3769 exporter->SetFilled(); 3770 3770 3771 ObjectPvs Map::iterator it, it_end = vc->GetPvs().mEntries.end();3771 ObjectPvsEntries::iterator it, it_end = vc->GetPvs().mEntries.end(); 3772 3772 // -- output PVS of view cell 3773 3773 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) … … 4617 4617 Intersectable::NewMail(); 4618 4618 4619 ObjectPvs Map::const_iterator oit, oit_end = pvs.mEntries.end();4619 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 4620 4620 cout << endl; 4621 4621 // output PVS of view cell … … 5448 5448 5449 5449 Intersectable::NewMail(); 5450 ObjectPvs Map::const_iterator oit, oit_end = pvs.mEntries.end();5450 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 5451 5451 5452 5452 // output PVS of view cell -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1737 r1738 85 85 86 86 // remove the parents from the object pvss 87 ObjectPvs Map::const_iterator oit, oit_end = parent->GetPvs().mEntries.end();87 ObjectPvsEntries::const_iterator oit, oit_end = parent->GetPvs().mEntries.end(); 88 88 89 89 for (oit = parent->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 104 104 105 105 // Add front view cell to the object pvsss 106 ObjectPvs Map::const_iterator oit, oit_end = vc->GetPvs().mEntries.end();106 ObjectPvsEntries::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 107 107 108 108 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) … … 2914 2914 #if WORK_WITH_VIEWCELL_PVS 2915 2915 // add first view cell to all the objects view cell pvs 2916 ObjectPvs Map::const_iterator oit,2916 ObjectPvsEntries::const_iterator oit, 2917 2917 oit_end = leaf->GetViewCell()->GetPvs().mEntries.end(); 2918 2918
Note: See TracChangeset
for help on using the changeset viewer.