Changeset 1444 for GTP/trunk/Lib
- Timestamp:
- 09/21/06 12:16:04 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1421 r1444 529 529 ); 530 530 531 if ( 0&& terminationCriteriaMet)531 if (1 && terminationCriteriaMet) 532 532 { 533 533 Debug << "bvh global termination criteria met:" << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1421 r1444 1670 1670 RegisterOption("Preprocessor.pvsRenderErrorSamples", 1671 1671 optInt, 1672 "p vsRenderErrorSamples=",1672 "preprocessor_pvs_rendererror_samples=", 1673 1673 "10000"); 1674 1674 … … 2427 2427 optFloat, 2428 2428 "hierarchy_term_min_global_cost_ratio=", 2429 "0. 9");2429 "0.000000001"); 2430 2430 2431 2431 RegisterOption("Hierarchy.Termination.globalCostMissTolerance", -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1422 r1444 234 234 (0 235 235 || (mHierarchyStats.Leaves() >= mTermMaxLeaves) 236 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance)236 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 237 237 ||(candidate->GlobalTerminationCriteriaMet()) 238 238 ); 239 239 240 if ( 0&& terminationCriteriaMet)240 if (1 && terminationCriteriaMet) 241 241 { 242 242 Debug << "hierarchy global termination criteria met:" << endl; … … 382 382 const bool vspSplit = (sc->Type() == SubdivisionCandidate::VIEW_SPACE); 383 383 384 if (!globalTerminationCriteriaMet) 385 { 386 // cost ratio of cost decrease / totalCost 387 const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost; 388 Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 389 390 if (costRatio < mTermMinGlobalCostRatio) 391 { 392 ++ mGlobalCostMisses; 393 } 394 395 mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 396 } 397 384 398 if (vspSplit) 385 399 { … … 481 495 { 482 496 mCurrentCandidate = NextSubdivisionCandidate(); 483 mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 484 485 // cost ratio of cost decrease / totalCost 486 const float costRatio = mCurrentCandidate->GetRenderCostDecrease() / mTotalCost; 487 488 //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 489 if (costRatio < mTermMinGlobalCostRatio) 490 { 491 ++ mGlobalCostMisses; 492 } 493 497 494 498 /////////////////// 495 499 //-- subdivide leaf node … … 498 502 { 499 503 cout << mCurrentCandidate->Type() << " "; 500 if (0) cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 504 if (0) cout << "subdividing candidate " << ++ i << " of type " 505 << mCurrentCandidate->Type() << endl; 501 506 mHierarchyStats.nodes += 2; 502 507 -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1415 r1444 537 537 { 538 538 // matt: TODO 539 return ( 540 (mOspStats.Leaves() >= mTermMaxLeaves)541 // mOutOfMemory ||542 //(mGlobalCostMisses >= mTermGlobalCostMissTolerance)539 return (0 540 || (mOspStats.Leaves() >= mTermMaxLeaves) 541 //|| mOutOfMemory 542 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 543 543 ); 544 544 } -
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 ... "; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1421 r1444 62 62 { 63 63 MailablePvsData *vdata = obj->mViewCellPvs.Find(vc); 64 //return false; 64 65 65 if (vdata) 66 66 { … … 128 128 129 129 app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 130 //app << "#N_PVS: " << pvs << endl; 131 132 //app << "#N_MAXOBJECTREFS ( Max number of object refs / leaf )\n" << maxObjectRefs << "\n"; 130 133 131 134 132 app << "========== END OF VspTree statistics ==========\n"; … … 202 200 mTreeValid = v; 203 201 } 202 204 203 205 204 … … 372 371 mHierarchyManager(NULL) 373 372 { 373 mLocalSubdivisionCandidates = new vector<SortableEntry>; 374 374 375 bool randomize = false; 375 376 Environment::GetSingleton()->GetBoolValue("VspTree.Construction.randomize", randomize); … … 377 378 Randomize(); // initialise random generator for heuristics 378 379 380 char subdivisionStatsLog[100]; 381 Environment::GetSingleton()->GetStringValue("VspTree.subdivisionStats", subdivisionStatsLog); 382 mSubdivisionStats.open(subdivisionStatsLog); 383 384 ///////////// 379 385 //-- termination criteria for autopartition 386 380 387 Environment::GetSingleton()->GetIntValue("VspTree.Termination.maxDepth", mTermMaxDepth); 381 388 Environment::GetSingleton()->GetIntValue("VspTree.Termination.minPvs", mTermMinPvs); … … 386 393 Environment::GetSingleton()->GetIntValue("VspTree.Termination.missTolerance", mTermMissTolerance); 387 394 Environment::GetSingleton()->GetIntValue("VspTree.Termination.maxViewCells", mMaxViewCells); 388 389 //-- max cost ratio for early tree termination 395 // max cost ratio for early tree termination 390 396 Environment::GetSingleton()->GetFloatValue("VspTree.Termination.maxCostRatio", mTermMaxCostRatio); 391 397 … … 393 399 Environment::GetSingleton()->GetIntValue("VspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 394 400 401 Environment::GetSingleton()->GetFloatValue("VspTree.maxStaticMemory", mMaxMemory); 402 403 404 ////////////// 395 405 //-- factors for bsp tree split plane heuristics 406 396 407 Environment::GetSingleton()->GetFloatValue("VspTree.Termination.ct_div_ci", mCtDivCi); 397 398 //-- partition criteria399 408 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.epsilon", mEpsilon); 409 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.minBand", mMinBand); 410 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.maxBand", mMaxBand); 411 Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 412 400 413 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 401 414 402 415 // if only the driving axis is used for axis aligned split 403 416 Environment::GetSingleton()->GetBoolValue("VspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 404 405 Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests);406 Environment::GetSingleton()->GetFloatValue("VspTree.maxStaticMemory", mMaxMemory);407 408 417 Environment::GetSingleton()->GetBoolValue("VspTree.useCostHeuristics", mUseCostHeuristics); 409 418 Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis); 410 411 //Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvsForHeuristics", mUseKdPvsForHeuristics); 412 413 char subdivisionStatsLog[100]; 414 Environment::GetSingleton()->GetStringValue("VspTree.subdivisionStats", subdivisionStatsLog); 415 mSubdivisionStats.open(subdivisionStatsLog); 416 417 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.minBand", mMinBand); 418 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.maxBand", mMaxBand); 419 420 419 420 421 ////////////// 421 422 //-- debug output 422 423 … … 445 446 Debug << "maxband: " << mMaxBand << endl; 446 447 447 mLocalSubdivisionCandidates = new vector<SortableEntry>;448 449 448 Debug << endl; 450 449 } … … 565 564 ); 566 565 567 if ( 0&& terminationCriteriaMet)566 if (1 && terminationCriteriaMet) 568 567 { 569 568 Debug << "vsp global termination criteria met:" << endl;
Note: See TracChangeset
for help on using the changeset viewer.