Changeset 485 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
- Timestamp:
- 12/30/05 12:08:15 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r483 r485 21 21 class ViewCellsStatistics; 22 22 class ViewCellsManager; 23 class BspMergeCandidate; 24 struct BspRay; 23 25 24 26 … … 222 224 BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 223 225 224 /** Returns view cell corresponding to unbounded space.225 */226 BspViewCell *GetRootCell() const;227 228 226 /** Returns epsilon of this tree. 229 227 */ 230 228 float GetEpsilon() const; 231 229 232 230 /** Casts line segment into the tree. 231 @param origin the origin of the line segment 232 @param termination the end point of the line segment 233 @returns view cells intersecting the line segment. 234 */ 233 235 int CastLineSegment(const Vector3 &origin, 234 236 const Vector3 &termination, 235 237 ViewCellContainer &viewcells); 236 238 237 /** Merges leaves with similar PVS.238 */239 int MergeLeaves();240 239 241 240 /** Sets pointer to view cells manager. … … 243 242 void SetViewCellsManager(ViewCellsManager *vcm); 244 243 245 /** Helper function revalidating the view cell leaf list after merge. 246 */ 247 void RepairVcLeafLists(); 248 249 /** Collapses the tree with respect to the view cell partition. 250 @returns node of type leaf if the node could be collapsed, this node otherwise 244 /** Returns distance from node 1 to node 2. 245 */ 246 int TreeDistance(BspNode *n1, BspNode *n2) const; 247 248 /** Merges view cells according to some cost heuristics. 249 */ 250 int MergeViewCells(const VssRayContainer &rays); 251 252 /** Refines view cells using shuffling, i.e., border leaves 253 of two view cells are exchanged if the resulting view cells 254 are tested to be "better" than the old ones. 255 @returns number of refined view cells 256 */ 257 int RefineViewCells(const VssRayContainer &rays); 258 259 /** Collapses the tree with respect to the view cell partition, 260 i.e. leaves having the same view cell are collapsed. 261 @returns node of type leaf if the node could be collapsed, 262 this node otherwise 251 263 */ 252 264 BspNode *CollapseTree(BspNode *node); 253 254 255 /** Returns distance from node 1 to node 2. 256 */ 257 int TreeDistance(BspNode *n1, BspNode *n2); 265 266 /** Constructs bsp rays for post processing and visualization. 267 */ 268 void ConstructBspRays(vector<BspRay *> &bspRays, 269 const VssRayContainer &rays); 270 271 272 /** Merge view cells of leaves l1 and l2. 273 */ 274 bool MergeViewCells(BspLeaf *l1, BspLeaf *l2) const; 258 275 259 276 protected: … … 286 303 }; 287 304 305 /** Shuffles the leaves, i.e., tests if exchanging 306 the leaves helps in improving the view cells. 307 */ 308 bool ShuffleLeaves(BspLeaf *leaf1, BspLeaf *leaf2) const; 309 310 /** Helper function revalidating the view cell leaf list after merge. 311 */ 312 void RepairVcLeafLists(); 313 288 314 /** Evaluates tree stats in the BSP tree leafs. 289 315 */ … … 478 504 479 505 506 /** Collects candidates for the merge in the merge queue. 507 @returns number of leaves in queue 508 */ 509 int CollectMergeCandidates(); 510 /** Collects candidates for the merge in the merge queue. 511 @returns number of leaves in queue 512 */ 513 int CollectMergeCandidates(const VssRayContainer &rays); 514 480 515 /** Take 3 ray endpoints, where two are minimum and one a maximum 481 516 point or the other way round. … … 484 519 485 520 /** Take plane normal as plane normal and the midpoint of the ray. 486 PROBLEM: does not resemble any point where visibility is likely to change 521 PROBLEM: does not resemble any point where visibility is 522 likely to change 487 523 */ 488 524 Plane3 ChooseCandidatePlane2(const RayInfoContainer &rays) const; 489 525 490 /** Fit the plane between the two lines so that the plane has equal shortest491 distance to both lines.526 /** Fit the plane between the two lines so that the plane 527 has equal shortest distance to both lines. 492 528 */ 493 529 Plane3 ChooseCandidatePlane3(const RayInfoContainer &rays) const; 494 530 495 /** Merge view cells of leaves l1 and l2.496 */497 bool MergeViewCells(BspLeaf *l1, BspLeaf *l2);531 void ShuffleLeaf(BspLeaf *leaf, 532 BspViewCell *vc1, 533 BspViewCell *vc2) const; 498 534 499 535 /// Pointer to the root of the tree … … 513 549 /// box around the whole view domain 514 550 AxisAlignedBox3 mBox; 515 516 /// view cell corresponding to unbounded space517 BspViewCell *mRootCell;518 551 519 552 /// minimal number of rays before subdivision termination … … 574 607 float mMergeMaxCostRatio; 575 608 576 ViewCellsManager *mViewCellsManager;577 578 609 // if rays should be stored in leaves 579 610 bool mStoreRays; 611 612 /// if only driving axis should be used for split 613 bool mOnlyDrivingAxis; 614 615 ViewCellsManager *mViewCellsManager; 580 616 581 617 vector<SortableEntry> *mSplitCandidates; 582 618 583 bool mOnlyDrivingAxis; 584 619 typedef priority_queue<BspMergeCandidate> MergeQueue; 620 MergeQueue mMergeQueue; 621 622 bool mUseRaysForMerge; 585 623 586 624 private: … … 646 684 647 685 protected: 648 686 687 /** Cost of a view cell. 688 */ 689 float GetCost(ViewCell *vc) const; 649 690 /** Evaluates the merge costs of the leaves. 650 691 */ … … 661 702 662 703 704 class MergeStatistics: public StatisticsBase 705 { 706 public: 707 708 int merged; 709 int siblings; 710 int candidates; 711 int nodes; 712 713 int accTreeDist; 714 int maxTreeDist; 715 716 Real collectTime; 717 Real mergeTime; 718 719 // Constructor 720 MergeStatistics() 721 { 722 Reset(); 723 } 724 725 double AvgTreeDist() const {return (double)accTreeDist / (double)merged;}; 726 727 void Reset() 728 { 729 nodes = 0; 730 merged = 0; 731 siblings = 0; 732 candidates = 0; 733 734 accTreeDist = 0; 735 maxTreeDist = 0; 736 737 collectTime = 0; 738 mergeTime = 0; 739 } 740 741 void Print(ostream &app) const; 742 743 friend ostream &operator<<(ostream &s, const MergeStatistics &stat) 744 { 745 stat.Print(s); 746 return s; 747 } 748 }; 749 663 750 #endif
Note: See TracChangeset
for help on using the changeset viewer.