Changeset 1790 for GTP/trunk/Lib/Vis
- Timestamp:
- 11/25/06 04:07:13 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1789 r1790 1554 1554 1555 1555 // no good results for degenerate axis split 1556 if (0 && tData.mNode->GetBoundingBox().Size(axis) < Limits::Small) 1556 if (0 && 1557 (tData.mNode->GetBoundingBox().Size(axis) < Limits::Small)) 1557 1558 nCostRatio[axis] += 9999; 1558 1559 … … 2549 2550 2550 2551 if (!InitialTerminationCriteriaMet(bsc->mParentData)) 2551 { cout << "here9"<<endl;2552 { 2552 2553 BvhNode *node = Subdivide(tempQueue, bsc, globalCriteriaMet); 2553 2554 … … 2556 2557 } 2557 2558 else // initial preprocessing finished for this candidate 2558 { cout << "here19"<<endl;2559 { 2559 2560 // add to "real" traversal queue 2560 2561 candidateContainer.push_back(bsc); … … 2608 2609 backObjects.push_back(*oit); 2609 2610 } 2610 TriangleIntersectable *tObj1 = (TriangleIntersectable *)frontObjects.back(); 2611 TriangleIntersectable *tObj2 = (TriangleIntersectable *)backObjects.front(); 2612 2613 cout << "here4 " << tObj1->GetItem().GetArea() << " " << tObj2->GetItem().GetArea() << endl; 2614 2615 2616 if (maxAreaDiff < 0.0001) 2617 cout << "big error!!!! " << maxAreaDiff << endl; 2618 2611 2619 2612 cout << "front: " << (int)frontObjects.size() << " back " << (int)backObjects.size() << " " << backObjects.front()->GetBox().SurfaceArea() - frontObjects.back()->GetBox().SurfaceArea() << endl; 2620 2613 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1789 r1790 206 206 @returns iterator on the sample. 207 207 */ 208 typename vector<PvsEntry<T, S> >::iterator Find(T sample, const bool checkDirty = true); 208 bool Find(T sample, 209 typename vector<PvsEntry<T, S> >::iterator &it, 210 const bool checkDirty = true); 209 211 210 212 bool GetSampleContribution(T sample, const float pdf, float &contribution); … … 391 393 float aSumPdf = 0.0f; 392 394 393 vector<PvsEntry<T, S> >::iterator oit = Find((*it).mObject); 394 395 const bool entryFound = (it != mEntries.end()) && ((*it).mObject == (*oit).mObject); 395 vector<PvsEntry<T, S> >::iterator oit; 396 const bool entryFound = Find((*it).mObject, oit); 396 397 397 398 if (entryFound) … … 427 428 (*it).mData.mSumPdf = -aSumPdf; 428 429 } else { 429 vector<PvsEntry<T, S> >::iterator oit = b.Find((*it).mObject);430 431 const bool entryFound = (it != mEntries.end()) && ((*it).mObject == (*oit).mObject);432 430 vector<PvsEntry<T, S> >::iterator oit; 431 432 const bool entryFound = b.Find((*it).mObject, oit); 433 433 434 if (entryFound) { 434 435 bSumPdf = (*oit).mData.mSumPdf; … … 461 462 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) 462 463 { 463 std::vector<PvsEntry<T, S> >::const_iterator bit = Find((*it).first); 464 if (bit == mEntries.end()) ++ dif; 464 vector<PvsEntry<T, S> >::iterator bit; 465 const bool entryFound = Find((*it).first, bit); 466 467 if (!entryFound) ++ dif; 465 468 } 466 469 … … 586 589 587 590 template <typename T, typename S> 588 typename std::vector<PvsEntry<T, S> >::iterator Pvs<T, S>::Find(T sample, const bool checkDirty) 589 { 591 bool Pvs<T, S>::Find(T sample, 592 typename vector<PvsEntry<T, S> >::iterator &it, 593 const bool checkDirty) 594 { 595 bool found = false; 596 590 597 PvsEntry<T, S> dummy(sample, PvsData()); 591 598 … … 593 600 //mLastSorted = 0; 594 601 vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 595 if (sorted_end != mEntries.end()) 596 cout << "not entries end!! " << endl; 602 597 603 // binary search 598 vector<PvsEntry<T, S> >::iterator it = lower_bound(mEntries.begin(), sorted_end, dummy); 604 it = lower_bound(mEntries.begin(), sorted_end, dummy); 605 606 if ((it != mEntries.end()) && ((*it).mObject == sample)) 607 found = true; 599 608 600 609 // sample not found yet => search further in the unsorted part 601 if (checkDirty && 602 ((it == mEntries.end()) || ((*it).mObject != sample))) 603 { 604 vector<PvsEntry<T, S> >::const_iterator it_end = mEntries.end(); 605 for (it = sorted_end; (it != it_end) && ((*it).mObject != sample); ++ it); 606 } 607 else cout << "f "; 608 return it; 610 if (!found && checkDirty) 611 { 612 vector<PvsEntry<T, S> >::const_iterator dit, dit_end = mEntries.end(); 613 614 for (dit = sorted_end; (dit != dit_end) && ((*dit).mObject != sample); ++ dit); 615 616 if ((dit != mEntries.end()) && ((*dit).mObject == sample)) 617 found = true; 618 } 619 620 return found; 609 621 } 610 622 … … 625 637 { 626 638 ++ mSamples; 627 cout << "! "; 628 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 629 630 if ((it != mEntries.end()) && ((*it).mObject == sample)) 631 { cout << "g"; 639 640 vector<PvsEntry<T, S> >::iterator it; 641 const bool entryFound = Find(sample, it); 642 643 if (entryFound) 644 { 632 645 S &data = (*it).mData; 633 646 data.mSumPdf += pdf; … … 635 648 } 636 649 else 637 { cout << "t";650 { 638 651 PvsEntry<T, S> entry(sample, pdf); 639 652 mEntries.insert(it, entry); … … 641 654 return pdf; 642 655 } 643 cout << " $";644 656 } 645 657 … … 654 666 655 667 template <typename T, typename S> 656 typename vector< PvsEntry<T, S> >::iterator Pvs<T, S>::AddSample2(T sample, const float pdf) 668 typename vector< PvsEntry<T, S> >::iterator Pvs<T, S>::AddSample2(T sample, 669 const float pdf) 657 670 { 658 671 ++ mSamples; 659 672 660 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 661 662 if ((it != mEntries.end()) && ((*it).mObject == sample)) 673 vector<PvsEntry<T, S> >::iterator it; 674 const bool entryFound == Find(sample, it); 675 676 if (entryFound) 663 677 { 664 678 S &data = (*it).second; … … 674 688 return it; 675 689 } 676 677 678 /*template <typename T, typename S>679 bool Pvs<T, S>::AddSample(T sample,680 const float pdf,681 float &contribution)682 {683 ++ mSamples;684 685 std::vector<PvsEntry<T, S> >::iterator it = Find(sample);686 687 if ((it != mEntries.end()) && ((*it).mObject == sample))688 {689 S &data = (*it).mData;690 691 data.mSumPdf += pdf;692 contribution = pdf / data.mSumPdf;693 694 return false;695 }696 else697 {698 PvsEntry<T, S> entry(sample, pdf);699 700 mEntries.insert(it, entry);701 contribution = 1.0f;702 ++ mLastSorted;703 704 return true;705 }706 }*/707 690 708 691 … … 717 700 ++ mSamples; 718 701 719 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 720 721 if ((it != mEntries.end()) && ((*it).mObject == sample)) 702 vector<PvsEntry<T, S> >::iterator it; 703 const bool entryFound = Find(sample, it); 704 705 if (entryFound) 722 706 { 723 707 S &data = (*it).mData; … … 743 727 float &contribution) 744 728 { 745 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 746 747 if (it != mEntries.end() && ((*it).mObject == sample)) 729 vector<PvsEntry<T, S> >::iterator it; 730 const bool entryFound = Find(sample, it); 731 732 if (entryFound) 748 733 { 749 734 S &data = (*it).mData; … … 764 749 -- mSamples; 765 750 766 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 767 768 if (it == mEntries.end()) 751 vector<PvsEntry<T, S> >::iterator it; 752 const bool entryFound = Find(sample, it); 753 754 if (!entryFound) 769 755 return false; 770 756 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1789 r1790 2694 2694 for (it = rays.begin(); it != it_end; ++ it) 2695 2695 { 2696 int contribution = 0;2696 float contribution = 0; 2697 2697 Ray *ray = (*it)->mRay; 2698 2698 float relContribution; … … 2707 2707 //relContribution); 2708 2708 2709 if (contribution )2710 { 2711 sampleContributions += contribution;2709 if (contribution > 0) 2710 { 2711 sampleContributions += (int)contribution; 2712 2712 ++ contributingSamples; 2713 2713 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1789 r1790 1956 1956 } 1957 1957 1958 /*1959 void1960 ViewCellsManager::AddSampleContributions(const VssRayContainer &rays)1961 {1962 if (!ViewCellsConstructed())1963 return;1964 1965 VssRayContainer::const_iterator it, it_end = rays.end();1966 cout <<"here60"<<endl;1967 for (it = rays.begin(); it != it_end; ++ it) {1968 AddSampleContributions(*(*it));1969 }1970 }1971 */1972 1958 1973 1959 int ViewCellsManager::GetMinPvsSize() const … … 1983 1969 } 1984 1970 1985 /*1986 void1987 ViewCellsManager::AddSampleContributions(VssRay &ray)1988 {cout << "here12" << endl;1989 // assumes viewcells have been stored...1990 ViewCellContainer *viewcells = &ray.mViewCells;1991 ViewCellContainer::const_iterator it;1992 1993 if (!ray.mTerminationObject)1994 return;1995 1996 Intersectable *obj = GetIntersectable(ray, true);1997 1998 for (it = viewcells->begin(); it != viewcells->end(); ++it)1999 {2000 ViewCell *viewcell = *it;2001 if (viewcell->GetValid())2002 {2003 Intersectable *entry = GetIntersectable(ray, true);2004 if (entry)2005 // if ray not outside of view space2006 viewcell->GetPvs().AddSample(entry, ray.mPdf);2007 }2008 }2009 }2010 */2011 1971 2012 1972 float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 2013 1973 const bool addRays, 2014 1974 const bool storeViewCells) 2015 { cout << "$$$$$$$$$$$$$4here10" << endl;1975 { 2016 1976 ViewCellContainer viewcells; 2017 1977 … … 6041 6001 6042 6002 6003 #define PVS_ADD_DIRTY 1 6043 6004 float VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray, 6044 6005 const bool addRays, … … 6094 6055 { 6095 6056 // todo: maybe not correct for kd node pvs 6096 /*if (viewcell->GetPvs().GetSampleContribution(6097 terminationObj, ray.mPdf, contribution))6057 if (viewcell->GetPvs().GetSampleContribution( 6058 terminationObj, ray.mPdf, contribution)) 6098 6059 { 6099 6060 ++ ray.mPvsContribution; 6100 6061 } 6101 ray.mRelativePvsContribution += contribution;*/ 6062 6063 ray.mRelativePvsContribution += contribution; 6102 6064 } 6103 6065 … … 6109 6071 #if SAMPLE_ORIGIN_OBJECTS 6110 6072 6111 /*if (originObj &&6073 if (originObj && 6112 6074 viewcell->GetPvs().GetSampleContribution(originObj, 6113 6075 ray.mPdf, … … 6116 6078 ++ ray.mPvsContribution; 6117 6079 ray.mRelativePvsContribution += contribution; 6118 } */6080 } 6119 6081 #endif 6120 6082 } … … 6135 6097 6136 6098 //$$JB hack 6137 float contrib; 6138 //viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf, contrib); 6139 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf);//, contrib); 6140 6141 if (viewCell->GetPvs().GetSize() == 50) 6142 //if (viewCell->GetPvs().RequiresResort()) 6143 {Intersectable::NewMail(); 6144 cout << "\nbefore sort: " << viewCell->GetPvs().GetLastSorted() << " \n"; 6145 ObjectPvsIterator pit = viewCell->GetPvs().GetIterator(); int i = 0; 6146 while (pit.HasMoreEntries()) 6147 { 6148 ObjectPvsEntry entry = pit.Next(); 6149 Intersectable *object = entry.mObject; 6150 6151 if ((i ++) == viewCell->GetPvs().GetLastSorted()) 6152 cout << "| "; 6153 6154 //if (object->Mailed()) cout << "error!!"<<endl; 6155 object->Mail(); 6156 cout << (int)object << " "; 6157 } 6158 6159 //viewCell->GetPvs().Sort(); 6160 6161 /*cout << "\nafter sort\n"; 6162 pit = viewCell->GetPvs().GetIterator(); i = 0; 6163 while (pit.HasMoreEntries()) 6164 { 6165 ObjectPvsEntry entry = pit.Next(); 6166 Intersectable *object = entry.mObject; 6167 6168 if ((i ++) == viewCell->GetPvs().GetLastSorted()) 6169 cout << "| "; 6170 cout << (int)object << " "; 6171 }*/ 6172 } 6173 //else cout << "b"; 6099 6100 #if PVS_ADD_DIRTY 6101 viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf); 6102 #else 6103 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf); 6104 #endif 6105 6174 6106 #if SAMPLE_ORIGIN_OBJECTS 6175 //viewCell->GetPvs().AddSample(originObj, ray.mPdf); 6107 #if PVS_ADD_DIRTY 6108 viewCell->GetPvs().AddSampleDirtyCheck(originObj, ray.mPdf); 6109 #else 6110 viewCell->GetPvs().AddSample(originObj, ray.mPdf); 6176 6111 #endif 6112 #endif 6113 if (viewCell->GetPvs().RequiresResort()) 6114 { 6115 viewCell->GetPvs().Sort(); 6116 } 6177 6117 } 6178 6118 … … 6310 6250 ////////////// 6311 6251 // filtered stats 6252 6312 6253 sprintf(suffix, "-%09d-eval-filter.log", castSamples); 6313 6254 const string filename2 = string(statsPrefix) + string(suffix);
Note: See TracChangeset
for help on using the changeset viewer.