Ignore:
Timestamp:
11/10/06 22:15:56 (18 years ago)
Author:
mattausch
Message:

exchanged pvs implementation: using vectors instead of maps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1738 r1740  
    6464        for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    6565        { 
    66                 if (!(*it).first->Mailed()) 
    67                 { 
    68                         (*it).first->Mail(); 
     66                if (!(*it).mObject->Mailed()) 
     67                { 
     68                        (*it).mObject->Mail(); 
    6969                        ++ count; 
    7070                } 
     
    8888        for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 
    8989        { 
    90                 (*it).first->Mail(); 
     90                (*it).mObject->Mail(); 
    9191        } 
    9292 
     
    9696        for (it = pvs2.mEntries.begin(); it != it_end; ++ it) 
    9797        { 
    98                 Intersectable *obj = (*it).first; 
     98                Intersectable *obj = (*it).mObject; 
    9999                if (!obj->Mailed()) 
    100100                        ++ pvs; 
     
    837837        for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 
    838838        { 
    839                 Intersectable *obj = (*it).first; 
     839                Intersectable *obj = (*it).mObject; 
    840840 
    841841                obj->Mail(); 
     
    848848        for (it = pvs2.mEntries.begin(); it != it_end; ++ it) 
    849849        { 
    850                 Intersectable *obj = (*it).first; 
     850                Intersectable *obj = (*it).mObject; 
    851851 
    852852                // test if object already considered     
     
    11521152inline int AddedPvsSize(ObjectPvs pvs1, const ObjectPvs &pvs2) 
    11531153{ 
    1154         return pvs1.AddPvs(pvs2); 
     1154        ObjectPvs interPvs; 
     1155        ObjectPvs::Merge(interPvs, pvs1, pvs2); 
     1156 
     1157        return (int)interPvs.GetSize(); 
    11551158} 
    11561159 
     
    12421245        // TODO change 
    12431246        vc1->GetPvs().SubtractPvs(leaf->GetPvs()); 
    1244         vc2->GetPvs().AddPvs(leaf->GetPvs()); 
    1245          
     1247         
     1248        ObjectPvs interPvs; 
     1249        ObjectPvs::Merge(interPvs, vc2->GetPvs(), leaf->GetPvs()); 
     1250        vc2->SetPvs(interPvs); 
     1251 
    12461252        if (mUseAreaForPvs) 
    12471253        { 
     
    16511657                for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    16521658                { 
    1653                         Intersectable *obj = (*oit).first; 
     1659                        Intersectable *obj = (*oit).mObject; 
    16541660                        if ((cit == interior->mChildren.begin()) && !obj->Mailed()) 
    16551661                                obj->Mail(); 
     
    16731679                for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    16741680                {                
    1675                         if ((*oit).first->Mailed((int)interior->mChildren.size())) 
     1681                        if ((*oit).mObject->Mailed((int)interior->mChildren.size())) 
    16761682                        {        
    1677                                 interior->GetPvs().AddSample((*oit).first, (*oit).second.mSumPdf); 
     1683                                interior->GetPvs().AddSample((*oit).mObject, (*oit).mData.mSumPdf); 
    16781684                        } 
    16791685                } 
     
    16881694                for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 
    16891695                { 
    1690                         if (!(*cit)->GetPvs().RemoveSample((*oit).first, Limits::Infinity)) 
     1696                        if (!(*cit)->GetPvs().RemoveSample((*oit).mObject, Limits::Infinity)) 
    16911697                        { 
    16921698                                Debug << "should not come here!" << endl; 
     
    17171723        { 
    17181724                root = root->GetParent(); 
    1719                 pvs.AddPvs(root->GetPvs()); 
     1725                pvs.MergeInPlace(root->GetPvs()); 
    17201726        } 
    17211727 
     
    17301736 
    17311737                // add newly found pvs to merged pvs 
    1732                 pvs.AddPvs(vc->GetPvs()); 
     1738                ObjectPvs interPvs; 
     1739                pvs.MergeInPlace(vc->GetPvs()); 
    17331740 
    17341741                if (!vc->IsLeaf()) // interior cells: go down to leaf level 
     
    17791786                for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    17801787                { 
    1781                         Intersectable *intersect = (*oit).first; 
     1788                        Intersectable *intersect = (*oit).mObject; 
    17821789 
    17831790                        if (!intersect->Mailed()) 
    17841791                        { 
    17851792                                intersect->Mail(); 
    1786                                 newPvs.AddSample(intersect, (*oit).second.mSumPdf); 
     1793                                newPvs.AddSample(intersect, (*oit).mData.mSumPdf); 
    17871794                        } 
    17881795                } 
     
    18291836                for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
    18301837                { 
    1831                         Intersectable *intersect = (*oit).first; 
     1838                        Intersectable *intersect = (*oit).mObject; 
    18321839 
    18331840                        if (!intersect->Mailed()) 
     
    20502057 
    20512058 
    2052 void ViewCellsTree::PropagatePvs(ViewCell *vc) 
     2059void ViewCellsTree::PropagatePvs(ViewCell *root) 
    20532060{        
    2054         ViewCell *viewCell = vc; 
     2061        ViewCell *viewCell = root; 
    20552062 
    20562063        // propagate pvs up 
    20572064        while (viewCell->GetParent()) 
    20582065        { 
    2059                 viewCell->GetParent()->GetPvs().Merge(vc->GetPvs()); 
     2066                ObjectPvs mergedPvs; 
     2067                viewCell->GetParent()->GetPvs().MergeInPlace(root->GetPvs()); 
     2068 
    20602069                viewCell = viewCell->GetParent(); 
    20612070        } 
    20622071 
    2063         if (vc->IsLeaf()) 
     2072        if (root->IsLeaf()) 
    20642073                return; 
    20652074 
    20662075        // propagate pvs to the leaves 
    20672076        stack<ViewCell *> tstack; 
    2068         tstack.push(vc); 
     2077        tstack.push(root); 
    20692078 
    20702079        while (!tstack.empty()) 
     
    20732082                tstack.pop(); 
    20742083 
    2075                 if (viewCell != vc) 
    2076                 { 
    2077                         viewCell->GetPvs().Merge(vc->GetPvs()); 
     2084                if (viewCell != root) 
     2085                { 
     2086                        viewCell->GetPvs().MergeInPlace(root->GetPvs()); 
    20782087                } 
    20792088 
     
    21052114                tqueue.pop(); 
    21062115 
    2107                 // save the view cells if it is a leaf or if enough view cells have already been traversed 
    2108                 // because of the priority queue, this will be the optimal set of v 
     2116                // save the view cells if it is a leaf or if enough view cells  
     2117                // have already been traversed because of the priority queue,  
     2118                // this will be the optimal set of v 
    21092119                if (!vc->IsLeaf())  
    21102120                {        
     
    23432353        for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    23442354        { 
    2345                 Intersectable *obj = (*it).first; 
     2355                Intersectable *obj = (*it).mObject; 
    23462356                // hack: just output full pvs 
    23472357                if (obj->Type() == Intersectable::BVH_INTERSECTABLE) 
     
    23592369                else 
    23602370                { 
    2361                         stream << (*it).first->GetId() << " "; 
     2371                        stream << (*it).mObject->GetId() << " "; 
    23622372                } 
    23632373        } 
Note: See TracChangeset for help on using the changeset viewer.