Changeset 342


Ignore:
Timestamp:
10/19/05 00:13:27 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r341 r342  
    15791579        } 
    15801580} 
    1581 /* 
     1581 
    15821582int BspTree::MergeViewCells() 
    15831583{ 
    1584         int prunedCells = 0; 
    1585  
    15861584        stack<BspNode *> nodeStack; 
    15871585        stack<BspLeaf *> leafStack; 
    15881586 
    15891587        nodeStack.push(mRoot); 
    1590  
    1591         ViewCell::NewMail(); 
    1592  
     1588         
    15931589        // collect leaves 
    15941590        while (!nodeStack.empty())  
     
    16001596                if (node->IsLeaf()) 
    16011597                { 
    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                        } 
    16051611                } 
    16061612                else 
    16071613                { 
    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        } 
    16181619 
    16191620        return 0; 
     1621} 
     1622 
     1623bool BspTree::MergeNecessary(BspLeaf *front, BspLeaf *back) const 
     1624{ 
     1625        return true; 
     1626} 
     1627 
     1628BspNode *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; 
    16201694}*/ 
    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 
    16571696void BspTree::SetGenerateViewCells(int generateViewCells) 
    16581697{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r341 r342  
    354354                @returns the number of merged view cells 
    355355        */ 
    356         //int MergeViewCells(); 
     356        int MergeViewCells(); 
    357357 
    358358        /** Set to true if new view cells shall be generated in each leaf. 
     
    368368 
    369369protected: 
    370          
     370 
    371371        // -------------------------------------------------------------- 
    372372        // For sorting objects 
     
    389389        }; 
    390390 
     391        BspNode *MergeNodes(BspInterior *node); 
     392 
     393        bool MergeNecessary(BspLeaf *front, BspLeaf *back) const; 
    391394 
    392395        /** Evaluates tree stats in the BSP tree leafs. 
Note: See TracChangeset for help on using the changeset viewer.