Changeset 991


Ignore:
Timestamp:
05/29/06 18:54:02 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj

    r938 r991  
    8080                        <Tool 
    8181                                Name="VCLinkerTool" 
    82                                 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib QtCored4.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib" 
     82                                AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtGuid4.lib Qt3Support4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib Preprocessor.lib QtCore4.lib QtOpenGL4.lib" 
    8383                                OutputFile="$(OutDir)/Preprocessor.exe" 
    8484                                LinkIncremental="1" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r975 r991  
    16971697                                   "0.02"); 
    16981698 
    1699          
     1699        RegisterOption("Preprocessor.histogram.maxValue",  
     1700                                        optInt, 
     1701                                        "preprocessor_histogram_max_value=", 
     1702                                        "1000"); 
     1703 
     1704        RegisterOption("Preprocessor.histogram.intervals",  
     1705                                        optInt, 
     1706                                        "preprocessor_histogram_intervals=", 
     1707                                        "20"); 
    17001708 
    17011709 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r931 r991  
    449449{ 
    450450  mViewCellsManager->GetViewPoint(mViewPoint); 
    451   cout<<mViewPoint<<endl; 
     451  sample.mPosition = mViewPoint; 
     452 
     453  cout << mViewPoint << endl; 
    452454   
    453455  // take a render cost sample by rendering a cube 
     
    573575                                                                   vector<RenderCostSample> &samples 
    574576                                                                   ) 
    575 { 
     577{cout << "here1" << endl; 
    576578  makeCurrent(); 
    577579 
     
    586588  int i; 
    587589  int numQ = 500; 
    588    
    589   if (mOcclusionQueries.size() < numQ) { 
    590         cout<<"allocating occ queries..."<<endl; 
    591          
    592         numQ; 
    593         unsigned int *queries = new unsigned int[numQ]; 
    594         for (i=0; i < numQ; i++) 
    595           queries[i] = 111; 
    596          
    597         glGenOcclusionQueriesNV(numQ, queries); 
    598          
    599         mOcclusionQueries.resize(numQ); 
    600          
    601         for (i=0; i < numQ; i++) 
    602           mOcclusionQueries[i] = queries[i]; 
    603          
    604         delete queries; 
    605   } 
    606    
    607   for (i=0; i < n; i++) 
    608         EvalRenderCostSample( 
    609                                                  samples[i] 
    610                                                  ); 
     590 
     591  cout << "here2988" << endl; 
     592 
     593  if (mOcclusionQueries.size() < numQ)  
     594  { 
     595          cout << "allocating occ queries..." << endl; 
     596         
     597          unsigned int *queries = new unsigned int[numQ]; 
     598           
     599          // matt: ? 
     600          for (i = 0; i < numQ; ++ i) 
     601          queries[i] = 111; 
     602         
     603          glGenOcclusionQueriesNV(numQ, queries); 
     604 
     605          mOcclusionQueries.resize(numQ); 
     606         
     607          for (i=0; i < numQ; ++ i) 
     608          { 
     609                  mOcclusionQueries[i] = queries[i]; 
     610          } 
     611     
     612          DEL_PTR(queries); 
     613  } 
     614   
     615  for (i=0; i < n; ++ i) 
     616  { 
     617          cout << i << " "; 
     618          EvalRenderCostSample(samples[i]); 
     619  } 
    611620 
    612621  doneCurrent(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r884 r991  
    6363  } 
    6464   
     65  Vector3 mPosition; 
     66 
    6567  // visible object from the given point 
    6668  int mVisibleObjects; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r878 r991  
    601601 
    602602 
    603 Mesh *CreateBox(const AxisAlignedBox3 &box) 
     603Mesh *CreateMeshFromBox(const AxisAlignedBox3 &box) 
    604604{ 
    605605        Mesh *mesh = new Mesh; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r878 r991  
    182182  } 
    183183   
    184   friend Mesh *CreateBox(const AxisAlignedBox3 &box); 
     184  /** Creates a mesh from a axis aligned bounding box 
     185  */ 
     186  friend Mesh *CreateMeshFromBox(const AxisAlignedBox3 &box); 
    185187}; 
    186188 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r944 r991  
    4141                        const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
    4242                        AxisAlignedBox3 box(pt2, pt2 + boxSize); 
    43                         Mesh *mesh = CreateBox(box); 
     43                        Mesh *mesh = CreateMeshFromBox(box); 
    4444 
    4545                        mesh->Preprocess(); 
     
    6060                        Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
    6161                        AxisAlignedBox3 box(pt2, pt2 + boxSize); 
    62                         Mesh *mesh = CreateBox(box); 
     62                        Mesh *mesh = CreateMeshFromBox(box); 
    6363 
    6464                        mesh->Preprocess(); 
     
    7878                Vector3 boxSize = sceneBox.Size() * Vector3(0.005, 0.02, 0.005); 
    7979                AxisAlignedBox3 box(pt2 + 0.1, pt2 + boxSize); 
    80                 Mesh *mesh = CreateBox(box); 
     80                Mesh *mesh = CreateMeshFromBox(box); 
    8181 
    8282                mesh->Preprocess(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RenderSampler.cpp

    r897 r991  
    99{ 
    1010  environment->GetIntValue("RenderSampler.samples", mSamples); 
    11   cout<<"mspamples"<<mSamples<<endl; 
     11  cout << "number of render samples: " << mSamples << endl; 
    1212} 
    1313 
     
    1515RenderSampler::ComputeVisibility() 
    1616{ 
     17        long startTime = GetTime(); 
     18         
     19        int histoMaxVal = 0; 
     20        int histoIntervals = 0; 
     21         
     22    environment->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 
     23        environment->GetIntValue("Preprocessor.histogram.intervals", histoIntervals); 
     24 
     25        const int intervals = histoIntervals; 
     26 
     27        cout << "starting sampling of render cost ... "; 
     28 
     29        vector<RenderCostSample> samples; 
    1730   
    18   cout<<"HERE I WAS!\n"; 
     31        if (renderer) 
     32        {cout << "here18 " << mSamples << endl; 
     33                renderer->SampleRenderCost(mSamples, samples); 
     34        } 
    1935 
    20   vector<RenderCostSample> samples; 
    21    
    22   if (renderer) 
    23         renderer->SampleRenderCost( 
    24                                                            mSamples, 
    25                                                            samples 
    26                                                            ); 
     36        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    2737 
    2838 
    29   // compute histogram from the samples 
    30   int bins = 100; 
    31   int maxPvs = 0; 
     39        //-- Evaluate properties 
     40         
    3241 
    33   vector<int> histogram(bins); 
     42        //-- compute histogram from the samples 
     43        int avgPvs = 0; 
     44        int maxPvs = 0; 
     45 
     46        vector<int> histogram(intervals); 
    3447   
    35   int i; 
    36   for (i = 0; i < bins; i++) 
    37         histogram[i] = 0; 
     48        int i; 
     49 
     50        /// initialise histogram 
     51        for (i = 0; i < intervals; ++ i) 
     52        { 
     53                histogram[i] = 0; 
     54        } 
     55 
     56         
     57 
     58        for (i = 0; i < mSamples; ++ i)  
     59        { 
     60                if (samples[i].mVisibleObjects > maxPvs) 
     61                { 
     62                        maxPvs = samples[i].mVisibleObjects; 
     63                } 
     64 
     65                avgPvs += samples[i].mVisibleObjects; 
     66        } 
     67 
     68        // sometimes need need to unifiy maximum pvs to compare with other method's histograms 
     69        // => choose histoMaxPvs accordingly (higher than all pvsss) 
     70        const int maxVal = max(histoMaxVal, maxPvs); 
     71         
     72        for (i = 0; i < mSamples; ++ i)  
     73        { 
     74                const int bin = (samples[i].mVisibleObjects * intervals) / maxVal; 
     75 
     76                ++ histogram[bin]; 
     77        } 
     78 
     79 
     80        //-- output the histogram 
     81 
     82        const string filename("fromPointHisto.log"); 
     83        std::ofstream outstream; 
     84        outstream.open(filename.c_str()); 
     85 
     86 
     87 
     88        Debug << "****************************************" << endl; 
     89        Debug << "From point queries: " << endl; 
     90 
     91        for (i = 0; i < intervals; ++ i)  
     92        { 
     93                outstream << "#Pass\n" << i << endl; 
     94                outstream << "#Pvs\n" << histogram[i] << endl; 
     95                //cout << histogram[i] << endl; 
     96        } 
     97 
     98        outstream.close(); 
     99 
     100        avgPvs /= mSamples; 
     101                 
     102        Debug << "max pvs: " << maxPvs << endl; 
     103        Debug << "avg pvs: " << avgPvs << endl; 
    38104   
    39   for (i = 0; i < mSamples; i++) { 
    40         if (samples[i].mVisibleObjects > maxPvs) 
    41           maxPvs = samples[i].mVisibleObjects; 
    42   } 
    43    
    44   for (i = 0; i < mSamples; i++) { 
    45         int bin = (samples[i].mVisibleObjects*bins)/maxPvs; 
    46         histogram[bin]++; 
    47   } 
    48  
    49   // output the histogram 
    50   for (i = 0; i < bins; i++) { 
    51         cout<<histogram[i]<<endl; 
    52   } 
    53  
    54    
    55   return true; 
     105        return true; 
    56106} 
    57107 
     108 
     109 
    58110} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r979 r991  
    566566        maxRenderCost = viewCells.back()->GetRenderCost(); 
    567567 
    568         Debug << "histogram minrc: " << minRenderCost << " maxrc: " << maxRenderCost << endl; 
    569  
    570         const int intervals = min(50, (int)viewCells.size()); 
     568        Debug << "histogram min rc: " << minRenderCost << " max rc: " << maxRenderCost << endl; 
     569 
     570 
     571        const int intervals = min(20, (int)viewCells.size()); 
    571572 
    572573        const float range = maxRenderCost - minRenderCost; 
     
    614615                const float volRatioDif = volDif / totalVol; 
    615616 
    616                 outstream << "#Pass\n" << j << endl; 
     617                outstream << "#Pass\n" << j ++ << endl; 
    617618                outstream << "#RenderCostRatio\n" << rcRatio << endl; 
    618619                outstream << "#WeightedCost\n" << currentRenderCost / totalVol << endl; 
     
    624625                // increase current render cost 
    625626                currentRenderCost += stepSize; 
    626                 ++ j; 
    627627        } 
    628628 
     
    763763        maxPvsSize = viewCells.back()->GetPvs().GetSize(); 
    764764        minPvsSize = 0; 
     765        // hack: normalize pvs size 
    765766        maxPvsSize = 1200; 
    766767        minPvsSize = 0; 
     
    768769 
    769770        Debug << "histogram minpvssize: " << minPvsSize << " maxpvssize: " << maxPvsSize << endl; 
     771 
    770772 
    771773        const int intervals = min(20, (int)viewCells.size()); 
     
    826828                currentPvsSize += stepSize; 
    827829        } 
     830 
    828831        outstream.close(); 
    829832} 
     
    902905                cout << "compute new statistics ... "; 
    903906 
    904 /*Debug << "*******+" << endl; 
    905 float overall = 0; 
    906 stable_sort(leaves.begin(), leaves.end(), ViewCell::SmallerPvs); 
    907         for (int i = 0; i < leaves.size(); ++ i) 
    908         { 
    909                 overall += leaves[i]->GetPvs().GetSize(); 
    910                 Debug << "i " << i << " !size: " << leaves[i]->GetPvs().GetSize() << " vol: " << leaves[i]->GetVolume() << " overall " << overall << endl; 
    911                  
    912         } 
    913 */ 
    914907 
    915908                //-- propagate pvs or pvs size information 
     
    12421235                                                          int maxPvsSize) const 
    12431236{ 
    1244   ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    1245  
    1246   for (it = mViewCells.begin(); it != it_end; ++ it) { 
    1247         SetValidity(*it, minPvsSize, maxPvsSize); 
    1248   } 
     1237        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     1238 
     1239 
     1240        for (it = mViewCells.begin(); it != it_end; ++ it)  
     1241        { 
     1242                SetValidity(*it, minPvsSize, maxPvsSize); 
     1243        } 
    12491244} 
    12501245 
     
    12611256 
    12621257  for (int i=0; i < mViewCells.size(); i++) 
    1263         mViewCells[i]->SetValid(i >= start && i <= end); 
    1264 } 
    1265  
    1266 int 
    1267 ViewCellsManager::CountValidViewcells() const 
    1268 { 
    1269   ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    1270   int valid = 0; 
    1271   for (it = mViewCells.begin(); it != it_end; ++ it) { 
    1272         if ((*it)->GetValid()) 
    1273           valid ++; 
     1258  { 
     1259          mViewCells[i]->SetValid(i >= start && i <= end); 
     1260   
    12741261  } 
    1275   return valid; 
     1262} 
     1263 
     1264int ViewCellsManager::CountValidViewcells() const 
     1265{ 
     1266        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     1267        int valid = 0; 
     1268 
     1269        for (it = mViewCells.begin(); it != it_end; ++ it)  
     1270        {        
     1271                if ((*it)->GetValid()) 
     1272                        ++ valid; 
     1273        } 
     1274 
     1275        return valid; 
    12761276} 
    12771277 
     
    47084708{ 
    47094709        int numSamples; 
     4710 
    47104711        environment->GetIntValue("RenderSampler.samples", numSamples); 
    47114712        cout << "samples" << numSamples << endl; 
     
    47164717                return; 
    47174718 
    4718         // doing the query 
     4719        //start the from point queries 
    47194720        long startTime = GetTime(); 
    47204721        cout << "starting sampling of render cost ... "; 
     
    47284729        vector<RenderCostSample>::const_iterator rit, rit_end = samples.end(); 
    47294730 
     4731        //std::map<ViewCell *, ObjectPvs> sampleMap; 
     4732 
    47304733        for (rit = samples.begin(); rit != rit_end; ++ rit) 
    47314734        { 
    47324735                RenderCostSample sample = *rit; 
    4733                 //ViewCell *vc = GetViewCell(sample.)pos; 
     4736                 
     4737                ViewCell *vc = GetViewCell(sample.mPosition); 
     4738                 
     4739                AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 
     4740         
     4741                Mesh *hMesh = CreateMeshFromBox(box); 
     4742                 
     4743                DEL_PTR(hMesh); 
     4744#if 0 
     4745                if (!sampleMap.find(vc)) 
     4746                        sampleMap.insert(vc, sample.mVisibleObjects); 
     4747                else 
     4748                        sampleMap[vc].Merge(Merge(sample.mVisibleObjects); 
     4749#endif 
    47344750        } 
    47354751} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r979 r991  
    973973        void VisualizeWithFromPointQueries(); 
    974974 
     975        /** Evaluate from point queries for the current scene. 
     976        */ 
     977        void EvalFromPointQueries(); 
     978 
    975979 
    976980        /// the view space partition BSP tree. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r878 r991  
    2828int 
    2929main(int argc, char **argv) 
    30 { 
    31          
     30{QApplication *app = new QApplication(argc, argv); 
     31 
     32        cout << "here222237" << endl; 
    3233//Now just call this function at the start of your program and if you're 
    3334//compiling in debug mode (F5), any leaks will be displayed in the Output 
     
    3839    _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 
    3940    _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);  
    40  
    41   Debug.open("debug.log"); 
     41cout << "here3" << endl; 
     42  Debug.open("debug.log");cout << "here2" << endl; 
    4243  environment = new Environment; 
     44  cout << "here122223" << endl; cout.flush(); 
    4345  environment->Parse(argc, argv, USE_EXE_PATH); 
    4446  MeshKdTree::ParseEnvironment(); 
    45  
     47cout << "here222283" << endl; 
    4648  char buff[128]; 
    4749  environment->GetStringValue("Preprocessor.type", buff); 
     
    4951         
    5052  Preprocessor *p; 
    51  
     53cout << "here22223" << endl; 
    5254  if (preprocessorType == "vss") 
     55  {cout << "here223" << endl; 
    5356        p = new VssPreprocessor(); 
     57  } 
    5458  else 
    5559        if (preprocessorType == "rss") 
     
    6367                else 
    6468                  if (preprocessorType == "render") 
     69                  { 
     70                          cout << "here23" << endl; 
    6571                        p = new RenderSampler(); 
     72                  } 
    6673                  else { 
    6774                        cerr<<"Unknown preprocessor type"<<endl; 
     
    7077                  } 
    7178   
    72  
    73   QApplication *app = NULL; 
     79  
     80  //QApplication *app = NULL; 
    7481 
    7582  if (p->mUseGlRenderer || p->mUseGlDebugger) { 
     83          cout << "here1111" << endl; 
    7684        // create a qt application first (must be created before any opengl widget... 
    77         app = new QApplication(argc, argv); 
    78          
     85        //app = new QApplication(argc, argv); 
     86          cout << "here1112" << endl; 
    7987        if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { 
     88                cout << "here1133" << endl;cout.flush(); 
    8089          QMessageBox::information(0, "OpenGL pbuffers",  
    8190                                                           "This system does not support OpenGL/pbuffers.", 
     
    8392          return -1; 
    8493        } 
     94          cout << "here1119" << endl; 
    8595  } 
    86    
     96   cout << "here1123" << endl; 
    8797  preprocessor = p; 
    8898   
     
    93103  p->BuildKdTree(); 
    94104  p->KdTreeStatistics(cout); 
    95    
     105   cout << "here1199" << endl; 
    96106  // parse view cells related options 
    97107  p->PrepareViewCells(); 
    98108   
    99  
     109 cout << "here1117" << endl; 
    100110  // create a preprocessor thread 
    101111  PreprocessorThread *pt = new PreprocessorThread(p, app); 
     
    106116    p->Export(filename + "-kdtree.x3d", false, true, false);     
    107117  } 
    108  
     118 cout << "here1118" << endl; 
    109119  if (p->mUseGlRenderer) { 
    110          
     120          cout << "here1114" << endl; 
    111121        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 
    112122        //  renderer->resize(640, 480); 
     123         cout << "here1115" << endl; 
    113124        rendererWidget->resize(640, 480); 
    114125        rendererWidget->show(); 
    115          
     126          cout << "here1113" << endl; 
    116127        if (p->GetRenderer()) { 
    117128           
Note: See TracChangeset for help on using the changeset viewer.