Changeset 881 for GTP/trunk


Ignore:
Timestamp:
05/03/06 09:40:01 (19 years ago)
Author:
mattausch
Message:

changing concept of active view cells

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

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

    r880 r881  
    143143mParent(NULL), 
    144144mMergeCost(0), 
    145 mIsActive(false), 
    146145mPvsSize(0), 
    147146mPvsSizeValid(false) 
     
    157156mParent(NULL), 
    158157mMergeCost(0), 
    159 mIsActive(false), 
    160 mLastUpdated(sLastUpdated), 
    161158mPvsSize(0), 
    162159mPvsSizeValid(false) 
     
    278275        return mMergeCost; 
    279276} 
    280  
    281  
    282 void ViewCell::SetActive() 
    283 { 
    284         mIsActive = true; 
    285         mLastUpdated = sLastUpdated; 
    286 } 
    287  
    288  
    289 bool ViewCell::IsActive() const 
    290 { 
    291         return mIsActive  && (mLastUpdated == sLastUpdated); 
    292 } 
    293  
    294277 
    295278/************************************************************************/ 
     
    342325                mChildren.erase(it); 
    343326} 
    344  
    345327 
    346328 
     
    539521        //static float expectedValue = pvsStats.avgPvs; 
    540522         
    541         // the current view cells are kept in this container 
    542         // we start with the current view cells from the view cell manager.  
    543         // The active view cells will change with subsequent merges 
     523        //-- the current view cells are kept in this container 
     524        //-- we start with the current view cells from the view cell manager.  
     525        //-- The active view cells will change with subsequent merges 
    544526         
    545527        // todo: should rather take initial view cells 
     
    582564        //-- use priority queue to merge leaf pairs 
    583565 
    584         //const float maxAvgCost = 350; 
    585         while (!mMergeQueue.empty())//nmNumActiveViewCells > mMergeMinViewCells)) 
     566        while (!mMergeQueue.empty()) 
    586567        { 
    587568                //-- reset merge queue if the ratio of current expected cost / real expected cost 
     
    18151796 
    18161797 
    1817 ViewCell *ViewCellsTree::GetActiveViewCell(ViewCell *vc) const 
    1818 { 
    1819         while (vc->GetParent() && !vc->IsActive()) 
    1820         { 
    1821                 vc = vc->GetParent(); 
    1822         } 
    1823  
    1824         return vc; 
     1798ViewCell *ViewCellsTree::GetActiveViewCell(ViewCellLeaf *vc) const 
     1799{ 
     1800        return vc->GetActiveViewCell(); 
    18251801} 
    18261802 
     
    20201996                stream << "<Leaf "; 
    20211997                stream << "id=\"" << viewCell->GetId() << "\" "; 
    2022                 stream << "active=\"" << viewCell->IsActive() << "\" "; 
     1998                stream << "active=\"" << dynamic_cast<ViewCellLeaf *>(viewCell)->GetActiveViewCell()->GetId() << "\" "; 
    20231999                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
    20242000                stream << "pvs=\""; 
     
    20372013                stream << "<Interior "; 
    20382014                stream << "id=\"" << viewCell->GetId() << "\" "; 
    2039                 stream << "active=\"" << viewCell->IsActive() << "\" "; 
    20402015                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
    20412016                stream << "pvs=\""; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r880 r881  
    2222class MergeCandidate; 
    2323class ViewCellsManager; 
     24class ViewCellLeaf; 
    2425 
    2526/** Statistics for a view cell partition. 
     
    217218 
    218219 
    219         /** Sets this view cell to be an active view cell. 
    220         */ 
    221         void SetActive(); 
    222         /** Returns if this view cell is active. 
    223         */ 
    224         bool IsActive() const; 
    225  
    226220 
    227221        // last mail id -> warning not thread safe! 
     
    230224        static int sReservedMailboxes; 
    231225 
    232         static int sLastUpdated; 
    233226         
    234227protected: 
     
    244237        bool mValid; 
    245238 
    246         int mLastUpdated; 
    247         bool mIsActive; 
    248         /** color used for consistent visualization */ 
     239        /// color used for consistent visualization 
    249240        RgbColor mColor; 
    250241 
     
    252243        /// pvs size, used for lazy pvs computation 
    253244        int mPvsSize; 
     245        /// if the given pvs size is the real pvs size 
    254246        bool mPvsSizeValid; 
    255247 
     
    287279}; 
    288280 
     281 
    289282/** 
    290         View cell belonging to a hierarchy. 
     283        Leaf of the view cell. 
    291284*/ 
    292 template<typename T> 
    293285class ViewCellLeaf: public ViewCell 
    294286{ 
    295287public: 
    296  
    297         ViewCellLeaf<T>(): mLeaf(NULL) { SetActive(); } 
    298         ViewCellLeaf<T>(Mesh *mesh): 
    299         ViewCell(mesh), mLeaf(NULL) { SetActive(); } 
    300          
     288        ViewCellLeaf()  {  mActiveViewCell = this; } 
     289        ViewCellLeaf(Mesh *mesh): 
     290        ViewCell(mesh) { mActiveViewCell = this; } 
    301291 
    302292        bool IsLeaf() const 
     
    304294                return true; 
    305295        } 
     296 
     297        /** Returns if this view cell is active. 
     298        */ 
     299        ViewCell *GetActiveViewCell() const  
     300        { return mActiveViewCell; } 
     301 
     302        /** Sets this view cell to be an active view cell. 
     303        */ 
     304        void SetActiveViewCell(ViewCell *vc) 
     305        { mActiveViewCell = vc;} 
     306 
     307         
     308        /// points to the currently active view cell. 
     309        ViewCell *mActiveViewCell; 
     310}; 
     311 
     312/** 
     313        Leaf of the view cell hierarchy corresponding to a leaf in a spatial hierarchy. 
     314*/ 
     315template<typename T> 
     316class HierarchyLeafViewCell: public ViewCellLeaf 
     317{ 
     318public: 
     319 
     320        HierarchyLeafViewCell<T>(): ViewCellLeaf() {  } 
     321        HierarchyLeafViewCell<T>(Mesh *mesh): 
     322        ViewCellLeaf(mesh) {  } 
     323                 
     324 
     325        bool IsLeaf() const 
     326        { 
     327                return true; 
     328        } 
     329 
    306330 
    307331        /// Leaf of some hierarchy which is part of this view cell. 
     
    310334 
    311335 
    312 typedef ViewCellLeaf<BspLeaf *> BspViewCell; 
    313 typedef ViewCellLeaf<KdLeaf *> KdViewCell; 
    314 typedef ViewCellLeaf<VspKdLeaf *> VspKdViewCell; 
     336typedef HierarchyLeafViewCell<BspLeaf *> BspViewCell; 
     337typedef HierarchyLeafViewCell<KdLeaf *> KdViewCell; 
     338typedef HierarchyLeafViewCell<VspKdLeaf *> VspKdViewCell; 
    315339 
    316340 
     
    399423        /** Returns active view cell that is in the path of this view cell. 
    400424        */ 
    401         ViewCell *GetActiveViewCell(ViewCell *vc) const; 
     425        ViewCell *GetActiveViewCell(ViewCellLeaf *vc) const; 
    402426 
    403427        /** Sets the leaves to be the currently active view cells. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r860 r881  
    2323class ViewCellsManager; 
    2424class ViewCellsTree; 
     25class ViewCellLeaf; 
    2526 
    2627class BspNodeGeometry 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r880 r881  
    18731873{ 
    18741874        ++ ViewCell::sLastUpdated; 
     1875 
    18751876        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    18761877        for (it = mViewCells.begin(); it != it_end; ++ it) 
    18771878        { 
    1878                 (*it)->SetActive(); 
     1879                ViewCellContainer leaves; 
     1880                mViewCellsTree->CollectLeaves(*it, leaves); 
     1881 
     1882                ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
     1883                for (lit = mViewCells.begin(); lit != lit_end; ++ lit) 
     1884                { 
     1885                        dynamic_cast<ViewCellLeaf *>(*lit)->SetActiveViewCell(*it); 
     1886                } 
    18791887        } 
    18801888} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r880 r881  
    324324                        viewCell->SetId(id); 
    325325                } 
    326                 else if (attrName == "active") 
     326                /*else if (attrName == "active") 
    327327                { 
    328328                        StrX attrValue(attributes.getValue(i)); 
     
    334334                        if (isActive) 
    335335                                viewCell->SetActive(); 
    336                 } 
     336                }*/ 
    337337                else if (attrName == "mergecost") 
    338338                { 
Note: See TracChangeset for help on using the changeset viewer.