Changeset 884 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 05/03/06 11:35:39 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r878 r884 44 44 #endif 45 45 46 bool useFilter = false;47 46 48 47 GlRenderer::GlRenderer(SceneGraph *sceneGraph, … … 848 847 PrVs prvs; 849 848 850 if (! useFilter) {851 viewcell = mViewCellsManager->GetViewCell(mViewPoint );849 if (!mUseFilter) { 850 viewcell = mViewCellsManager->GetViewCell(mViewPoint, true); 852 851 } else { 853 852 // mViewCellsManager->SetMaxFilterSize(1); … … 857 856 858 857 if (viewcell) { 859 ObjectPvs &pvs = viewcell->GetPvs(); 860 858 // copy the pvs so that it can be filtered... 859 ObjectPvs pvs = viewcell->GetPvs(); 860 861 if (mUseSpatialFilter) { 862 mViewCellsManager->ApplySpatialFilter(mKdTree, 863 mSpatialFilterSize* 864 Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 865 // mViewCellsManager->GetFilterWidth()/2, 866 pvs); 867 } 868 869 861 870 // read back the texture 862 871 std::map<Intersectable *, … … 881 890 } 882 891 883 if ( useFilter)892 if (mUseFilter) 884 893 mViewCellsManager->DeleteLocalMergeTree(viewcell); 885 894 } else { … … 924 933 ViewCell *viewcell; 925 934 926 PrVs prvs;927 // mViewCellsManager->SetMaxFilterSize(1);928 929 930 if (!useFilter)931 viewcell = mViewCellsManager->GetViewCell(mViewPoint);932 else {933 mViewCellsManager->GetPrVS(mViewPoint, prvs);934 viewcell = prvs.mViewCell;935 }936 937 935 QImage im1, im2; 938 936 QImage diff; … … 942 940 im1 = grabFrameBuffer(true); 943 941 944 SetupCamera(); 945 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 946 947 std::map<Intersectable *, 948 PvsData<Intersectable *>, 949 LtSample<Intersectable *> >::const_iterator it = viewcell->GetPvs().mEntries.begin(); 950 951 mPvsSize = viewcell->GetPvs().mEntries.size(); 952 953 for (; it != viewcell->GetPvs().mEntries.end(); ++ it) { 954 Intersectable *object = (*it).first; 955 RenderIntersectable(object); 956 } 942 RenderPvs(); 957 943 958 944 // read back the texture … … 978 964 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 979 965 mUseFalseColors = false; 980 966 981 967 oi = mObjects.begin(); 982 968 for (; oi != mObjects.end(); oi++) … … 1033 1019 1034 1020 glDisable(GL_CLIP_PLANE0); 1035 1036 if (useFilter && viewcell)1037 mViewCellsManager->DeleteLocalMergeTree(viewcell);1038 1021 1039 1022 mRenderError = pErrorPixels; … … 1317 1300 1318 1301 1302 label = new QLabel("Spatial Filter size"); 1303 vbox->layout()->addWidget(label); 1304 1305 slider = new QSlider(Qt::Horizontal, vbox); 1306 vbox->layout()->addWidget(slider); 1307 slider->show(); 1308 slider->setRange(1, 100); 1309 slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 1310 slider->setValue(10); 1311 1312 connect(slider, SIGNAL(valueChanged(int)), SIGNAL(SetSpatialFilterSize(int))); 1313 1314 1319 1315 1320 1316 QWidget *hbox = new QWidget(vbox); … … 1363 1359 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderErrors(bool))); 1364 1360 1361 cb = new QCheckBox("Use filter", vbox); 1362 vbox->layout()->addWidget(cb); 1363 cb->setChecked(true); 1364 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseFilter(bool))); 1365 1366 cb = new QCheckBox("Use spatial filter", vbox); 1367 vbox->layout()->addWidget(cb); 1368 cb->setChecked(true); 1369 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetUseSpatialFilter(bool))); 1370 1365 1371 cb = new QCheckBox("Render filter", vbox); 1366 1372 vbox->layout()->addWidget(cb); 1367 1373 cb->setChecked(true); 1368 1374 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetRenderFilter(bool))); 1375 1369 1376 1370 1377 cb = new QCheckBox("Cut view cells", vbox); … … 1457 1464 mRenderErrors = false; 1458 1465 mRenderFilter = true; 1466 mUseFilter = true; 1467 mUseSpatialFilter = true; 1459 1468 mShowRenderCost = false; 1460 1469 mShowPvsSizes = false; 1461 1470 mSpatialFilterSize = 0.01; 1462 1471 mPvsSize = 0; 1463 1472 mRenderError = 0.0f; … … 1469 1478 1470 1479 connect(mControlWidget, SIGNAL(SetVisibilityFilterSize(int)), this, SLOT(SetVisibilityFilterSize(int))); 1480 connect(mControlWidget, SIGNAL(SetSpatialFilterSize(int)), this, SLOT(SetSpatialFilterSize(int))); 1471 1481 1472 1482 connect(mControlWidget, SIGNAL(SetShowViewCells(bool)), this, SLOT(SetShowViewCells(bool))); … … 1478 1488 connect(mControlWidget, SIGNAL(SetRenderErrors(bool)), this, SLOT(SetRenderErrors(bool))); 1479 1489 connect(mControlWidget, SIGNAL(SetRenderFilter(bool)), this, SLOT(SetRenderFilter(bool))); 1490 connect(mControlWidget, SIGNAL(SetUseFilter(bool)), this, SLOT(SetUseFilter(bool))); 1491 connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), 1492 this, SLOT(SetUseSpatialFilter(bool))); 1480 1493 1481 1494 … … 1489 1502 // mViewCellsManager->SetMaxFilterSize(number); 1490 1503 mViewCellsManager->CollectViewCells(number); 1504 1491 1505 updateGL(); 1492 1506 } … … 1497 1511 if (mViewCellsManager) 1498 1512 mViewCellsManager->SetMaxFilterSize(number); 1513 updateGL(); 1514 } 1515 1516 void 1517 GlRendererWidget::SetSpatialFilterSize(int number) 1518 { 1519 mSpatialFilterSize = 1e-3*number; 1499 1520 updateGL(); 1500 1521 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r865 r884 259 259 SetTopDistance(int); 260 260 SetVisibilityFilterSize(int); 261 SetSpatialFilterSize(int); 261 262 262 263 SetRenderFilter(bool); 264 SetUseFilter(bool); 265 SetUseSpatialFilter(bool); 263 266 SetRenderErrors(bool); 264 267 SetShowViewCells(bool); … … 286 289 bool mRenderErrors; 287 290 bool mRenderFilter; 291 bool mUseFilter; 292 bool mUseSpatialFilter; 288 293 bool mShowRenderCost; 294 289 295 bool mShowPvsSizes; 290 296 float mSpatialFilterSize; 297 291 298 Plane3 mSceneCutPlane; 292 299 float mTopDistance; … … 351 358 } 352 359 360 void SetUseFilter(bool b) { 361 mUseFilter = b; 362 updateGL(); 363 } 364 365 void SetUseSpatialFilter(bool b) { 366 mUseSpatialFilter = b; 367 updateGL(); 368 } 369 353 370 354 371 void … … 357 374 void 358 375 SetVisibilityFilterSize(int number); 376 377 void 378 SetSpatialFilterSize(int number); 359 379 360 380 void -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r871 r884 686 686 rssSamples += (int)vssRays.size(); 687 687 688 cout<<"Generated "<<castRays<<" rays, progress "<< totalSamples/((float) mRssSamples +689 mInitialSamples)<<"%\n";688 cout<<"Generated "<<castRays<<" rays, progress "<<100.0f*totalSamples/((float) mRssSamples + 689 mInitialSamples)<<"%\n"; 690 690 691 691 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r882 r884 4844 4844 } 4845 4845 4846 void 4847 ViewCellsManager::ApplySpatialFilter( 4848 KdTree *kdTree, 4849 const float spatialFilterSize, 4850 ObjectPvs &pvs 4851 ) 4852 { 4853 4854 // now compute a new Pvs by including also objects intersecting the extended boxes of 4855 // visible objects 4856 4857 Intersectable::NewMail(); 4858 4859 std::map<Intersectable *, 4860 PvsData<Intersectable *>, 4861 LtSample<Intersectable *> >::const_iterator oi; 4862 4863 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 4864 Intersectable *object = (*oi).first; 4865 object->Mail(); 4866 } 4867 4868 ObjectPvs nPvs; 4869 int nPvsSize=0; 4870 // now go through the pvs again 4871 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 4872 Intersectable *object = (*oi).first; 4873 4874 // Vector3 center = object->GetBox().Center(); 4875 // AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 4876 // center + Vector3(spatialFilterSize/2)); 4877 4878 AxisAlignedBox3 box = object->GetBox(); 4879 box.Enlarge(Vector3(spatialFilterSize/2)); 4880 4881 ObjectContainer objects; 4882 4883 // $$ warning collect objects takes only unmailed ones! 4884 kdTree->CollectObjects(box, 4885 objects); 4886 // cout<<"collected objects="<<objects.size()<<endl; 4887 ObjectContainer::const_iterator noi = objects.begin(); 4888 for (; noi != objects.end(); ++noi) { 4889 Intersectable *o = *noi; 4890 // $$ JB warning: pdfs are not correct at this point! 4891 nPvs.AddSample(o, Limits::Small); 4892 nPvsSize++; 4893 } 4894 } 4895 // cout<<"nPvs size = "<<nPvsSize<<endl; 4896 pvs.Merge(nPvs); 4897 } 4846 4898 4847 4899 void … … 4881 4933 } 4882 4934 4883 // now compute a new Pvs by including also objects intersecting the extended boxes of 4884 // visible objects 4885 4886 Intersectable::NewMail(); 4887 4888 std::map<Intersectable *, 4889 PvsData<Intersectable *>, 4890 LtSample<Intersectable *> >::const_iterator oi; 4891 4892 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 4893 Intersectable *object = (*oi).first; 4894 object->Mail(); 4895 } 4896 4897 ObjectPvs nPvs; 4898 // now go through the pvs again 4899 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 4900 Intersectable *object = (*oi).first; 4901 4902 // Vector3 center = object->GetBox().Center(); 4903 // AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 4904 // center + Vector3(spatialFilterSize/2)); 4905 4906 AxisAlignedBox3 box = object->GetBox(); 4907 box.Enlarge(Vector3(spatialFilterSize/2)); 4908 4909 ObjectContainer objects; 4910 4911 // $$ warning collect objects takes only unmailed ones! 4912 kdTree->CollectObjects(box, 4913 objects); 4914 // cout<<"collected objects="<<objects.size()<<endl; 4915 ObjectContainer::const_iterator noi = objects.begin(); 4916 for (; noi != objects.end(); ++noi) { 4917 Intersectable *o = *noi; 4918 if (!o->Mailed()) 4919 // $$ JB warning: pdfs are not correct at this point! 4920 nPvs.AddSample(o, Limits::Small); 4921 } 4922 } 4923 4924 pvs.Merge(nPvs); 4935 ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 4925 4936 } 4926 4937 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r880 r884 424 424 ); 425 425 426 void 427 ApplySpatialFilter( 428 KdTree *kdTree, 429 const float spatialFilterSize, 430 ObjectPvs &pvs 431 ); 432 426 433 /** Returns bounding box of a view cell. 427 434 */ … … 447 454 static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 448 455 456 float GetFilterWidth() { 457 return Magnitude(mViewSpaceBox.Size())*mFilterWidth; 458 } 459 449 460 protected: 450 461 void -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r878 r884 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d 11 #filename ../data/vienna/vienna-buildings.x3d12 filename ../data/vienna/city1500_flat_1.x3d11 filename ../data/vienna/vienna-buildings.x3d 12 #filename ../data/vienna/city1500_flat_1.x3d 13 13 #filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 14 14 # filename ../data/vienna/viewcells-25-sel.x3d … … 53 53 samplesPerPass 100000 54 54 initialSamples 500000 55 vssSamples 100000056 vssSamplesPerPass 20000057 useImportanceSampling false55 vssSamples 5000000 56 vssSamplesPerPass 500000 57 useImportanceSampling true 58 58 loadInitialSamples false 59 59 storeInitialSamples false … … 95 95 samplesPerPass 500000 96 96 initialSamples 1000000 97 vssSamples 200000097 vssSamples 5000000 98 98 vssSamplesPerPass 1000000 99 useImportanceSampling false99 useImportanceSampling true 100 100 101 101 directionalSampling false … … 203 203 Filter { 204 204 maxSize 5 205 width 0.0 5205 width 0.02 206 206 } 207 207
Note: See TracChangeset
for help on using the changeset viewer.