Changeset 342 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 10/19/05 00:13:27 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r341 r342 1579 1579 } 1580 1580 } 1581 /* 1581 1582 1582 int BspTree::MergeViewCells() 1583 1583 { 1584 int prunedCells = 0;1585 1586 1584 stack<BspNode *> nodeStack; 1587 1585 stack<BspLeaf *> leafStack; 1588 1586 1589 1587 nodeStack.push(mRoot); 1590 1591 ViewCell::NewMail(); 1592 1588 1593 1589 // collect leaves 1594 1590 while (!nodeStack.empty()) … … 1600 1596 if (node->IsLeaf()) 1601 1597 { 1602 //if (!leafStack.empty() && leafStack.top()->mParent() == node->mParent) 1603 leafStack.push(dynamic_cast<BspLeaf *>(node)); 1604 1598 BspNode *leaf = dynamic_cast<BspLeaf *>(node); 1599 1600 // get other leaf we can merge with 1601 while (!leafStack.empty() && leafStack.top()->mParent == node->mParent) 1602 { 1603 leafStack.pop(); 1604 BspNode *mergedNode = MergeNodes(node->mParent); 1605 1606 if (mergedNode->IsLeaf()) 1607 leafStack.push(dynamic_cast<BspLeaf *>(mergedNode)); 1608 else 1609 leafStack.push(dynamic_cast<BspLeaf *>(node)); 1610 } 1605 1611 } 1606 1612 else 1607 1613 { 1608 nodeStack.push_back(node->mFront); 1609 nodeStack.push_back(node->mFront); 1610 } 1611 1612 while (!leafStack.empty()) 1613 { 1614 BspLeaf *leaf = leafStack.top(); 1615 leafStack.pop(); 1616 } 1617 1614 BspInterior *interior = dynamic_cast<BspInterior *>(node); 1615 nodeStack.push(interior->mFront); 1616 nodeStack.push(interior->mBack); 1617 } 1618 } 1618 1619 1619 1620 return 0; 1621 } 1622 1623 bool BspTree::MergeNecessary(BspLeaf *front, BspLeaf *back) const 1624 { 1625 return true; 1626 } 1627 1628 BspNode *BspTree::MergeNodes(BspInterior *node) 1629 { 1630 BspLeaf *front = dynamic_cast<BspLeaf *>(node->mFront); 1631 BspLeaf *back = dynamic_cast<BspLeaf *>(node->mBack); 1632 1633 if (!MergeNecessary(front, back)) 1634 return node; 1635 1636 DEL_PTR(front->mViewCell); 1637 DEL_PTR(front); 1638 1639 DEL_PTR(back->mViewCell); 1640 DEL_PTR(back); 1641 1642 BspLeaf *leaf = new BspLeaf(new ViewCell()); 1643 BspInterior *parent = node->GetParent(); 1644 1645 // replace a link from node's parent 1646 if (!node->IsRoot()) 1647 { 1648 parent->ReplaceChildLink(node, leaf); 1649 node->SetParent(parent); 1650 } 1651 else // new root 1652 { 1653 mRoot = leaf; 1654 } 1655 1656 return leaf; 1657 } 1658 1659 /*BspNode *BspTree::MergeNodes(BspNode *node) 1660 { 1661 BspNode *front = MergeNodes(dynamic_cast<BspInterior *>(node)->mFront); 1662 BspNode *back = MergeNodes(dynamic_cast<BspInterior *>(node)->mBack); 1663 1664 if (!front->IsLeaf() && !back->IsLeaf()) 1665 1666 { 1667 if (!MergeNecessary(front, back)) 1668 return node; 1669 1670 DEL_PTR(front->mViewCell); 1671 DEL_PTR(front); 1672 1673 DEL_PTR(back->mViewCell); 1674 DEL_PTR(back); 1675 1676 BspLeaf *leaf = new BspLeaf(new ViewCell()); 1677 BspInterior *parent = node->GetParent(); 1678 1679 // replace a link from node's parent 1680 if (!node->IsRoot()) 1681 { 1682 parent->ReplaceChildLink(node, leaf); 1683 node->SetParent(parent); 1684 } 1685 else // new root 1686 { 1687 mRoot = leaf; 1688 } 1689 1690 return leaf; 1691 } 1692 1693 return node; 1620 1694 }*/ 1621 /* 1622 BspLeaf *BspTree::MergeNodes(BspInterior *interior) 1623 { 1624 BspNode *frontLeaf = MergeNodes(interior->mFront); 1625 BspNode *backLeaf = MergeNodes(interior->mBack); 1626 1627 if (frontLeaf->IsLeaf() && backLeaf->IsLeaf()) 1628 { 1629 if (!MergeNecessary(frontLeaf, backLeaf)) 1630 return interior; 1631 1632 DEL_PTR(frontLeaf->mViewCell); 1633 DEL_PTR(interior->mFront); 1634 1635 DEL_PTR(backLeaf->mViewCell); 1636 DEL_PTR(interior->mBack); 1637 1638 BspLeaf *leaf = new BspLeaf(viewCell); 1639 1640 // replace a link from node's parent 1641 if (!interior->IsRoot()) 1642 { 1643 parent->ReplaceChildLink(interior, leaf); 1644 interior->SetParent(parent); 1645 } 1646 else // new root 1647 { 1648 mRoot = leaf; 1649 } 1650 1651 return leaf; 1652 } 1653 1654 return interior; 1655 } 1656 */ 1695 1657 1696 void BspTree::SetGenerateViewCells(int generateViewCells) 1658 1697 { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r341 r342 354 354 @returns the number of merged view cells 355 355 */ 356 //int MergeViewCells();356 int MergeViewCells(); 357 357 358 358 /** Set to true if new view cells shall be generated in each leaf. … … 368 368 369 369 protected: 370 370 371 371 // -------------------------------------------------------------- 372 372 // For sorting objects … … 389 389 }; 390 390 391 BspNode *MergeNodes(BspInterior *node); 392 393 bool MergeNecessary(BspLeaf *front, BspLeaf *back) const; 391 394 392 395 /** Evaluates tree stats in the BSP tree leafs.
Note: See TracChangeset
for help on using the changeset viewer.