Changeset 2035


Ignore:
Timestamp:
01/23/07 14:13:43 (17 years ago)
Author:
bittner
Message:

merge

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
1 added
5 edited

Legend:

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

    r2022 r2035  
    3030// use avg ray contribution as importance 
    3131// if 0 the importance is evaluated from the succ of mutations 
    32 #define USE_AVG_CONTRIBUTION 0 
     32#define USE_AVG_CONTRIBUTION 1 
    3333 
    3434MutationBasedDistribution::RayEntry & 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2023 r2035  
    11101110bool Preprocessor::LoadInternKdTree( const string internKdTree) 
    11111111{ 
    1112         // always try to load the kd tree 
    1113         cout << "loading kd tree file " << internKdTree << " ... " << endl; 
    1114  
    1115         if (!LoadKdTree(internKdTree)) 
    1116         { 
    1117                 cout << "error loading kd tree with filename "  
    1118                          << internKdTree << ", rebuilding it instead ... " << endl; 
    1119                 // build new kd tree from scene geometry 
    1120                 BuildKdTree(); 
    1121  
    1122                 // export kd tree? 
    1123                 const long startTime = GetTime(); 
    1124                 cout << "exporting kd tree ... "; 
    1125  
    1126                 if (!ExportKdTree(internKdTree)) 
    1127                 { 
    1128                         cout << " error exporting kd tree with filename "  
    1129                                  << internKdTree << endl; 
    1130                 } 
    1131                 else 
    1132                 { 
    1133                         cout << "finished in "  
    1134                                  << TimeDiff(startTime, GetTime()) * 1e-3  
    1135                                  << " secs" << endl; 
    1136                 } 
    1137         } 
    1138          
    1139         KdTreeStatistics(cout); 
    1140         cout << mKdTree->GetBox() << endl; 
    1141  
     1112  if (!mUseKdTree) { 
     1113        // create just a dummy KdTree 
     1114        mKdTree = new KdTree; 
    11421115        return true; 
     1116  } 
     1117   
     1118  // always try to load the kd tree 
     1119  cout << "loading kd tree file " << internKdTree << " ... " << endl; 
     1120   
     1121  if (!LoadKdTree(internKdTree)) { 
     1122        cout << "error loading kd tree with filename "  
     1123                 << internKdTree << ", rebuilding it instead ... " << endl; 
     1124        // build new kd tree from scene geometry 
     1125        BuildKdTree(); 
     1126         
     1127        // export kd tree? 
     1128        const long startTime = GetTime(); 
     1129        cout << "exporting kd tree ... "; 
     1130         
     1131        if (!ExportKdTree(internKdTree)) 
     1132          { 
     1133                cout << " error exporting kd tree with filename "  
     1134                         << internKdTree << endl; 
     1135          } 
     1136        else 
     1137          { 
     1138                cout << "finished in "  
     1139                         << TimeDiff(startTime, GetTime()) * 1e-3  
     1140                         << " secs" << endl; 
     1141          } 
     1142  } 
     1143   
     1144  KdTreeStatistics(cout); 
     1145  cout << mKdTree->GetBox() << endl; 
     1146   
     1147  return true; 
    11431148} 
    11441149 
     
    12091214                                           ) 
    12101215{ 
     1216 
    12111217  const long t1 = GetTime(); 
    1212  
    1213 #if 1 
    1214   mRayCaster->SortRays(rays); 
    1215   //cout<<"Rays sorted in "<<TimeDiff(t1, GetTime())<<" ms."<<endl; 
    1216  
    1217   if (0) { 
    1218         VssRayContainer tmpRays; 
    1219         int m = 50000; 
    1220         for (int i=m; i < m+20; i++) { 
    1221           tmpRays.push_back(new VssRay(rays[i].mOrigin, 
    1222                                                                    rays[i].mOrigin + 100.0f*rays[i].mDirection, 
    1223                                                                    NULL, 
    1224                                                                    NULL 
    1225                                                                    ) 
    1226                                                 ); 
    1227            
    1228         } 
    1229         ExportRays("sorted_rays.x3d", tmpRays, 200); 
     1218  if (rays.size() > 10000) { 
     1219        mRayCaster->SortRays(rays); 
     1220        cout<<"Rays sorted in "<<TimeDiff(t1, GetTime())<<" ms."<<endl; 
     1221         
     1222        if (0) { 
     1223          VssRayContainer tmpRays; 
     1224          int m = 50000; 
     1225          for (int i=m; i < m+20; i++) { 
     1226                tmpRays.push_back(new VssRay(rays[i].mOrigin, 
     1227                                                                         rays[i].mOrigin + 100.0f*rays[i].mDirection, 
     1228                                                                         NULL, 
     1229                                                                         NULL 
     1230                                                                         ) 
     1231                                                  ); 
     1232                 
     1233          } 
     1234          ExportRays("sorted_rays.x3d", tmpRays, 200); 
     1235        } 
    12301236  } 
    1231 #endif 
    1232    
    1233         SimpleRayContainer::const_iterator rit, rit_end = rays.end(); 
     1237   
     1238  SimpleRayContainer::const_iterator rit, rit_end = rays.end(); 
    12341239 
    12351240        SimpleRayContainer rayBucket; 
     
    12611266                } 
    12621267         
    1263                 if ((int)rays.size() > 10000 && i % 10000 == 0) 
     1268                if ((int)rays.size() > 100000 && i % 100000 == 0) 
    12641269                  cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 
    12651270        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r2021 r2035  
    106106        else 
    107107        { 
    108                 if (mPreprocessor.mDetectEmptyViewSpace)  
    109                 { 
    110                         if (DotProd(hit.mNormal, direction) >= -Limits::Small)  
    111                         {        
    112                                 hit.mObject = NULL; 
    113                                 return false; 
    114                         } 
     108          if (mPreprocessor.mDetectEmptyViewSpace)  { 
     109                if (DotProd(hit.mNormal, direction) >= -Limits::Small)  {        
     110                  hit.mObject = NULL; 
     111                  return false; 
    115112                } 
    116         } 
    117  
     113          } 
     114        } 
     115         
    118116        return true; 
    119117} 
     
    251249        // regardless of the pruneInvalidRays setting reject rays whic degenerate to a point 
    252250        if (EpsilonEqualV3(hitA.mPoint, hitB.mPoint, Limits::Small)) { 
    253                 return 0; 
     251          return 0; 
    254252        } 
    255253         
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r2022 r2035  
    1111#include "VssRay.h" 
    1212#include "SamplingStrategy.h" 
     13#include "RayCaster.h" 
    1314 
    1415 
     
    2526SamplingPreprocessor::~SamplingPreprocessor() 
    2627{ 
    27   CLEAR_CONTAINER(mSampleRays); 
    28   CLEAR_CONTAINER(mVssSampleRays); 
    2928} 
    3029 
     
    9190 
    9291  map<ViewCell *, HaltonSequence> dirHalton; 
    93    
     92  int lastEvaluation = 0; 
     93  SimpleRayContainer rays; 
     94  VssRayContainer vssRays; 
     95 
    9496  while (samples < mTotalSamples) { 
    95         for (int i=0; i < mSamplesPerEvaluation;) { 
    96           SimpleRayContainer rays; 
    97           VssRayContainer vssRays; 
    98           //      vector<ViewCell *> viewcells; 
     97        for (int i=0; i < mSamplesPerPass;) { 
     98           
     99          mRayCaster->InitPass(); 
    99100           
    100101          float r[5]; 
     
    107108          if (!viewcell || !viewcell->GetValid()) 
    108109                continue; 
    109            
     110 
     111          rays.clear(); 
     112          vssRays.clear(); 
     113 
    110114          for (; rays.size() < 16; ) { 
    111                 if (i%100000 == 0) 
    112                   cout<<"+"; 
     115                if (i%100000 == 0) { 
     116                  cout<<samples/1e6f<<"M rays, progress: "<<samples*100/mTotalSamples<<" %   \r"; 
     117                } 
    113118                 
    114                 //              dirHalton.GetNext(2, r); 
    115119                dirHalton[viewcell].GetNext(2, r); 
    116120                direction = UniformRandomVector(r[0],r[1]); 
    117121                //direction = UniformRandomVector(); 
    118122                 
    119                 //              viewcells.push_back(viewcell); 
    120123                // cast rays in both directions to make the number of samples comparable 
    121124                // with the global sampling method which also casts a "double" ray per sample 
     
    133136                           true); 
    134137           
    135           //      if (vssRays.size()!=32) { 
    136           //            cerr<<"wrong number of rays "<<(int)vssRays.size()<<endl; 
    137           //            exit(1); 
    138           //      } 
    139138 
    140139          rssSamples += vssRays.size(); 
     
    147146                        float pdf = 1.0f; 
    148147                        //                      ViewCell *viewcell = viewcells[j/2]; 
    149  
     148                         
    150149                        ObjectPvs &pvs = viewcell->GetPvs(); 
    151150                        pvs.AddSampleDirtyCheck(obj, pdf); 
     
    157156                } 
    158157           
    159           CLEAR_CONTAINER(vssRays); 
    160            
    161158          if (samples > mTotalSamples) 
    162159                break; 
    163160        } 
    164161 
    165 #if 0 
    166         Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    167         mViewCellsManager->SetValidity(0, intersectables/2); 
    168         Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    169 #endif 
    170          
    171         //      mVssRays.PrintStatistics(mStats); 
    172         mStats << 
    173           "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<< 
    174           "#TotalSamples\n" <<samples<<endl<< 
    175           "#RssSamples\n" <<rssSamples<<endl; 
    176                    
    177         mViewCellsManager->PrintPvsStatistics(mStats); 
    178         // ComputeRenderError(); 
    179   } 
    180    
     162 
     163        if (samples - lastEvaluation >= mSamplesPerEvaluation) { 
     164          mViewCellsManager->PrintPvsStatistics(mStats); 
     165          mStats << 
     166                "#Pass\n" <<mPass<<endl<< 
     167                "#Time\n" << TimeDiff(startTime, GetTime())<<endl<< 
     168                "#TotalSamples\n" <<samples<<endl<< 
     169                "#RssSamples\n" <<rssSamples<<endl; 
     170          lastEvaluation = samples; 
     171 
     172          if (renderer) { 
     173                ComputeRenderError(); 
     174          } 
     175           
     176        } 
     177  } 
    181178  if (0) { 
    182179        Exporter *exporter = Exporter::GetExporter("ray-density.x3d");  
     
    185182        delete exporter; 
    186183  } 
    187    
    188    
    189   // $$JB temporary removed 
     184         
     185         
     186        // $$JB temporary removed 
    190187  //    mViewCellsManager->PostProcess(objects, mSampleRays); 
    191188   
  • GTP/trunk/Lib/Vis/Preprocessing/src/run_test_pompeii

    r2010 r2035  
    22 
    33#COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+" 
    4 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter+ -preprocessor_detect_empty_viewspace-" 
     4COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace- -total_samples=500000000" 
    55 
    66 
     
    88VIEWCELLS=../data/Pompeii/pompeii_big-seq-viewcells.xml.gz 
    99 
    10 PREFIX=../work/plots/osp-pompeii3-1e5 
     10PREFIX=../work/plots/osp-pompeii4-1e5 
    1111 
    1212# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     
    1616#  -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n4n.hlog 
    1717 
    18 # n - no origin mutation, q=2, reverse samples 
     18# # n - no origin mutation, q=2, reverse samples 
    1919 
    20 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    21  -rss_distributions=mutation+object_direction+spatial \ 
    22  -view_cells_use_kd_pvs- -af_use_kd_pvs- \ 
    23  -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4n.xml \ 
    24  -preprocessor_stats=$PREFIX-i-mixed-bvh-n4n.log \ 
    25  -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4n.hlog 
     20# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     21# -rss_distributions=mutation+object_direction+spatial \ 
     22# -view_cells_use_kd_pvs- -af_use_kd_pvs- \ 
     23# -preprocessor_visibility_file=$PREFIX-i-mixed-bvh-n4n.xml \ 
     24# -preprocessor_stats=$PREFIX-i-mixed-bvh-n4n.log \ 
     25# -preprocessor_histogram_file=$PREFIX-i-mixed-bvh-n4n.hlog 
    2626 
    27 # $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    28 # -preprocessor_visibility_file=$PREFIX-r-reference.xml \ 
    29 # -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \ 
    30 # -preprocessor_histogram_file=$PREFIX-r-reference.hlog 
     27$COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     28-preprocessor_visibility_file=$PREFIX-r-reference.xml \ 
     29-view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \ 
     30-preprocessor_histogram_file=$PREFIX-r-reference.hlog 
    3131 
    32 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    33 # -rss_distributions=direction -view_cells_filter_max_size=1 \ 
    34 # -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \ 
    35 # -preprocessor_stats=$PREFIX-r-reference-global.log \ 
    36 # -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog 
     32$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     33 -rss_distributions=direction -view_cells_filter_max_size=1 \ 
     34 -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \ 
     35 -preprocessor_stats=$PREFIX-r-reference-global.log \ 
     36 -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog 
    3737 
    3838#mutation+object_direction+ 
Note: See TracChangeset for help on using the changeset viewer.