Ignore:
Timestamp:
03/22/06 14:15:07 (18 years ago)
Author:
bittner
Message:

visibility filter used in glrenderer

File:
1 edited

Legend:

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

    r712 r713  
    615615                neighborhood.pop_back(); 
    616616         
    617                 //cout << "vc idx: " << bestViewCellIdx << endl; 
     617                //              cout << "vc idx: " << bestViewCellIdx << endl; 
    618618                if (!bestViewCell || !root) 
    619619                        cout << "warning!!" << endl; 
     
    627627 
    628628 
     629struct SortableViewCellEntry { 
     630 
     631  SortableViewCellEntry() {} 
     632  SortableViewCellEntry(const float v, ViewCell *cell):mValue(v), mViewCell(cell) {} 
     633   
     634  float mValue; 
     635  ViewCell *mViewCell; 
     636 
     637  friend bool operator<(const SortableViewCellEntry &a, const SortableViewCellEntry &b) { 
     638        return a.mValue < b.mValue; 
     639  } 
     640}; 
     641 
     642ViewCell * 
     643ViewCellsManager::ConstructLocalMergeTree2(ViewCell *currentViewCell,  
     644                                                                                   const ViewCellContainer &viewCells) 
     645{ 
     646   
     647  vector<SortableViewCellEntry> neighborhood(viewCells.size()); 
     648  int i, j; 
     649  for (i = 0, j = 0; i < viewCells.size(); i++) { 
     650        if (viewCells[i] != currentViewCell)  
     651          neighborhood[j++] = SortableViewCellEntry( 
     652                                                                                                EvalMergeCost(currentViewCell, viewCells[i]), 
     653                                                                                                viewCells[i]); 
     654  } 
     655  neighborhood.resize(j); 
     656   
     657  sort(neighborhood.begin(), neighborhood.end()); 
     658   
     659  ViewCell *root = currentViewCell; 
     660   
     661  vector<SortableViewCellEntry>::const_iterator it, it_end = neighborhood.end(); 
     662   
     663  const int n = min(mMaxFilterSize, (int)neighborhood.size()); 
     664  //-- use priority queue to merge leaf pairs 
     665   
     666  //cout << "neighborhood: " << neighborhood.size() << endl; 
     667  for (int nMergedViewCells = 0; nMergedViewCells < n; ++ nMergedViewCells) 
     668        { 
     669          ViewCell *bestViewCell = neighborhood[nMergedViewCells].mViewCell; 
     670          //cout <<nMergedViewCells<<":"<<"homogenity=" <<neighborhood[nMergedViewCells].mValue<<endl; 
     671          // create new root of the hierarchy 
     672          root = MergeViewCells(root, bestViewCell); 
     673          // set negative cost so that this view cell gets deleted 
     674          root->SetMergeCost(-1.0f); 
     675        } 
     676   
     677  return root;   
     678} 
     679 
     680void 
     681ViewCellsManager::DeleteLocalMergeTree(ViewCell *vc 
     682                                                                           ) const 
     683{ 
     684  if (!vc->IsLeaf() && vc->GetMergeCost() < 0.0f) { 
     685        ViewCellInterior *vci = (ViewCellInterior *) vc; 
     686        ViewCellContainer::const_iterator it, it_end = vci->mChildren.end(); 
     687         
     688        for (it = vci->mChildren.begin(); it != it_end; ++ it) 
     689          DeleteLocalMergeTree(*it); 
     690        vci->mChildren.clear(); 
     691        delete vci; 
     692  } 
     693} 
     694 
    629695bool ViewCellsManager::CheckValidity(ViewCell *vc, 
    630696                                                                         int minPvsSize, 
     
    672738        ComputeBoxIntersections(box, viewCells); 
    673739 
    674         ViewCell *root = ConstructLocalMergeTree(currentViewCell, viewCells); 
     740        ViewCell *root = ConstructLocalMergeTree2(currentViewCell, viewCells); 
    675741 
    676742        prvs.mViewCell = root; 
Note: See TracChangeset for help on using the changeset viewer.