Changeset 859 for GTP


Ignore:
Timestamp:
04/28/06 12:23:14 (18 years ago)
Author:
bittner
Message:

apply filter routine for working modules

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r850 r859  
    2525  // Constructors. 
    2626  AxisAlignedBox3() { } 
     27   
    2728  AxisAlignedBox3(const Vector3 &nMin, const Vector3 &nMax) 
    2829  { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r850 r859  
    10361036} 
    10371037 
     1038  /** 
     1039         Input scene filename. Currently simplified X3D (.x3d), Unigraphics (.dat), 
     1040         and UNC (.ply) formats are supported. 
     1041  */ 
    10381042 
    10391043Environment::Environment() 
     
    10621066  RegisterOption("Limits.infinity", optFloat, NULL, "1e6"); 
    10631067 
    1064  
    10651068  RegisterOption("Scene.filename", 
    10661069                                 optString, 
     
    10681071                                 "atlanta2.x3d"); 
    10691072 
     1073   
    10701074  RegisterOption("Unigraphics.meshGrouping", 
    10711075                                 optInt, 
     
    10781082                                 "kd_term_min_cost=", 
    10791083                                 "10"); 
    1080  
     1084   
    10811085  RegisterOption("KdTree.Termination.maxNodes", 
    10821086                                 optInt, 
    10831087                                 "kd_term_max_nodes=", 
    10841088                                 "200000"); 
    1085  
     1089   
    10861090  RegisterOption("KdTree.Termination.maxDepth", 
    10871091                                 optInt, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r811 r859  
    4141//PFNGLGETQUERYUIVARBPROC glGetQueryuivARB; 
    4242#endif 
     43 
     44bool useFilter = false; 
    4345 
    4446GlRenderer::GlRenderer(SceneGraph *sceneGraph, 
     
    838840   
    839841  ViewCell *viewcell; 
    840   //  viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
    841842 
    842843  PrVs prvs; 
    843   //  mViewCellsManager->SetMaxFilterSize(1); 
    844   mViewCellsManager->GetPrVS(mViewPoint, prvs); 
    845   viewcell = prvs.mViewCell; 
     844   
     845  if (!useFilter) 
     846        viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
     847  else { 
     848        //  mViewCellsManager->SetMaxFilterSize(1); 
     849        mViewCellsManager->GetPrVS(mViewPoint, prvs); 
     850        viewcell = prvs.mViewCell; 
     851  } 
    846852   
    847853  if (viewcell) { 
     
    869875          mWireFrame = false; 
    870876        } 
    871         mViewCellsManager->DeleteLocalMergeTree(viewcell); 
     877         
     878        if (useFilter) 
     879          mViewCellsManager->DeleteLocalMergeTree(viewcell); 
    872880  } else { 
    873881        ObjectContainer::const_iterator oi = mObjects.begin(); 
     
    910918 
    911919  ViewCell *viewcell; 
    912   //  viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
    913920 
    914921  PrVs prvs; 
    915922  //  mViewCellsManager->SetMaxFilterSize(1); 
    916   mViewCellsManager->GetPrVS(mViewPoint, prvs); 
    917   viewcell = prvs.mViewCell; 
     923 
     924 
     925  if (!useFilter) 
     926        viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
     927  else { 
     928        mViewCellsManager->GetPrVS(mViewPoint, prvs); 
     929        viewcell = prvs.mViewCell; 
     930  } 
    918931   
    919932  QImage im1, im2; 
     
    10161029  glDisable(GL_CLIP_PLANE0); 
    10171030 
    1018   if (viewcell) 
     1031  if (useFilter && viewcell) 
    10191032        mViewCellsManager->DeleteLocalMergeTree(viewcell); 
    1020  
     1033   
    10211034  mRenderError = pErrorPixels; 
    10221035  return pErrorPixels; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r837 r859  
    714714 
    715715void 
     716KdTree::CollectObjects(const AxisAlignedBox3 &box, 
     717                                           ObjectContainer &objects) 
     718{ 
     719  stack<KdNode *> nodeStack; 
     720 
     721  nodeStack.push(mRoot); 
     722 
     723  while (!nodeStack.empty()) { 
     724    KdNode *node = nodeStack.top(); 
     725    nodeStack.pop(); 
     726    if (node->IsLeaf()) { 
     727      KdLeaf *leaf = (KdLeaf *)node; 
     728      for (int j=0; j < leaf->mObjects.size(); j++) { 
     729                Intersectable *object = leaf->mObjects[j]; 
     730                if (!object->Mailed()) { 
     731                  object->Mail(); 
     732                  objects.push_back(object); 
     733                } 
     734      } 
     735    } else { 
     736      KdInterior *interior = (KdInterior *)node; 
     737 
     738          if ( box.Max()[interior->mAxis] > interior->mPosition ) 
     739                nodeStack.push(interior->mFront); 
     740  
     741          if (box.Min()[interior->mAxis] < interior->mPosition) 
     742                nodeStack.push(interior->mBack); 
     743    } 
     744  } 
     745} 
     746 
     747void 
    716748KdTree::CollectObjects(KdNode *n, ObjectContainer &objects) 
    717749{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r752 r859  
    307307  void 
    308308  CollectObjects(KdNode *n, ObjectContainer &objects); 
    309          
     309 
     310  void 
     311  CollectObjects(const AxisAlignedBox3 &box, 
     312                                 ObjectContainer &objects); 
     313 
    310314  void 
    311315  CollectLeaves(vector<KdLeaf *> &leaves); 
     
    342346  KdTree::GetRandomLeaf(const Plane3 &halfspace); 
    343347 
    344         KdNode * 
    345         GetRandomLeaf(const bool onlyUnmailed = false); 
    346  
     348  KdNode * 
     349  GetRandomLeaf(const bool onlyUnmailed = false); 
     350   
    347351  int 
    348352  FindNeighbors(KdNode *n, 
    349                 vector<KdNode *> &neighbors, 
    350                 bool onlyUnmailed 
    351                 ); 
     353                                vector<KdNode *> &neighbors, 
     354                                bool onlyUnmailed 
     355                                ); 
    352356 
    353357  int 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r811 r859  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: pá 14. IV 14:54:41 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: út 25. IV 12:50:38 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r811 r859  
    5050}; 
    5151 
    52 void 
    53 Mesh::Preprocess() 
    54 { 
    55   Cleanup(); 
    56          
     52 
     53void 
     54Mesh::ComputeBoundingBox() 
     55{ 
     56 
    5757  mBox.Initialize(); 
    5858  VertexContainer::const_iterator vi = mVertices.begin(); 
     
    6161  } 
    6262 
    63    
     63} 
     64 
     65void 
     66Mesh::Preprocess() 
     67{ 
     68 Cleanup(); 
     69    
     70   ComputeBoundingBox(); 
     71    
    6472  /** true if it is a watertight convex mesh */ 
    6573  mIsConvex = false; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r752 r859  
    100100    mFaces.push_back(face); 
    101101  } 
    102    
     102 
     103  void ComputeBoundingBox(); 
    103104  void Preprocess(); 
    104105 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r811 r859  
    798798  Debug<<"Done.\n"; 
    799799 
     800 
     801  cout<<"Applying visibility filter..."; 
     802  mViewCellsManager->ApplyFilter(mKdTree, 
     803                                                                 0.05f, 
     804                                                                 0.05f); 
     805  cout<<"done."; 
    800806   
    801807  return true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r850 r859  
    207207} 
    208208 
     209AxisAlignedBox3 
     210ViewCellsManager::GetViewCellBox(ViewCell *vc) 
     211{ 
     212  Mesh *m = vc->GetMesh(); 
     213   
     214  if (m) { 
     215        m->ComputeBoundingBox(); 
     216        return m->mBox; 
     217  } 
     218 
     219  AxisAlignedBox3 box; 
     220   
     221  box.Initialize(); 
     222   
     223  if (!vc->IsLeaf()) { 
     224        ViewCellInterior *vci = (ViewCellInterior *) vc; 
     225         
     226        ViewCellContainer::iterator it = vci->mChildren.begin(); 
     227        for (; it != vci->mChildren.end(); ++it) { 
     228          box.Include(GetViewCellBox(*it)); 
     229        } 
     230  } 
     231   
     232  return box; 
     233} 
    209234 
    210235void ViewCellsManager::CollectEmptyViewCells() 
     
    48074832 
    48084833 
     4834void 
     4835ViewCellsManager::ApplyFilter(ViewCell *viewCell, 
     4836                                                          KdTree *kdTree, 
     4837                                                          const float viewSpaceFilterSize, 
     4838                                                          const float spatialFilterSize, 
     4839                                                          ObjectPvs &pvs 
     4840                                                          ) 
     4841{ 
     4842  // extend the pvs of the viewcell by pvs of its neighbors 
     4843  // and apply spatial filter by including all neighbors of the objects 
     4844  // in the pvs 
     4845 
     4846  // get all viewcells intersecting the viewSpaceFilterBox 
     4847  // and compute the pvs union 
     4848   
     4849  //Vector3 center = viewCell->GetBox().Center(); 
     4850  //  Vector3 center = m->mBox.Center(); 
     4851   
     4852  //  AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 
     4853  //                                      center + Vector3(viewSpaceFilterSize/2)); 
     4854   
     4855  AxisAlignedBox3 box = GetViewCellBox(viewCell); 
     4856  box.Enlarge(Vector3(viewSpaceFilterSize/2)); 
     4857   
     4858  ViewCellContainer viewCells; 
     4859  ComputeBoxIntersections(box, viewCells); 
     4860 
     4861  //  cout<<"box="<<box<<endl; 
     4862  ViewCellContainer::const_iterator it=viewCells.begin(), it_end = viewCells.end(); 
     4863   
     4864  int i; 
     4865  for (i=0; it != it_end; ++it, i++) { 
     4866        //      cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
     4867        pvs.Merge((*it)->GetPvs()); 
     4868  } 
     4869   
     4870  // now compute a new Pvs by including also objects intersecting the extended boxes of 
     4871  // visible objects 
     4872 
     4873  Intersectable::NewMail(); 
     4874   
     4875  std::map<Intersectable *, 
     4876        PvsData<Intersectable *>, 
     4877        LtSample<Intersectable *> >::const_iterator oi; 
     4878   
     4879  for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 
     4880        Intersectable *object = (*oi).first; 
     4881        object->Mail(); 
     4882  } 
     4883 
     4884  ObjectPvs nPvs; 
     4885  // now go through the pvs again 
     4886  for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 
     4887        Intersectable *object = (*oi).first; 
     4888 
     4889        //      Vector3 center = object->GetBox().Center(); 
     4890        //      AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 
     4891        //                                              center + Vector3(spatialFilterSize/2)); 
     4892 
     4893        AxisAlignedBox3 box = object->GetBox(); 
     4894        box.Enlarge(Vector3(spatialFilterSize/2)); 
     4895 
     4896        ObjectContainer objects; 
     4897 
     4898        // $$ warning collect objects takes only unmailed ones! 
     4899        kdTree->CollectObjects(box, 
     4900                                                   objects); 
     4901        //      cout<<"collected objects="<<objects.size()<<endl; 
     4902        ObjectContainer::const_iterator noi = objects.begin(); 
     4903        for (; noi != objects.end(); ++noi) { 
     4904          Intersectable *o = *noi; 
     4905          if (!o->Mailed()) 
     4906                // $$ JB warning: pdfs are not correct at this point! 
     4907                nPvs.AddSample(o, Limits::Small); 
     4908        } 
     4909  } 
     4910 
     4911  pvs.Merge(nPvs); 
     4912 
     4913} 
     4914 
     4915 
     4916 
     4917void 
     4918ViewCellsManager::ApplyFilter(KdTree *kdTree, 
     4919                                                          const float relViewSpaceFilterSize, 
     4920                                                          const float relSpatialFilterSize 
     4921                                                          ) 
     4922{ 
     4923 
     4924  ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     4925 
     4926  ObjectPvs *newPvs; 
     4927  newPvs = new ObjectPvs[mViewCells.size()]; 
     4928 
     4929  float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 
     4930  float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 
     4931   
     4932  int i; 
     4933  for (i=0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 
     4934        ApplyFilter(*it, 
     4935                                kdTree, 
     4936                                viewSpaceFilterSize, 
     4937                                spatialFilterSize, 
     4938                                newPvs[i] 
     4939                                ); 
     4940  } 
     4941 
     4942  // now replace all pvss 
     4943  for (i= 0, it = mViewCells.begin(); it != it_end; ++ it, i++) { 
     4944        ObjectPvs &pvs = (*it)->GetPvs(); 
     4945        pvs.Clear(); 
     4946        pvs = newPvs[i]; 
     4947  } 
     4948   
     4949} 
     4950 
    48094951void VspBspViewCellsManager::TestFilter(const ObjectContainer &objects) 
    48104952{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r850 r859  
    422422        float EvalRenderCost(Intersectable *obj) const; 
    423423 
     424    void 
     425        ApplyFilter(KdTree *kdTree, 
     426                                const float viewSpaceFilterSize, 
     427                                const float spatialFilterSize 
     428                                ); 
     429 
     430  AxisAlignedBox3 
     431  GetViewCellBox(ViewCell *vc); 
     432 
    424433        /** Exports bounding boxes of objects to file. 
    425434        */ 
     
    431440 
    432441protected: 
    433  
     442    void 
     443        ApplyFilter(ViewCell *viewCell, 
     444                                KdTree *kdTree, 
     445                                const float viewSpaceFilterSize, 
     446                                const float spatialFilterSize, 
     447                                ObjectPvs &pvs 
     448                                ); 
     449 
     450   
    434451        /** Returns the bounding box of filter width. 
    435452        */ 
     
    667684        void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 
    668685 
     686 
    669687protected: 
    670688 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r811 r859  
    1212#filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 
    1313# filename ../data/vienna/viewcells-25-sel.x3d 
    14 #filename ../data/atlanta/atlanta2.x3d 
     14filename ../data/atlanta/atlanta2.x3d 
    1515#filename ../data/soda/soda.dat 
    16 filename ../data/soda/soda5.dat 
     16#filename ../data/soda/soda5.dat 
    1717#filename ../data/PowerPlant/ppsection1/part_a/g0.ply 
    1818#filename ../data/PowerPlant/ppsection1/part_b/g0.ply 
     
    2828        # stored sample rays 
    2929        samplesFilename rays.out 
    30         useGlRenderer false 
    31         useGlDebugger true 
     30        useGlRenderer true 
     31        useGlDebugger false 
    3232#       type sampling 
    3333#       type vss 
    34 #       type rss 
    35         type render 
     34        type rss 
     35#       type render 
    3636        detectEmptyViewSpace false 
    3737        pvsRenderErrorSamples 0 
     
    5151        vssSamples 1000000 
    5252        vssSamplesPerPass 200000 
    53         useImportanceSampling true 
     53        useImportanceSampling false 
    5454        loadInitialSamples  false 
    5555        storeInitialSamples false 
     
    8989 
    9090RssPreprocessor { 
    91         samplesPerPass 100000 
    92         initialSamples 500000 
    93         vssSamples 1000000000 
    94         vssSamplesPerPass 100000 
    95         useImportanceSampling true 
     91        samplesPerPass 1000000 
     92        initialSamples 1000000 
     93        vssSamples 1000000 
     94        vssSamplesPerPass 1000000 
     95        useImportanceSampling false 
    9696 
    9797        directionalSampling false 
     
    101101                pvs false 
    102102                rssTree false 
    103                 rays true 
     103                rays false 
    104104                numRays 20000 
    105105        } 
     
    170170MeshKdTree { 
    171171        Termination { 
    172                 minCost 8 
     172                minCost 40 
    173173                maxDepth 18 
    174174                maxCostRatio 0.9 
     
    201201 
    202202        #number of active view cells 
    203         active 15000 
     203        active 5000 
    204204        maxStaticMemory 40 
    205205 
     
    214214         
    215215        height 5.0 
    216         maxViewCells 4000 
     216        maxViewCells 5000 
    217217 
    218218        #percentage of total visible objects where pvs is considered invalid 
     
    248248                #colorCode MergedTreeDiff 
    249249                colorCode Random 
    250                 exportRays true 
     250                exportRays false 
    251251                exportGeometry false 
    252252                exportMergedViewCells false 
     
    273273#       filename ../data/soda/soda5-viewcells.xml 
    274274#       filename ../scripts/viewcells_atlanta.xml 
    275         filename ../data/soda/soda5-viewcells2.xml 
    276 #       filename ../data/atlanta/viewcells_atlanta3.xml 
     275#       filename ../data/soda/soda5-viewcells2.xml 
     276        filename ../data/atlanta/viewcells_atlanta3.xml 
    277277#       filename ../data/vienna/viewcells_vienna.xml 
    278278#       filename ../data/PowerPlant/power_plant_viewcells_all3.xml 
     
    376376                minGlobalCostRatio      0.0000001 
    377377#               minGlobalCostRatio      0.0001 
    378                 maxViewCells            3000 
     378                maxViewCells            50000 
    379379         
    380380 
Note: See TracChangeset for help on using the changeset viewer.