Ignore:
Timestamp:
02/08/06 20:32:42 (18 years ago)
Author:
bittner
Message:

slider support for viewcells

File:
1 edited

Legend:

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

    r607 r608  
    606606                        if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 
    607607                                ++ mergeStats.siblings; 
     608                        mergedVc->SetCost(realExpectedCost); 
    608609 
    609610                        if (((mergeStats.merged % statsOut) == 0) ||  
     
    664665                ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 
    665666                root->SetMergeCost(totalRenderCost); 
     667                // $$JB keep this 0 temporarilly 
     668                root->SetCost(0.0f); 
     669                 
    666670                mRoot = root; 
    667671        } 
     
    693697        Debug << mergeStats << endl << endl; 
    694698 
    695  
     699        // assign colors for the view cells so that at least one is always consistent 
     700        AssignRandomColors(); 
    696701        //TODO: should return sample contributions? 
    697702        return mergeStats.merged; 
     
    15331538 
    15341539 
     1540void 
     1541ViewCellsTree::AssignRandomColors() 
     1542{ 
     1543  TraversalQueue tqueue; 
     1544  tqueue.push(mRoot); 
     1545  mRoot->SetColor(RandomColor(0.3f, 1.0f)); 
     1546  while (!tqueue.empty()) 
     1547        { 
     1548          ViewCell *vc = tqueue.top(); 
     1549           
     1550          // save the view cells if it is a leaf or if enough view cells have already been traversed 
     1551          // because of the priority queue, this will be the optimal set of v 
     1552          if (!vc->IsLeaf()) {   
     1553                ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1554                 
     1555                ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1556                float maxProbability = -1.0f; 
     1557                ViewCell *maxViewCell = NULL; 
     1558                for (it = interior->mChildren.begin(); it != it_end; ++ it) { 
     1559                  ViewCell *v = *it; 
     1560                  // set random color 
     1561                  v->SetColor(RandomColor(0.3f, 1.0f)); 
     1562                  if (v->GetVolume() > maxProbability) { 
     1563                        maxProbability = v->GetVolume(); 
     1564                        maxViewCell = v; 
     1565                  } 
     1566                  maxViewCell->SetColor(vc->GetColor()); 
     1567                  tqueue.push(v); 
     1568                } 
     1569                 
     1570          } 
     1571           
     1572          tqueue.pop(); 
     1573        } 
     1574} 
     1575 
     1576/** Get costs resulting from each merge step. */ 
     1577void 
     1578ViewCellsTree::GetCostFunction(vector<float> &costFunction) 
     1579{ 
     1580  TraversalQueue tqueue; 
     1581  tqueue.push(mRoot); 
     1582  while (!tqueue.empty()) { 
     1583        ViewCell *vc = tqueue.top(); 
     1584         
     1585        // save the view cells if it is a leaf or if enough view cells have already been traversed 
     1586        // because of the priority queue, this will be the optimal set of v 
     1587        if (!vc->IsLeaf()) {     
     1588          ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1589          costFunction.push_back(interior->GetCost()); 
     1590           
     1591          ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1592           
     1593          for (it = interior->mChildren.begin(); it != it_end; ++ it) { 
     1594                tqueue.push(*it); 
     1595          } 
     1596           
     1597        } 
     1598         
     1599        tqueue.pop(); 
     1600  } 
     1601} 
     1602 
     1603 
    15351604void  ViewCellsTree::UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat) 
    15361605{ 
Note: See TracChangeset for help on using the changeset viewer.