- Timestamp:
- 04/08/06 12:15:50 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r734 r735 1224 1224 "viewCells"); 1225 1225 1226 RegisterOption("ViewCells.Evaluation.histogram", 1227 optBool, 1228 "view_cells_evaluation_histogram=", 1229 "false"); 1230 1231 RegisterOption("ViewCells.Evaluation.histoPasses", 1232 optInt, 1233 "view_cells_evaluation_histo_passes=", 1234 "5"); 1235 1236 1226 1237 RegisterOption("ViewCells.renderCostEvaluationType", 1227 1238 optString, … … 2059 2070 "false"); 2060 2071 2061 RegisterOption("VspBspTree.useBreathFirstSplits", 2062 optBool, 2063 "vsp_bsp_breath_first_splits=", 2064 "false"); 2065 2066 RegisterOption("VspBspTree.useDepthFirstSplits", 2067 optBool, 2068 "vsp_bsp_depth_first_splits=", 2069 "false"); 2072 RegisterOption("VspBspTree.nodePriorityQueueType", 2073 optInt, 2074 "vsp_bsp_node_queue_type=", 2075 "0"); 2070 2076 2071 2077 RegisterOption("VspBspTree.useRandomAxis", -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r734 r735 541 541 outstream.open(filename.c_str()); 542 542 543 Debug << "here3" << endl;544 543 ViewCellContainer viewCells; 545 mViewCellsTree->CollectBestViewCellSet( mViewCells, nViewCells);544 mViewCellsTree->CollectBestViewCellSet(viewCells, nViewCells); 546 545 547 546 float maxRenderCost, minRenderCost; 548 549 /// find out the range for valid render cost550 ComputeMinMaxRenderCost(minRenderCost, maxRenderCost, viewCells);551 547 552 548 // sort by render cost … … 556 552 maxRenderCost = viewCells.back()->GetRenderCost(); 557 553 558 const int intervals = 10000; 554 const int intervals = min(10000, (int)viewCells.size()); 555 559 556 const float range = maxRenderCost - minRenderCost; 560 int currentRenderCost = (int)ceil(minRenderCost); 561 const int stepSize = (int)((float)range / (float)intervals); 557 const float stepSize = range / (float)intervals; 558 559 float currentRenderCost = minRenderCost;//(int)ceil(minRenderCost); 560 561 const float totalRenderCost = mViewCellsTree->GetRoot()->GetRenderCost(); 562 const float totalVol = GetViewSpaceBox().GetVolume(); 562 563 563 564 float vol = 0; 564 565 int smallerCost = 0; 565 566 int i = 0; 567 int j = 0; 568 569 566 570 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 567 571 568 int i = 0; 569 572 570 573 // note can skip computations for view cells already evaluated and delete them from vector ... 571 574 while (1) 572 575 { 573 Debug << "here4" << endl;574 576 while ((i < (int)viewCells.size()) && (viewCells[i]->GetRenderCost() < currentRenderCost)) 575 577 { 576 577 Debug << "here5" << endl; 578 vol += viewCells[i]->GetVolume(); 578 579 ++ i; 579 580 ++ smallerCost; 580 vol += viewCells[i]->GetVolume(); 581 } 582 581 } 582 583 if ((i >= (int)viewCells.size()) || (currentRenderCost >= maxRenderCost)) 584 break; 585 586 float rcRatio = currentRenderCost / maxRenderCost; 587 float volRatio = vol / totalVol; 588 589 outstream << "#Pass\n" << j ++ << endl; 590 outstream << "#RenderCost\n" << rcRatio << endl; 591 //fprintf(outstream, "#RenderCost\n%3.3f", rcRatio); 592 outstream << "#ViewCells\n" << i << endl; 593 outstream << "#Volume\n" << volRatio << endl << endl; 594 595 // increase current render cost 583 596 currentRenderCost += stepSize; 584 585 outstream << "#RenderCost: " << currentRenderCost << endl; 586 outstream << "#ViewCells: " << smallerCost << endl; 587 outstream << "#Volume: " << vol << endl << endl; 588 } 597 } 598 589 599 outstream.close(); 590 Debug << "here6" << endl; 591 } 592 593 /* 594 void ViewCellsManager::EvalViewCellHistogramForPvs(const string filename,const int nViewCells)600 } 601 602 603 void ViewCellsManager::EvalViewCellHistogramForPvsSize(const string filename, 604 const int nViewCells) 595 605 { 596 606 std::ofstream outstream; … … 598 608 599 609 ViewCellContainer viewCells; 600 mViewCellsTree->CollectBestViewCellSet(mViewCells, nViewCells); 601 602 float maxRenderCost, minRenderCost; 603 /// find out the range for valid render cost 604 ComputeMinMaxRenderCost(minRenderCost, maxRenderCost, viewCells); 605 606 const int intervals = 10000; 607 const float range = maxRenderCost - minRenderCost; 608 int currentRenderCost = (int)ceil(minRenderCost); 609 const int stepSize = (int)((float)range / (float)intervals); 610 mViewCellsTree->CollectBestViewCellSet(viewCells, nViewCells); 611 612 int maxPvsSize, minPvsSize; 613 614 // sort by render cost 615 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 616 617 minPvsSize = viewCells.front()->GetPvs().GetSize(); 618 maxPvsSize = viewCells.back()->GetPvs().GetSize(); 619 620 const int intervals = min(10000, (int)viewCells.size()); 621 const int range = maxPvsSize - minPvsSize; 622 int stepSize = range / intervals; 623 624 if (!stepSize) stepSize = 1; 625 626 const float totalRenderCost = mViewCellsTree->GetRoot()->GetRenderCost(); 627 const float totalVol = GetViewSpaceBox().GetVolume(); 628 629 int currentPvsSize = minPvsSize;//(int)ceil(minRenderCost); 630 610 631 float vol = 0; 611 612 ViewCell::NewMail(); 613 614 for (; currentRenderCost < (int)maxRenderCost; currentRenderCost += stepSize) 615 { 616 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 617 618 int smallerCost = 0; 619 620 // note can skip computations for view cells already evaluated and delete them from vector ... 621 for (it = viewCells.begin(); it != viewCells.end(); ++ it) 622 { 623 if (!vc->Mailed()) 624 { 625 vc->Mail(); 626 ViewCell *vc = *it; 627 628 if (EvalRenderCost(vc) < currentRenderCost) 629 { 630 ++ smallerCost; 631 vol = (*it)->GetVolume(); 632 } 633 } 634 // note: can remove already found view cells 635 //swap(neighborhood[bestViewCellIdx], neighborhood.back()); 636 //neighborhood.pop_back(); 637 638 639 outstream << "#RenderCost: " << currentRenderCost << endl; 640 outstream << "#ViewCells: " << smallerCost << endl; 641 outstream << "#Volume: " << vol << endl << endl; 642 } 643 } 644 */ 632 int smallerCost = 0; 633 634 int i = 0; 635 int j = 0; 636 637 638 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 639 640 // note can skip computations for view cells already evaluated and delete them from vector ... 641 while (1) 642 { 643 while ((i < (int)viewCells.size()) && (viewCells[i]->GetPvs().GetSize() < currentPvsSize)) 644 { 645 vol += viewCells[i]->GetVolume(); 646 ++ i; 647 ++ smallerCost; 648 } 649 650 if ((i >= (int)viewCells.size()) || (currentPvsSize >= maxPvsSize)) 651 break; 652 653 float volRatio = vol / totalVol; 654 655 outstream << "#Pass\n" << j ++ << endl; 656 outstream << "#Pvs\n" << currentPvsSize << endl; 657 //fprintf(outstream, "#RenderCost\n%3.3f", rcRatio); 658 outstream << "#ViewCells\n" << i << endl; 659 outstream << "#Volume\n" << volRatio << endl << endl; 660 661 662 // increase current pvs size 663 currentPvsSize += stepSize; 664 } 665 outstream.close(); 666 } 667 645 668 646 669 void ViewCellsManager::EvalViewCellPartition(Preprocessor *preprocessor) … … 688 711 } 689 712 690 713 691 714 while (castSamples < numSamples) 692 715 { … … 727 750 } 728 751 729 #if 0 730 // evaluate view cells in a histogram 731 vector<int> nViewCells; 732 nViewCells.push_back(10000); 733 nViewCells.push_back(5000); 734 nViewCells.push_back(1000); 735 nViewCells.push_back(500); 736 nViewCells.push_back(100); 737 738 vector<int>::const_iterator iit, iit_end = nViewCells.end(); 739 char filename[64]; 740 741 for (iit = nViewCells.begin(); iit != nViewCells.end(); ++ iit) 742 { 743 Debug << "here2" << endl; 744 int n = *iit; 752 bool useHisto; 753 int histoPasses; 754 755 environment->GetBoolValue("ViewCells.Evaluation.histogram", useHisto); 756 environment->GetIntValue("ViewCells.Evaluation.histoPasses", histoPasses); 757 758 if (useHisto) 759 { 760 // evaluate view cells in a histogram 761 char s[64]; 762 763 for (int passes = 1; passes <= histoPasses; ++ passes) 764 { 765 int n = (int)mViewCells.size() * passes / histoPasses; 745 766 746 sprintf(filename, "histogram%06d.log", n); 747 EvalViewCellHistogram(filename, n); 748 } 749 750 #endif 767 cout << "computing histogram for " << n << " view cells" << endl; 768 769 //-- evaluate histogram for render cost 770 sprintf(s, "-%09d-histo.log", n); 771 string filename = string(statsPrefix) + string(s); 772 773 EvalViewCellHistogram(filename, n); 774 775 ////////////////////////////////////////// 776 // --evaluate histogram for pvs size 777 778 cout << "computing pvs histogram for " << n << " view cells" << endl; 779 780 sprintf(s, "-%09d-histo-pvs.log", n); 781 filename = string(statsPrefix) + string(s); 782 783 EvalViewCellHistogramForPvsSize(filename, n); 784 } 785 } 786 751 787 // find empty view cells bug 752 788 if (TEST_EMPTY_VIEW_CELLS) … … 802 838 803 839 case PER_TRIANGLE: 804 { 840 {cout << "pertriangle" << endl; 805 841 // HACK 806 842 MeshInstance *mi = dynamic_cast<MeshInstance *>(obj); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r728 r735 405 405 void EvalViewCellHistogram(const string filename, const int nViewCells); 406 406 407 /** Evaluautes histogram for a given number of view cells. 408 */ 409 void EvalViewCellHistogramForPvsSize(const string filename, const int nViewCells); 410 407 411 /** Evaluates the render cost of a view cell. 408 412 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r734 r735 120 120 environment->GetBoolValue("VspBspTree.simulateOctree", mSimulateOctree); 121 121 environment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 122 environment->Get BoolValue("VspBspTree.useBreathFirstSplits", mBreathFirstSplits);122 environment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 123 123 124 124 environment->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); … … 154 154 Debug << "subdivision stats log: " << subdivisionStatsLog << endl; 155 155 Debug << "use random axis: " << mUseRandomAxis << endl; 156 Debug << "breath first splits: " << mBreathFirstSplits << endl; 157 Debug << "depth first splits: " << mDepthFirstSplits << endl; 158 156 Debug << "priority queue type: " << mNodePriorityQueueType << endl; 159 157 Debug << "empty view cells merge: " << mEmptyViewCellsMergeAllowed << endl; 160 161 158 Debug << "octree: " << mSimulateOctree << endl; 162 159 … … 942 939 void VspBspTree::EvalPriority(VspBspTraversalData &tData) const 943 940 { 944 if (mBreathFirstSplits) 941 switch (mNodePriorityQueueType) 942 { 943 case BREATH_FIRST: 945 944 tData.mPriority = (float)-tData.mDepth; 946 else if (mDepthFirstSplits) 945 break; 946 case DEPTH_FIRST: 947 947 tData.mPriority = (float)tData.mDepth; 948 else 948 break; 949 default: 949 950 tData.mPriority = tData.mPvs * tData.mProbability; 950 //cout << "priority: " << tData.mPriority << endl; 951 //Debug << "priority: " << tData.mPriority << endl; 952 break; 953 } 951 954 } 952 955 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r734 r735 810 810 811 811 /// if we should use breath first priority for the splits 812 bool mBreathFirstSplits;813 bool mDepthFirstSplits; 812 int mNodePriorityQueueType; 813 814 814 bool mEmptyViewCellsMergeAllowed; 815 815 816 // priority queue strategy 817 enum {BREATH_FIRST, DEPTH_FIRST, COST_BASED}; 816 818 private: 817 819
Note: See TracChangeset
for help on using the changeset viewer.