Changeset 580 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
- Timestamp:
- 02/01/06 19:29:59 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r579 r580 21 21 class ViewCellsStatistics; 22 22 class ViewCellsManager; 23 class BspMergeCandidate;23 class MergeCandidate; 24 24 class Beam; 25 25 … … 252 252 int TreeDistance(BspNode *n1, BspNode *n2) const; 253 253 254 /** Merges view cells according to some cost heuristics.255 */256 int MergeViewCells(const VssRayContainer &rays, const ObjectContainer &objects);257 258 /** Refines view cells using shuffling, i.e., border leaves259 of two view cells are exchanged if the resulting view cells260 are tested to be "better" than the old ones.261 @returns number of refined view cells262 */263 int RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects);264 265 254 /** Collapses the tree with respect to the view cell partition. 266 255 @returns number of collapsed nodes … … 272 261 ViewCell *GetViewCell(const Vector3 &point); 273 262 274 /** Constructs bsp rays for post processing and visualization.275 */276 void ConstructBspRays(vector<BspRay *> &bspRays,277 const VssRayContainer &rays);278 279 /** Merge view cells of leaves l1 and l2.280 */281 bool MergeViewCells(BspLeaf *l1, BspLeaf *l2); //const;282 263 283 264 /** Returns true if this view point is in a valid view space, … … 369 350 BspNode *CollapseTree(BspNode *node, int &collapsed); 370 351 371 /** Shuffles the leaves, i.e., tests if exchanging372 the leaves helps in improving the view cells.373 */374 bool ShuffleLeaves(BspLeaf *leaf1, BspLeaf *leaf2) const;375 376 352 /** Helper function revalidating the view cell leaf list after merge. 377 353 */ … … 573 549 574 550 575 /** Collects candidates for the merge in the merge queue. 576 @param leaves the leaves to be merged 577 @returns number of leaves in queue 578 */ 579 int CollectMergeCandidates(const vector<BspLeaf *> leaves); 580 /** Collects candidates for the merge in the merge queue. 581 @returns number of leaves in queue 582 */ 583 int CollectMergeCandidates(const VssRayContainer &rays); 584 551 552 553 554 585 555 /** Take 3 ray endpoints, where two are minimum and one a maximum 586 556 point or the other way round. … … 599 569 Plane3 ChooseCandidatePlane3(const RayInfoContainer &rays) const; 600 570 601 /** Shuffles, i.e. takes border leaf from view cell 1 and adds it 602 to view cell 2. 603 */ 604 void ShuffleLeaf(BspLeaf *leaf, 605 BspViewCell *vc1, 606 BspViewCell *vc2) const; 607 571 /** Collects candidates for merging. 572 @param leaves the leaves to be merged 573 @returns number of leaves in queue 574 */ 575 int CollectMergeCandidates(const vector<BspLeaf *> leaves, vector<MergeCandidate> &candidates); 576 577 /** Collects candidates for the merge in the merge queue. 578 @returns number of leaves in queue 579 */ 580 int CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 581 582 608 583 609 584 /** Propagates valid flag up the tree. … … 620 595 float GetMemUsage() const; 621 596 622 /** Calculates cost for merge of view cell 1 and 2. 623 */ 624 float GetShuffledVcCost(BspLeaf *leaf, BspViewCell *vc1, BspViewCell *vc2) const; 625 626 void ExportMergedViewCells(ViewCellContainer &viewCells, 627 const ObjectContainer &objects, 628 const int nViewCells); 597 629 598 630 599 /// Pointer to the root of the tree … … 658 627 float mTermMinAccRayLength; 659 628 660 ofstream mStats;629 661 630 662 631 //-- termination criteria for axis aligned split … … 701 670 /// maximal number of view cells 702 671 int mMaxViewCells; 703 /// minimal number of view cells 704 int mMergeMinViewCells; 705 /// maximal cost ratio for the merge 706 float mMergeMaxCostRatio; 672 707 673 708 674 // if rays should be stored in leaves … … 716 682 vector<SortableEntry> *mSplitCandidates; 717 683 718 719 typedef priority_queue<BspMergeCandidate> MergeQueue; 720 721 MergeQueue mMergeQueue; 722 723 /// if rays should be used to collect merge candidates 724 bool mUseRaysForMerge; 725 684 685 float mRenderCostWeight; 726 686 /// View cell corresponding to the space outside the valid view space 727 687 BspViewCell *mOutOfBoundsCell; 728 729 int mCurrentViewCellsId;730 688 731 689 /// maximal tree memory … … 733 691 /// the tree is out of memory 734 692 bool mOutOfMemory; 735 /// if merge visualization should be shown 736 bool mExportMergedViewCells; 737 /// if merge statistics should be exported 738 bool mExportMergeStats; 739 693 694 740 695 private: 741 742 ViewCellContainer mOldViewCells; 743 ViewCellContainer mNewViewCells; 696 744 697 745 698 static const float sLeastRaySplitsTable[5]; … … 758 711 }; 759 712 760 /** 761 Candidate for leaf merging based on priority. 762 */ 763 class BspMergeCandidate 764 { 765 friend class VspBspTree; 766 767 public: 768 769 BspMergeCandidate(BspLeaf *l1, BspLeaf *l2); 770 771 /** If this merge pair is still valid. 772 */ 773 bool Valid() const; 774 775 /** Sets this merge candidate to be valid. 776 */ 777 void SetValid(); 778 779 friend bool operator<(const BspMergeCandidate &leafa, const BspMergeCandidate &leafb) 780 { 781 return leafb.GetMergeCost() < leafa.GetMergeCost(); 782 } 783 784 void SetLeaf1(BspLeaf *l); 785 void SetLeaf2(BspLeaf *l); 786 787 BspLeaf *GetLeaf1() const; 788 BspLeaf *GetLeaf2() const; 789 790 /** Merge cost of this candidate pair. 791 */ 792 float GetMergeCost() const; 793 794 /** Render cost of this candidate. 795 */ 796 float GetRenderCost() const; 797 798 /** returns increase in variance of this view cell. 799 */ 800 float GetVarianceIncr() const; 801 802 /** Returns cost of leaf 1. 803 */ 804 float GetLeaf1Cost() const; 805 806 /** Returns cost of leaf 2. 807 */ 808 float GetLeaf2Cost() const; 809 810 /** Variance of leaf1 811 */ 812 float GetLeaf1Variance() const; 813 814 /** Variance of leaf2 815 */ 816 float GetLeaf2Variance() const; 817 818 /// overall cost used to normalize cost ratio 819 static float sOverallCost; 820 static float sExpectedCost; 821 static float sVariance; 822 823 static int sNumViewCells; 824 825 // weights between variance and render cost increase (must between zero and one) 826 static float sRenderCostWeight; 827 828 /// if area or volume should be used for the merge heuristics 829 static bool sUseArea; 830 831 /// pointer to view cells manager 832 static ViewCellsManager *sViewCellsManager; 833 834 protected: 835 836 837 /** Evaluates the merge costs of the leaves. 838 */ 839 void EvalMergeCost(); 840 841 /** render cost of a view cell. 842 */ 843 float GetRenderCost(ViewCell *vc) const; 844 845 int mLeaf1Id; 846 int mLeaf2Id; 847 848 /// render cost increase by this merge 849 float mRenderCost; 850 /// increase / decrease of variance 851 float mVarianceIncr; 852 853 BspLeaf *mLeaf1; 854 BspLeaf *mLeaf2; 855 }; 856 857 858 class MergeStatistics: public StatisticsBase 859 { 860 public: 861 862 int merged; 863 int siblings; 864 int candidates; 865 int nodes; 866 867 int accTreeDist; 868 int maxTreeDist; 869 870 Real collectTime; 871 Real mergeTime; 872 873 Real overallCost; 874 875 // Constructor 876 MergeStatistics() 877 { 878 Reset(); 879 } 880 881 double AvgTreeDist() const {return (double)accTreeDist / (double)merged;}; 882 883 void Reset() 884 { 885 nodes = 0; 886 merged = 0; 887 siblings = 0; 888 candidates = 0; 889 890 accTreeDist = 0; 891 maxTreeDist = 0; 892 893 collectTime = 0; 894 mergeTime = 0; 895 overallCost = 0; 896 } 897 898 void Print(ostream &app) const; 899 900 friend ostream &operator<<(ostream &s, const MergeStatistics &stat) 901 { 902 stat.Print(s); 903 return s; 904 } 905 }; 713 714 906 715 907 716 #endif
Note: See TracChangeset
for help on using the changeset viewer.