Changeset 664 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 02/27/06 18:39:47 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.