- Timestamp:
- 02/27/06 18:39:47 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env
r662 r664 236 236 clipPlaneAxis 1 237 237 } 238 239 evaluateViewCells true 238 240 239 241 Evaluation { … … 241 243 samples 2000000 242 244 } 245 243 246 # filename ../data/atlanta/atlanta_viewcells_large.x3d 244 247 # filename ../data/vienna/viewcells-25-sel.x3d … … 322 325 maxTotalMemory 50 323 326 maxStaticMemory 50 327 328 simulateOctree false 324 329 325 330 subdivisionStats ../subDivisionStats.log -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r663 r664 1201 1201 RegisterOption("ViewCells.type", 1202 1202 optString, 1203 "view_cells_type ",1203 "view_cells_type=", 1204 1204 "vspBspTree"); 1205 1205 1206 1206 RegisterOption("ViewCells.samplingType", 1207 1207 optString, 1208 "view_cells_sampling_type ",1208 "view_cells_sampling_type=", 1209 1209 "box"); 1210 1210 … … 1214 1214 "viewCellsStats.log"); 1215 1215 1216 RegisterOption("ViewCells. PostProcess.statsPrefix",1216 RegisterOption("ViewCells.Evaluation.statsPrefix", 1217 1217 optString, 1218 "view_cells_ stats_prefix=",1218 "view_cells_evaluation_stats_prefix=", 1219 1219 "viewCells"); 1220 1220 1221 1221 RegisterOption("ViewCells.active", 1222 1222 optInt, 1223 "view_cells_active=", 1223 1224 "1000"); 1224 1225 … … 1228 1229 "5000000"); 1229 1230 1230 1231 1231 RegisterOption("ViewCells.Construction.samplesPerPass", 1232 1232 optInt, … … 1246 1246 RegisterOption("ViewCells.loadFromFile", 1247 1247 optBool, 1248 "view_cells_load_from_file ",1248 "view_cells_load_from_file=", 1249 1249 "false"); 1250 1250 1251 1251 RegisterOption("ViewCells.PostProcess.refine", 1252 1252 optBool, 1253 "view_cells_refine ",1253 "view_cells_refine=", 1254 1254 "false"); 1255 1256 1255 1257 1256 RegisterOption("ViewCells.PostProcess.compress", 1258 1257 optBool, 1259 "view_cells_ compress",1258 "view_cells_post_process_compress=", 1260 1259 "false"); 1261 1260 … … 1270 1269 "300000"); 1271 1270 1272 1273 1271 RegisterOption("ViewCells.exportToFile", 1274 1272 optBool, 1275 1273 "view_cells_export_to_file", 1274 "false"); 1275 1276 RegisterOption("ViewCells.evaluateViewCells", 1277 optBool, 1278 "view_cells_evaluate_view_cells=", 1276 1279 "false"); 1277 1280 … … 1983 1986 RegisterOption("VspBspTree.Factor.balancedRays", optFloat, "-vsp_bsp_factor_balanced_rays=", "1.0"); 1984 1987 RegisterOption("VspBspTree.Factor.pvs", optFloat, "-vsp_bsp_factor_pvs=", "1.0"); 1985 1986 1988 1987 1989 RegisterOption("VspBspTree.Construction.renderCostWeight", 1988 1990 optFloat, … … 1998 2000 optBool, 1999 2001 "vsp_bsp_simulate_octree=", 2002 "false"); 2003 2004 RegisterOption("VspBspTree.breathFirstSplits", 2005 optBool, 2006 "-vsp_bsp_breath_first_splits=", 2007 "false"); 2008 2009 RegisterOption("VspBspTree.useRandomAxis", 2010 optBool, 2011 "-vsp_bsp_use_random_axis=", 2000 2012 "false"); 2001 2013 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r659 r664 283 283 else 284 284 { 285 cerr <<"Wrong view cells type" << name<< endl;285 cerr << "Wrong view cells type " << name << "!!!" << endl; 286 286 exit(1); 287 287 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r660 r664 411 411 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 412 412 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 413 413 414 for (it = interior->mChildren.begin(); it != it_end; ++ it) 415 { 414 416 tstack.push(*it); 417 } 415 418 416 419 } … … 1633 1636 1634 1637 void ViewCellsTree::PropagatePvs(ViewCell *vc) 1635 { 1638 { 1639 ViewCell *viewCell = vc; 1640 1636 1641 // propagate pvs up 1637 while (v c->GetParent())1638 { 1639 v c->GetParent()->GetPvs().Merge(vc->GetPvs());1640 v c = vc->GetParent();1642 while (viewCell->GetParent()) 1643 { 1644 viewCell->GetParent()->GetPvs().Merge(vc->GetPvs()); 1645 viewCell = viewCell->GetParent(); 1641 1646 } 1642 1647 … … 1661 1666 { 1662 1667 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell); 1668 1663 1669 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1664 1670 … … 1677 1683 tqueue.push(mRoot); 1678 1684 mRoot->SetColor(RandomColor(0.3f, 1.0f)); 1685 1679 1686 while (!tqueue.empty()) 1680 1687 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r660 r664 261 261 public: 262 262 263 ViewCellLeaf<T>(): mLeaf(NULL) { }263 ViewCellLeaf<T>(): mLeaf(NULL) { SetActive(); } 264 264 ViewCellLeaf<T>(Mesh *mesh): 265 ViewCell(mesh), mLeaf(NULL) { }265 ViewCell(mesh), mLeaf(NULL) { SetActive(); } 266 266 267 267 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r663 r664 45 45 environment->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry); 46 46 environment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); 47 47 48 bool emptyViewCells = false; 48 49 environment->GetBoolValue("ViewCells.pruneEmptyViewCells", emptyViewCells); 50 mMinPvsSize = emptyViewCells ? 1 : 0; 51 49 52 environment->GetBoolValue("ViewCells.processOnlyValidViewCells", mOnlyValidViewCells); 50 53 … … 58 61 environment->GetBoolValue("ViewCells.exportToFile", mExportViewCells); 59 62 60 61 63 environment->GetIntValue("ViewCells.active", mNumActiveViewCells); 62 64 environment->GetBoolValue("ViewCells.PostProcess.compress", mCompressViewCells); 63 65 environment->GetBoolValue("ViewCells.Visualization.useClipPlane", mUseClipPlaneForViz); 64 65 66 environment->GetBoolValue("ViewCells.PostProcess.merge", mMergeViewCells); 66 67 char samplingBuf[50]; 68 environment->GetStringValue("ViewCells.samplingType", samplingBuf); 69 70 if (strcmp(samplingBuf, "box") == 0) 67 environment->GetBoolValue("ViewCells.evaluateViewCells", mEvaluateViewCells); 68 69 char buf[100]; 70 environment->GetStringValue("ViewCells.samplingType", buf); 71 72 73 if (strcmp(buf, "box") == 0) 71 74 mSamplingType = Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 72 else if (strcmp( samplingBuf, "directional") == 0)75 else if (strcmp(buf, "directional") == 0) 73 76 mSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION; 74 77 75 78 #if 0 76 77 char viewCellsStatsLog[100]; 78 environment->GetStringValue("ViewCells.stats", viewCellsStats); 79 mViewCellsStats.open(viewCellsStatsLog); 79 environment->GetStringValue("ViewCells.stats", buf); 80 mViewCellsStats.open(buf); 80 81 #endif 81 82 82 mMinPvsSize = emptyViewCells ? 1 : 0;83 84 char buf[50];85 83 environment->GetStringValue("ViewCells.Visualization.colorCode", buf); 86 84 … … 94 92 mColorCode = 0; 95 93 96 Debug << "colorCode: " << mColorCode << endl; 94 95 Debug << "***********View Cells options ****************" << endl; 96 Debug << "color code: " << mColorCode << endl; 97 98 Debug << "export rays: " << mExportRays << endl; 99 Debug << "export geometry: " << mExportGeometry << endl; 100 Debug << "max pvs ratio: " << mMaxPvsRatio << endl; 101 102 Debug << "prune empty view cells: " << emptyViewCells << endl; 103 104 Debug << "process only valid view cells: " << mOnlyValidViewCells << endl; 105 Debug << "construction samples: " << mConstructionSamples << endl; 106 Debug << "post process samples: " << mPostProcessSamples << endl; 107 Debug << "post process use rays for merge: " << mUseRaysForMerge << endl; 108 Debug << "visualization samples: " << mVisualizationSamples << endl; 109 Debug << "construction samples per pass: " << mSamplesPerPass << endl; 110 Debug << "export to file: " << mExportViewCells << endl; 111 112 Debug << "active: " << mNumActiveViewCells << endl; 113 Debug << "post process compress: " << mCompressViewCells << endl; 114 Debug << "visualization use clipPlane: " << mUseClipPlaneForViz << endl; 115 Debug << "post process merge: " << mMergeViewCells << endl; 116 Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 117 Debug << "sampling type: " << mSamplingType << endl; 118 119 Debug << endl; 97 120 } 98 121 … … 213 236 const int n = mConstructionSamples; //+initialSamples; 214 237 215 bool dirSamples = false;238 bool dirSamples = mSamplingType; 216 239 217 240 while (numSamples < n) … … 298 321 disposeRays(visualizationSamples, outRays); 299 322 323 if (mEvaluateViewCells) 324 { 325 Debug << "Evaluatating view cells!!!" << endl; 326 EvalViewCellPartition(preprocessor); 327 } 328 else 329 Debug << "No evaluation!!" << endl; 330 300 331 return numSamples; 301 332 } 302 333 303 334 304 void ViewCellsManager::EvalViewCellPartition( )335 void ViewCellsManager::EvalViewCellPartition(Preprocessor *preprocessor) 305 336 { 306 337 int samplesPerPass; … … 308 339 int castSamples = 0; 309 340 341 char s[64]; 342 310 343 environment->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 311 344 environment->GetIntValue("ViewCells.Evaluation.samples", numSamples); 312 345 313 Debug << "view cells evaluation samples per pass: " << samplesPerPass << endl; 314 Debug << "view cells evaluation samples: " << numSamples << endl; 346 char statsPrefix[100]; 347 environment->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 348 349 Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; 350 Debug << "view cell evaluation samples: " << numSamples << endl; 351 Debug << "view cell stats prefix: " << statsPrefix << endl; 352 353 //VssRayContainer outRays; 354 355 int dirSamples = mSamplingType; 356 357 if (0) 358 mViewCellsTree->ResetPvs(); 359 360 cout << "Evaluating view cell partition" << endl; 361 362 ViewCellContainer leaves; 363 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 315 364 316 365 while (castSamples < numSamples) 317 366 { 318 319 } 320 //char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 367 VssRayContainer evaluationSamples; 368 369 const int samplingType = 370 dirSamples ? 371 Preprocessor::DIRECTION_BASED_DISTRIBUTION : 372 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 373 374 //-- construction rays => we use uniform samples for this 375 CastPassSamples(samplesPerPass, samplingType, evaluationSamples); 376 377 castSamples += samplesPerPass; 378 379 cout << "casting " << (int)evaluationSamples.size() << " samples " << endl; 380 381 ComputeSampleContributions(evaluationSamples, true, false); 382 383 cout << "compute new statistics ... "; 384 385 ViewCellContainer::const_iterator it, it_end = leaves.end(); 386 387 for (it = leaves.begin(); it != it_end; ++ it) 388 { 389 mViewCellsTree->PropagatePvs(*it); 390 } 391 392 // output stats 393 sprintf(s, "Stats-%09d-eval.log", castSamples); 394 string fileName = string(statsPrefix) + string(s); 395 396 mViewCellsTree->ExportStats(fileName); 397 398 cout << "finished" << endl; 399 400 disposeRays(evaluationSamples, NULL); 401 } 321 402 } 322 403 … … 446 527 447 528 float sum = 0.0f; 448 for (it = rays.begin(); it != it_end; ++ it) { 449 sum += ComputeSampleContributions(*(*it), addRays, storeViewCells); 450 //ComputeSampleContributions(*(*it), addRays); 451 // sum += (*it)->mPvsContribution; 529 for (it = rays.begin(); it != it_end; ++ it) 530 { 531 sum += ComputeSampleContributions(*(*it), addRays, storeViewCells); 532 //ComputeSampleContributions(*(*it), addRays); 533 // sum += (*it)->mPvsContribution; 452 534 } 535 453 536 return sum; 454 537 } … … 885 968 886 969 CastLineSegment(origin, termination, viewcells); 887 970 888 971 // copy viewcells memory efficiently 889 972 //const bool storeViewcells = !addRays; … … 897 980 ViewCellContainer::const_iterator it = viewcells.begin(); 898 981 899 900 for (; it != viewcells.end(); ++it) { 901 ViewCell *viewcell = *it; 902 if (viewcell->GetValid()) { 903 // if ray not outside of view space 904 float contribution; 905 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 906 ray.mPdf, 907 contribution 908 )) 909 ray.mPvsContribution++; 910 ray.mRelativePvsContribution += contribution; 911 } 912 } 913 914 if (addRays) 915 for (it = viewcells.begin(); it != viewcells.end(); ++it) { 916 ViewCell *viewcell = *it; 917 if (viewcell->GetValid()) { 918 // if ray not outside of view space 919 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 920 } 982 for (; it != viewcells.end(); ++ it) 983 { 984 ViewCell *viewcell = *it; 985 if (viewcell->GetValid()) 986 { 987 // if ray not outside of view space 988 float contribution; 989 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 990 ray.mPdf, 991 contribution)) 992 { 993 ++ ray.mPvsContribution; 994 ray.mRelativePvsContribution += contribution; 995 } 996 } 997 } 998 999 1000 if (addRays) 1001 { 1002 for (it = viewcells.begin(); it != viewcells.end(); ++ it) 1003 { 1004 ViewCell *viewcell = *it; 1005 1006 if (viewcell->GetValid()) 1007 { 1008 // if ray not outside of view space 1009 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 1010 } 1011 } 921 1012 } 922 1013 … … 2471 2562 } 2472 2563 else 2473 { 2474 // we can use the view cells tree hierarchy to get the right set 2564 { // we can use the view cells tree hierarchy to get the right set 2475 2565 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumActiveViewCells); 2476 2566 } … … 2509 2599 2510 2600 Debug << "samples used for vsp bsp subdivision: " << mInitialSamples 2511 << " rays: " << (int)rays.size() << endl;2601 << ", actual rays: " << (int)rays.size() << endl; 2512 2602 2513 2603 GetRaySets(rays, mInitialSamples, constructionRays, &savedRays); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r660 r664 362 362 /** Evaluates worth of current view cell hierarchy. 363 363 */ 364 void EvalViewCellPartition( );364 void EvalViewCellPartition(Preprocessor *preprocessor); 365 365 366 366 protected: … … 478 478 479 479 bool mViewCellsFinished; 480 481 bool mEvaluateViewCells; 480 482 }; 481 483 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r660 r664 569 569 else 570 570 { 571 cerr<<"Wrong view cells type " << name<< endl;571 cerr<<"Wrong view cells type " << name << "!!!" << endl; 572 572 exit(1); 573 573 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r663 r664 37 37 int VspBspTree::sFrontAndBackId = 0; 38 38 39 bool VspBspTraversalData::sBreathFirstSplits = false;40 39 41 40 … … 130 129 environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 131 130 environment->GetBoolValue("VspBspTree.simulateOctree", mSimulateOctree); 132 environment->GetBoolValue("VspBspTree.breathFirstSplits", VspBspTraversalData::sBreathFirstSplits); 131 environment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 132 environment->GetBoolValue("VspBspTree.breathFirstSplits", mBreathFirstSplits); 133 133 134 134 char subdivisionStatsLog[100]; … … 162 162 Debug << "use split cost queue: " << mUseSplitCostQueue << endl; 163 163 Debug << "subdivision stats log: " << subdivisionStatsLog << endl; 164 164 Debug << "use random axis: " << mUseRandomAxis << endl; 165 Debug << "breath first splits: " << mBreathFirstSplits << endl; 166 165 167 166 168 Debug << "Split plane strategy: "; … … 463 465 geom); 464 466 465 tData.mPriority = mBreathFirstSplits ?466 (float)-frontData.mDepth : tData.mPvs * tData.mProbability;467 EvalPriority(tData); 468 467 469 468 470 if (mSimulateOctree) … … 494 496 495 497 long startTime = GetTime(); 496 int nLeaves = 0;497 int nViewCells = 0;498 int nLeaves = 500; 499 int nViewCells = 500; 498 500 499 501 // used for intermediate time measurements and progress … … 538 540 } 539 541 540 if (mCreatedViewCells == nViewCells)542 if (mCreatedViewCells >= nViewCells) 541 543 { 542 544 nViewCells += 500; … … 575 577 geom); 576 578 577 tData.mPriority = mBreathFirstSplits ? 578 (float)-tData.mDepth : tData.mPvs * tData.mProbability; 579 579 580 580 581 // compute first split candidate … … 744 745 tBackData.mMaxCostMisses = maxCostMisses; 745 746 746 ComputePriority(tFrontData);747 ComputePriority(tBackData);747 EvalPriority(tFrontData); 748 EvalPriority(tBackData); 748 749 749 750 if (1) … … 864 865 tFrontData.mMaxCostMisses = maxCostMisses; 865 866 tBackData.mMaxCostMisses = maxCostMisses; 866 867 ComputePriority(tFrontData); 868 ComputePriority(tBackData); 869 870 frontData.mPriority = mBreathFirstSplits ? 871 (float)-frontData.mDepth : frontData.mPvs * frontData.mProbability; 872 backData.mPriority = mBreathFirstSplits ? 873 (float)-backData.mDepth : backData.mPvs * backData.mProbability; 867 874 868 if (1) 875 869 { … … 951 945 952 946 return newNode; 947 } 948 949 950 void VspBspTree::EvalPriority(VspBspTraversalData &tData) const 951 { 952 tData.mPriority = mBreathFirstSplits ? 953 (float)-tData.mDepth : tData.mPvs * tData.mProbability; 953 954 } 954 955 … … 1356 1357 int sAxis = 0; 1357 1358 1358 bool useSpecialAxis = false; 1359 1360 if (mSimulateOctree) 1361 { 1359 bool useSpecialAxis = mOnlyDrivingAxis || mUseRandomAxis || mSimulateOctree; 1360 1361 // use some kind of specialised fixed axis 1362 if (mOnlyDrivingAxis) 1363 sAxis = box.Size().DrivingAxis(); 1364 else if (mUseRandomAxis) 1365 sAxis = Random(3); 1366 else if (mSimulateOctree) 1362 1367 sAxis = tData.mAxis; 1363 useSpecialAxis = true; 1364 } 1365 else if (mUseRandomAxis) 1366 { 1367 sAxis = Random(3); 1368 useSpecialAxis = true; 1369 } 1370 else if (mOnlyDrivingAxis) 1371 { 1372 sAxis = box.Size().DrivingAxis(); 1373 useSpecialAxis = true; 1374 } 1368 1375 1369 1376 1370 for (axis = 0; axis < 3; ++ axis) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r663 r664 69 69 float mPriority; 70 70 71 static bool sBreathFirstSplits; 72 71 73 72 /** Returns average ray contribution. 74 73 */ … … 88 87 mGeometry(NULL), 89 88 mMaxCostMisses(0), 90 mIsKdNode(false) 89 mIsKdNode(false), 90 mPriority(0) 91 91 {} 92 92 … … 106 106 mGeometry(geom), 107 107 mMaxCostMisses(0), 108 mIsKdNode(false) 108 mIsKdNode(false), 109 mPriority(0) 109 110 {} 110 111 … … 128 129 float GetCost() const 129 130 { 130 if (sBreathFirstSplits) 131 return mPvs * mProbability; 132 else 133 return (float) (-mDepth); // for kd tree 131 return mPriority; 134 132 } 135 133 … … 388 386 float &pBack) const; 389 387 388 /** Evaluates candidate for splitting. 389 */ 390 390 void EvalSplitCandidate(VspBspTraversalData &tData, VspBspSplitCandidate &splitData); 391 392 /** Computes priority of the traversal data and stores it in tData. 393 */ 394 void EvalPriority(VspBspTraversalData &tData) const; 391 395 392 396 float EvalRenderCostDecrease(const Plane3 &candidatePlane, … … 790 794 bool mSimulateOctree; 791 795 792 int mBreathFirstSplits; 796 /// if we should use breath first priority for the splits 797 bool mBreathFirstSplits; 793 798 794 799 private:
Note: See TracChangeset
for help on using the changeset viewer.