Changeset 713


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

visibility filter used in glrenderer

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

Legend:

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

    r685 r713  
    301301 
    302302float 
    303 GlRendererBuffer::GetPixelError() 
     303GlRendererBuffer::GetPixelError(int &pvsSize) 
    304304{ 
    305305  float pErrorPixels = -1.0f; 
    306  
     306   
    307307  glReadBuffer(GL_BACK); 
    308308   
     
    351351         
    352352 
    353   ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
    354          
     353  ViewCell *viewcell = NULL; 
     354   
     355  PrVs prvs; 
     356  //  mViewCellsManager->SetMaxFilterSize(1); 
     357  mViewCellsManager->GetPrVS(mViewPoint, prvs); 
     358  viewcell = prvs.mViewCell; 
     359   
     360  //  ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
     361  pvsSize = 0; 
    355362  if (viewcell) { 
    356363        SetupCamera(); 
     
    363370          PvsData<Intersectable *>, 
    364371          LtSample<Intersectable *> >::const_iterator it = viewcell->GetPvs().mEntries.begin(); 
     372 
     373        pvsSize = viewcell->GetPvs().mEntries.size(); 
    365374         
    366375        for (; it != viewcell->GetPvs().mEntries.end(); ++ it) { 
     
    436445        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    437446  } 
     447 
     448  if (viewcell) 
     449        mViewCellsManager->DeleteLocalMergeTree(viewcell); 
    438450   
    439451  return pErrorPixels; 
     
    487499        RenderIntersectable(*oi); 
    488500 
    489   ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
     501  ViewCell *viewcell; 
     502  //  viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
     503 
     504  PrVs prvs; 
     505  //  mViewCellsManager->SetMaxFilterSize(1); 
     506  mViewCellsManager->GetPrVS(mViewPoint, prvs); 
     507  viewcell = prvs.mViewCell; 
    490508   
    491509  QImage im1, im2; 
     
    587605  glDisable(GL_CLIP_PLANE0); 
    588606 
     607  if (viewcell) 
     608        mViewCellsManager->DeleteLocalMergeTree(viewcell); 
     609 
    589610  return pErrorPixels; 
    590611} 
     
    615636{ 
    616637  for (int i=0; i < mPvsStatFrames; i++) { 
    617         mPvsErrorBuffer[i] = 1.0f; 
     638        mPvsErrorBuffer[i].mError = 1.0f; 
    618639  } 
    619640} 
     
    646667        } 
    647668#endif 
    648         if (mPvsErrorBuffer[i] > 0.0f) { 
    649           mPvsErrorBuffer[i] = GetPixelError(); 
    650           cout<<"("<<i<<","<<mPvsErrorBuffer[i]<<")"; 
     669        if (mPvsErrorBuffer[i].mError > 0.0f) { 
     670          int pvsSize; 
     671          float error = GetPixelError(pvsSize); 
     672          mPvsErrorBuffer[i].mError = error; 
     673          mPvsErrorBuffer[i].mPvsSize = pvsSize; 
     674 
     675          cout<<"("<<i<<","<<mPvsErrorBuffer[i].mError<<")"; 
    651676          //      swapBuffers(); 
    652677        } 
    653678         
    654         err = mPvsErrorBuffer[i]; 
     679        err = mPvsErrorBuffer[i].mError; 
    655680         
    656681        if (err >= 0.0f) { 
     
    658683                mPvsStat.maxError = err; 
    659684          mPvsStat.sumError += err; 
     685          mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
     686           
    660687          if (err == 0.0f) 
    661688                mPvsStat.errorFreeFrames++; 
     
    820847  vl = new QVBoxLayout; 
    821848  vbox->setLayout(vl); 
    822    
     849 
     850  QLabel *label = new QLabel("Granularity"); 
     851  vbox->layout()->addWidget(label); 
     852 
    823853  QSlider *slider = new QSlider(Qt::Horizontal, vbox); 
    824854  vl->addWidget(slider); 
    825855  slider->show(); 
    826   slider->setRange(1, 5000); 
     856  slider->setRange(1, 200); 
    827857  slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 
    828   slider->setValue(500); 
     858  slider->setValue(200); 
    829859 
    830860  connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetViewCellGranularity(int))); 
     861 
     862  label = new QLabel("Filter size"); 
     863  vbox->layout()->addWidget(label); 
     864   
     865  slider = new QSlider(Qt::Horizontal, vbox); 
     866  vbox->layout()->addWidget(slider); 
     867  slider->show(); 
     868  slider->setRange(1, 100); 
     869  slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 
     870  slider->setValue(3); 
     871   
     872  connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetVisibilityFilterSize(int))); 
    831873 
    832874 
     
    881923  connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetTopDistance(int))); 
    882924 
     925 
     926 
     927   
    883928  cb = new QCheckBox("Top View", vbox); 
    884929  vbox->layout()->addWidget(cb); 
     
    886931  connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetTopView(bool))); 
    887932   
    888  
     933  setWindowTitle("Preprocessor Control Widget"); 
    889934  adjustSize(); 
    890935} 
     
    910955  connect(cw, SIGNAL(SetSceneCut(int)), this, SLOT(SetSceneCut(int))); 
    911956  connect(cw, SIGNAL(SetTopDistance(int)), this, SLOT(SetTopDistance(int))); 
     957 
     958  //connect(cw, SIGNAL(SetViewCellGranularity(int)), this, SLOT(SetMaxFilterSize(int))); 
     959  //  connect(cw, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetVisibilityFilterSize(int))); 
     960  //connect(cw, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetViewCellGranularity(int))); 
     961 
    912962  connect(cw, SIGNAL(SetShowViewCells(bool)), this, SLOT(SetShowViewCells(bool))); 
    913963  connect(cw, SIGNAL(SetTopView(bool)), this, SLOT(SetTopView(bool))); 
     
    921971GlRendererWidget::SetViewCellGranularity(int number) 
    922972{ 
    923   mViewCellsManager->CollectViewCells(number); 
     973  if (mViewCellsManager)  
     974        mViewCellsManager->SetMaxFilterSize(number); 
     975  //  mViewCellsManager->CollectViewCells(number); 
     976  updateGL(); 
     977} 
     978 
     979void 
     980GlRendererWidget::SetVisibilityFilterSize(int number) 
     981{ 
     982  if (mViewCellsManager)  
     983        mViewCellsManager->SetMaxFilterSize(number); 
    924984  updateGL(); 
    925985} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r608 r713  
    3030  float maxError; 
    3131  float sumError; 
     32  int sumPvsSize; 
    3233  int frames; 
    3334  int errorFreeFrames; 
     
    4041        frames = 0; 
    4142        errorFreeFrames = 0; 
     43        sumPvsSize = 0; 
    4244  } 
    4345 
     
    4547  float GetAvgError() { return sumError/frames; } 
    4648  float GetErrorFreeFrames() { return errorFreeFrames/(float)frames; } 
     49  float GetAvgPvs() { return sumPvsSize/(float)frames; } 
    4750   
    4851}; 
     
    161164 
    162165  float 
    163   GetPixelError(); 
     166  GetPixelError(int &pvsSize); 
    164167 
    165168  int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 
     
    168171    
    169172  int mPvsStatFrames; 
    170   vector<float> mPvsErrorBuffer; 
     173  struct PvsErrorEntry { 
     174        PvsErrorEntry() {} 
     175        float mError; 
     176        int mPvsSize; 
     177  }; 
     178   
     179  vector<PvsErrorEntry> mPvsErrorBuffer; 
     180 
    171181private: 
    172182         
     
    190200  SetSceneCut(int); 
    191201  SetTopDistance(int); 
     202  SetVisibilityFilterSize(int); 
    192203 
    193204  SetShowViewCells(bool); 
     
    195206  SetCutViewCells(bool); 
    196207  SetCutScene(bool); 
     208 
    197209 
    198210}; 
     
    256268 SetViewCellGranularity(int number); 
    257269 
    258  void 
    259  SetSceneCut(int cut); 
    260  
    261  void 
    262  SetTopDistance(int dist); 
    263  
     270  void 
     271  SetVisibilityFilterSize(int number); 
     272 
     273  void 
     274  SetSceneCut(int cut); 
     275   
     276  void 
     277  SetTopDistance(int dist); 
     278   
    264279  void SetShowViewCells(bool b) { 
    265280        mRenderViewCells = b; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r695 r713  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0) on: st 15. III 09:41:58 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.0) on: po 20. III 17:50:07 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r705 r713  
    119119          pvsReduction, 
    120120          pvsEnlargement; 
    121  
     121         
    122122        ComputeContinuousPvsDifference(pvs, 
    123123                                                                   pvsReduction, 
    124124                                                                   pvsEnlargement); 
    125  
     125         
    126126        return pvsReduction + pvsEnlargement; 
    127127  } 
     
    161161          data->mSumPdf = -aSumPdf; 
    162162        } 
     163 
     164#if 0 
    163165        float diff = bSumPdf - aSumPdf; 
    164166         
     
    168170          pvsReduction += -diff; 
    169171        } 
     172#else 
     173        if (!data) 
     174          pvsEnlargement += 1.0f; 
     175#endif 
    170176  } 
    171177   
     
    182188                bSumPdf = data->mSumPdf; 
    183189          } 
     190#if 0 
    184191          float diff = bSumPdf - aSumPdf; 
    185192           
     
    189196                pvsReduction += -diff; 
    190197          } 
     198 
     199#else 
     200          if (!data)  
     201                pvsReduction += 1.0f; 
     202#endif 
    191203        } 
    192204  } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r677 r713  
    446446          "#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError()<<endl<< 
    447447          "#MaxPvsRenderError\n" <<renderer->mPvsStat.GetMaxError()<<endl<< 
    448           "#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl; 
     448          "#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl<< 
     449          "#AvgRenderPvs\n" <<renderer->mPvsStat.GetAvgPvs()<<endl; 
    449450  } 
    450451} 
     
    558559        Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    559560        // cull viewcells with PVS > median (0.5f) 
    560         mViewCellsManager->SetValidityPercentage(0, 0.5f);  
     561        //      mViewCellsManager->SetValidityPercentage(0, 0.5f);  
    561562        Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    562563         
  • 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; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r710 r713  
    423423        void EvalViewCellPartition(Preprocessor *preprocessor); 
    424424 
    425  
     425  void SetMaxFilterSize(const int size) { 
     426        mMaxFilterSize = size; 
     427  } 
     428 
     429  /** deletes interior nodes from the tree which have negative merge cost set (local merge) */ 
     430  void 
     431  DeleteLocalMergeTree(ViewCell *vc 
     432                                           ) const; 
     433   
    426434protected: 
    427435 
     
    495503        ViewCell *ConstructLocalMergeTree(ViewCell *currentViewCell,  
    496504                                                                          const ViewCellContainer &viewCells); 
     505 
     506        /** Constructs local view cell merge hierarchy based solely on similarity with the 
     507                current viewcell 
     508        */ 
     509        ViewCell *ConstructLocalMergeTree2(ViewCell *currentViewCell,  
     510                                                                           const ViewCellContainer &viewCells); 
     511   
    497512 
    498513        /** Creates clip plane for visualization. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r685 r713  
    2626        type rss 
    2727        detectEmptyViewSpace true 
    28         pvsRenderErrorSamples 10000 
    29         quitOnFinish false 
    30         computeVisibility false 
     28        pvsRenderErrorSamples 5000 
     29#       pvsRenderErrorSamples 1000 
     30        quitOnFinish true 
     31        computeVisibility true 
    3132} 
    3233 
     
    7576 
    7677RssPreprocessor { 
    77         samplesPerPass 100000 
     78        samplesPerPass 500000 
    7879        initialSamples 500000 
    79         vssSamples 5000000 
    80         vssSamplesPerPass 500000 
     80        vssSamples 20000000 
     81        vssSamplesPerPass 1000000 
    8182        useImportanceSampling true 
    8283 
     
    176177        } 
    177178 
     179        Filter { 
     180                maxSize 20 
     181                width  200.0 
     182        } 
     183 
    178184        #number of active view cells 
    179         active 1024 
     185        active 3000 
    180186        maxStaticMemory 40 
    181187 
     
    185191        #type kdTree 
    186192        #type vspKdTree 
    187         type bspTree 
    188         #type vspBspTree 
     193        #type bspTree 
     194        type vspBspTree 
    189195        #type sceneDependent 
    190196         
     
    235241         
    236242        Evaluation { 
    237                 samplesPerPass 80000 
    238                 samples 1000000 
     243                samplesPerPass 500 
     244                samples 1000 
    239245                statsPrefix ../scripts/viewCells 
    240246        } 
     
    248254#       filename ../scripts/viewcells_soda5-2.xml 
    249255#       filename ../data/soda/soda5-viewcells.xml 
    250         filename ../scripts/viewcells_atlanta.xml 
     256#       filename ../scripts/viewcells_atlanta.xml 
     257        filename ../data/soda/soda5-viewcells2.xml 
    251258} 
    252259 
     
    348355                minGlobalCostRatio      0.0000001 
    349356#               minGlobalCostRatio      0.0001 
    350                 maxViewCells            20000 
     357                maxViewCells            3000 
    351358         
    352359 
Note: See TracChangeset for help on using the changeset viewer.