Changeset 1444 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 09/21/06 12:16:04 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1421 r1444 348 348 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 349 349 350 351 /////////////////////////////////////////// 352 //-- Initial hierarchy construction finished 350 // collect view cells and compute statistics 351 ResetViewCells(); 352 353 354 /////////////////// 355 //-- Initial hierarchy construction finished. 353 356 //-- We can do some stats and visualization 354 357 355 ResetViewCells();356 357 if (0) //-- optionallyexport initial view cell partition358 {359 Debug << "\nView cells after initial sampling:\n"<< mCurrentViewCellsStats << endl;358 if (0) 359 { 360 //-- export initial view cell partition 361 Debug << "\nView cells after initial sampling:\n" 362 << mCurrentViewCellsStats << endl; 360 363 361 364 const string filename("viewcells.wrl"); … … 400 403 401 404 const int samplingType = mSamplingType; 402 /*dirSamples ? 403 Preprocessor::DIRECTION_BASED_DISTRIBUTION : 404 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION;*/ 405 //dirSamples ? Preprocessor::DIRECTION_BASED_DISTRIBUTION : Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION; 405 406 406 407 if (0) dirSamples = !dirSamples; // toggle sampling method … … 445 446 //-- post processing of the initial construction 446 447 //-- We can bottom-up merge the view cells in this step 447 448 449 // we can additionally cast some post processing sample rays. 450 // These rays can be used to store the view cells with the rays 448 //-- We can additionally cast some post processing sample rays. 449 //-- These rays can be used to store the view cells with the rays 450 451 451 VssRayContainer postProcessSamples; 452 452 cout << "casting " << mPostProcessSamples << " post processing samples ... "; … … 457 457 cout << "starting post processing and visualization" << endl; 458 458 459 // store view cells for post processing?459 // store view cells with rays for post processing? 460 460 const bool storeViewCells = true; 461 461 … … 480 480 EvalViewCellPartition(); 481 481 } 482 483 482 484 483 ///////////////// … … 497 496 ComputeSampleContributions(visualizationSamples, true, storeViewCells); 498 497 499 // differentvisualizations498 // various visualizations 500 499 Visualize(preprocessor->mObjects, visualizationSamples); 501 500 502 501 disposeRays(visualizationSamples, outRays); 503 502 } 503 504 // recalculate view cells 505 EvaluateViewCellsStats(); 504 506 505 507 return numSamples; … … 614 616 long startTime = GetTime(); 615 617 616 //vm->PrepareLoadedViewCells();617 618 vm->ResetViewCells(); 618 619 … … 620 621 vm->mMaxPvsSize = (int)objects->size(); 621 622 622 // create the meshes and compute volumes623 623 if (finalizeViewCells) 624 624 { 625 // create the meshes and compute volumes 625 626 vm->FinalizeViewCells(true); 626 627 vm->mViewCellsTree->AssignRandomColors(); … … 901 902 startTime = GetTime(); 902 903 903 cout << "compute new statistics ... "; 904 Debug << "compute new statistics ... "; 905 904 cout << "compute new statistics ... " << endl; 905 906 906 //-- propagate pvs or pvs size information 907 907 ObjectPvs pvs; … … 916 916 timeDiff = TimeDiff(startTime, GetTime()); 917 917 cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 918 Debug << " finished in " << timeDiff * 1e-3 << " secs" << endl;918 Debug << "statistis compted in " << timeDiff * 1e-3 << " secs" << endl; 919 919 920 920 disposeRays(evaluationSamples, NULL); … … 922 922 923 923 924 ////////////7 924 925 //-- histogram 925 926 … … 1286 1287 bool ViewCellsManager::ViewPointValid(const Vector3 &viewPoint) const 1287 1288 { 1288 1289 return mViewSpaceBox.IsInside(viewPoint);1290 else 1291 { 1292 if (!mViewSpaceBox.IsInside(viewPoint))1293 return false;1294 1295 ViewCell *viewcell = GetViewCell(viewPoint);1296 1297 if (!viewcell || !viewcell->GetValid())1298 return false; 1299 } 1300 1301 return true; 1302 } 1303 1304 1305 float 1306 ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 1307 const bool addRays, 1308 const bool storeViewCells1309 1310 { 1311 1312 1313 return 0.0f;1314 1315 VssRayContainer::const_iterator it, it_end = rays.end();1316 1317 float sum = 0.0f;1318 1319 1320 1321 1322 1323 1324 1289 if (!ViewCellsConstructed()) 1290 { 1291 return mViewSpaceBox.IsInside(viewPoint); 1292 } 1293 else 1294 { 1295 if (!mViewSpaceBox.IsInside(viewPoint)) 1296 return false; 1297 1298 ViewCell *viewcell = GetViewCell(viewPoint); 1299 1300 if (!viewcell || !viewcell->GetValid()) 1301 return false; 1302 } 1303 1304 return true; 1305 } 1306 1307 1308 float ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 1309 const bool addRays, 1310 const bool storeViewCells) 1311 { 1312 // view cells not yet constructed 1313 if (!ViewCellsConstructed()) 1314 return 0.0f; 1315 1316 float sum = 0.0f; 1317 1318 VssRayContainer::const_iterator it, it_end = rays.end(); 1319 1320 for (it = rays.begin(); it != it_end; ++ it) 1321 { 1322 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 1323 } 1324 1325 return sum; 1325 1326 } 1326 1327 … … 1345 1346 float &avgRenderCost) 1346 1347 { 1347 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1348 1348 //////////// 1349 1349 //-- compute expected value 1350 1350 1351 totalRenderCost = 0; 1351 1352 totalPvs = 0; 1353 1354 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1352 1355 1353 1356 for (it = mViewCells.begin(); it != it_end; ++ it) … … 1364 1367 1365 1368 1369 /////////// 1366 1370 //-- compute standard defiation 1371 1367 1372 variance = 0; 1368 1373 deviation = 0; … … 1727 1732 CollectViewCells(); 1728 1733 1729 1730 1734 // stats are computed once more 1731 mCurrentViewCellsStats.Reset();1732 1735 EvaluateViewCellsStats(); 1733 1736 … … 2554 2557 2555 2558 Debug << mBspTree->GetStatistics() << endl; 2556 2557 //EvaluateViewCellsStats();2558 2559 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 2559 2560 … … 2630 2631 int vcSize = 0; 2631 2632 int pvsSize = 0; 2632 2633 2634 ////////////////// /////2633 2634 2635 ////////////////// 2635 2636 //-- merge leaves of the view cell hierarchy 2636 2637 … … 2668 2669 2669 2670 //////////////////////// 2670 //-- visualization and statistics 2671 2672 // export statistics after merge 2671 //-- visualization and statistics after merge 2672 2673 2673 if (1) 2674 2674 { … … 2686 2686 if (1) // export merged view cells 2687 2687 { 2688 mColorCode = 0; // hack color code2688 mColorCode = 0; // use random colors 2689 2689 Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl"); 2690 2690 2691 2692 2691 cout << "exporting view cells after merge ... "; 2693 2692 … … 3241 3240 // create the view cells 3242 3241 mKdTree->CreateAndCollectViewCells(mViewCells); 3243 3244 3242 // cast rays 3245 3243 ComputeSampleContributions(rays, true, false); … … 3623 3621 cout << "finished" << endl; 3624 3622 3623 ///////////////// 3625 3624 //-- stats after construction 3626 3625 … … 3631 3630 3632 3631 3632 ////////////////////// 3633 //-- recast rest of rays 3633 3634 startTime = GetTime(); 3634 3635 3635 3636 cout << "Computing remaining ray contributions ... "; 3636 3637 3637 // recast rest of rays3638 3638 if (SAMPLE_AFTER_SUBDIVISION) 3639 3639 ComputeSampleContributions(savedRays, true, false); … … 3646 3646 cout << "construction finished" << endl; 3647 3647 3648 3649 3648 if (0) 3650 3649 { … … 3696 3695 } 3697 3696 3698 //-- stats and visualizations3699 cout << "finished merging" << endl;3700 3697 cout << "merged view cells in " 3701 3698 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; … … 3704 3701 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 3705 3702 3703 3704 ////////////////// 3705 //-- stats and visualizations 3706 3706 3707 3707 int savedColorCode = mColorCode; … … 3710 3710 ResetViewCells(); 3711 3711 Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 3712 3713 //BspLeaf::NewMail(); 3712 3714 3713 if (1) // export merged view cells 3715 3714 { … … 3892 3891 if (0) FinalizeViewCells(false); 3893 3892 3894 ////////// ////////3893 ////////// 3895 3894 //-- merge the individual view cells 3896 3895 MergeViewCells(postProcessRays, objects); 3897 3896 3898 ///////////////////////////////// 3899 //-- refines the merged view cells 3897 // refines the merged view cells 3900 3898 if (0) RefineViewCells(postProcessRays, objects); 3901 3899 3902 ////////////////// 3900 3901 /////////// 3903 3902 //-- render simulation after merge + refine 3904 3903 … … 3934 3933 // compute final meshes and volume / area 3935 3934 if (1) FinalizeViewCells(true); 3936 cout << "here09*******************" << endl; 3935 3937 3936 // write view cells to disc 3938 3937 if (0 && mExportViewCells) 3939 { cout << "here77*******************" << endl;3938 { 3940 3939 char filename[100]; 3941 3940 Environment::GetSingleton()->GetStringValue("ViewCells.filename", filename); … … 4793 4792 } 4794 4793 4795 // print subdivision statistics 4794 //////////// 4795 //-- print satistics for subdivision and view cells 4796 4796 4797 Debug << endl << endl << *mHierarchyManager << endl; 4797 //mHierarchyManager->PrintHierarchyStatistics(Debug); 4798 4799 ResetViewCells(); 4800 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 4798 4801 4799 4802 if (0) … … 4803 4806 } 4804 4807 4805 // print view cell statistics 4806 ResetViewCells(); 4807 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; 4808 4809 4808 4809 ////////// 4810 //-- recast rest of rays 4811 4810 4812 const long startTime = GetTime(); 4811 4813 cout << "Computing remaining ray contributions ... "; 4812 4814 4813 // recast rest of rays4814 4815 if (SAMPLE_AFTER_SUBDIVISION) 4815 4816 ComputeSampleContributions(savedRays, true, false); … … 5487 5488 5488 5489 // for directional sampling it is important to count only contributions 5489 // made in one direction! !!5490 // the other contributions of this sample will be counted for the op osite ray!5490 // made in one direction! 5491 // the other contributions of this sample will be counted for the opposite ray! 5491 5492 #if SAMPLE_ORIGIN_OBJECTS 5492 5493 if (ray.mOriginObject && … … 5590 5591 mViewCellsTree->ResetPvs(); 5591 5592 } 5592 else // start from current sampless 5593 { 5593 else 5594 { 5595 // start from current sampless 5594 5596 // statistics before casting more samples 5595 5597 cout << "compute new statistics ... ";
Note: See TracChangeset
for help on using the changeset viewer.