- Timestamp:
- 05/03/06 09:40:01 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r880 r881 143 143 mParent(NULL), 144 144 mMergeCost(0), 145 mIsActive(false),146 145 mPvsSize(0), 147 146 mPvsSizeValid(false) … … 157 156 mParent(NULL), 158 157 mMergeCost(0), 159 mIsActive(false),160 mLastUpdated(sLastUpdated),161 158 mPvsSize(0), 162 159 mPvsSizeValid(false) … … 278 275 return mMergeCost; 279 276 } 280 281 282 void ViewCell::SetActive()283 {284 mIsActive = true;285 mLastUpdated = sLastUpdated;286 }287 288 289 bool ViewCell::IsActive() const290 {291 return mIsActive && (mLastUpdated == sLastUpdated);292 }293 294 277 295 278 /************************************************************************/ … … 342 325 mChildren.erase(it); 343 326 } 344 345 327 346 328 … … 539 521 //static float expectedValue = pvsStats.avgPvs; 540 522 541 // the current view cells are kept in this container542 // we start with the current view cells from the view cell manager.543 // The active view cells will change with subsequent merges523 //-- 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 544 526 545 527 // todo: should rather take initial view cells … … 582 564 //-- use priority queue to merge leaf pairs 583 565 584 //const float maxAvgCost = 350; 585 while (!mMergeQueue.empty())//nmNumActiveViewCells > mMergeMinViewCells)) 566 while (!mMergeQueue.empty()) 586 567 { 587 568 //-- reset merge queue if the ratio of current expected cost / real expected cost … … 1815 1796 1816 1797 1817 ViewCell *ViewCellsTree::GetActiveViewCell(ViewCell *vc) const 1818 { 1819 while (vc->GetParent() && !vc->IsActive()) 1820 { 1821 vc = vc->GetParent(); 1822 } 1823 1824 return vc; 1798 ViewCell *ViewCellsTree::GetActiveViewCell(ViewCellLeaf *vc) const 1799 { 1800 return vc->GetActiveViewCell(); 1825 1801 } 1826 1802 … … 2020 1996 stream << "<Leaf "; 2021 1997 stream << "id=\"" << viewCell->GetId() << "\" "; 2022 stream << "active=\"" << viewCell->IsActive() << "\" ";1998 stream << "active=\"" << dynamic_cast<ViewCellLeaf *>(viewCell)->GetActiveViewCell()->GetId() << "\" "; 2023 1999 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 2024 2000 stream << "pvs=\""; … … 2037 2013 stream << "<Interior "; 2038 2014 stream << "id=\"" << viewCell->GetId() << "\" "; 2039 stream << "active=\"" << viewCell->IsActive() << "\" ";2040 2015 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 2041 2016 stream << "pvs=\""; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r880 r881 22 22 class MergeCandidate; 23 23 class ViewCellsManager; 24 class ViewCellLeaf; 24 25 25 26 /** Statistics for a view cell partition. … … 217 218 218 219 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 226 220 227 221 // last mail id -> warning not thread safe! … … 230 224 static int sReservedMailboxes; 231 225 232 static int sLastUpdated;233 226 234 227 protected: … … 244 237 bool mValid; 245 238 246 int mLastUpdated; 247 bool mIsActive; 248 /** color used for consistent visualization */ 239 /// color used for consistent visualization 249 240 RgbColor mColor; 250 241 … … 252 243 /// pvs size, used for lazy pvs computation 253 244 int mPvsSize; 245 /// if the given pvs size is the real pvs size 254 246 bool mPvsSizeValid; 255 247 … … 287 279 }; 288 280 281 289 282 /** 290 View cell belonging to a hierarchy.283 Leaf of the view cell. 291 284 */ 292 template<typename T>293 285 class ViewCellLeaf: public ViewCell 294 286 { 295 287 public: 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; } 301 291 302 292 bool IsLeaf() const … … 304 294 return true; 305 295 } 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 */ 315 template<typename T> 316 class HierarchyLeafViewCell: public ViewCellLeaf 317 { 318 public: 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 306 330 307 331 /// Leaf of some hierarchy which is part of this view cell. … … 310 334 311 335 312 typedef ViewCellLeaf<BspLeaf *> BspViewCell;313 typedef ViewCellLeaf<KdLeaf *> KdViewCell;314 typedef ViewCellLeaf<VspKdLeaf *> VspKdViewCell;336 typedef HierarchyLeafViewCell<BspLeaf *> BspViewCell; 337 typedef HierarchyLeafViewCell<KdLeaf *> KdViewCell; 338 typedef HierarchyLeafViewCell<VspKdLeaf *> VspKdViewCell; 315 339 316 340 … … 399 423 /** Returns active view cell that is in the path of this view cell. 400 424 */ 401 ViewCell *GetActiveViewCell(ViewCell *vc) const;425 ViewCell *GetActiveViewCell(ViewCellLeaf *vc) const; 402 426 403 427 /** Sets the leaves to be the currently active view cells. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h
r860 r881 23 23 class ViewCellsManager; 24 24 class ViewCellsTree; 25 class ViewCellLeaf; 25 26 26 27 class BspNodeGeometry -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r880 r881 1873 1873 { 1874 1874 ++ ViewCell::sLastUpdated; 1875 1875 1876 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1876 1877 for (it = mViewCells.begin(); it != it_end; ++ it) 1877 1878 { 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 } 1879 1887 } 1880 1888 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r880 r881 324 324 viewCell->SetId(id); 325 325 } 326 else if (attrName == "active")326 /*else if (attrName == "active") 327 327 { 328 328 StrX attrValue(attributes.getValue(i)); … … 334 334 if (isActive) 335 335 viewCell->SetActive(); 336 } 336 }*/ 337 337 else if (attrName == "mergecost") 338 338 {
Note: See TracChangeset
for help on using the changeset viewer.