- Timestamp:
- 08/28/06 03:42:51 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj
r1276 r1288 87 87 OmitFramePointers="TRUE" 88 88 EnableFiberSafeOptimizations="TRUE" 89 OptimizeForProcessor=" 3"89 OptimizeForProcessor="0" 90 90 OptimizeForWindowsApplication="TRUE" 91 91 AdditionalIncludeDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Dependencies\include";..\include;..\..\..\OnlineCullingCHC\include;..\..\..\Preprocessing\src" -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/GtpVisibility.vcproj
r1239 r1288 62 62 <Tool 63 63 Name="VCCLCompilerTool" 64 GlobalOptimizations="TRUE" 65 FavorSizeOrSpeed="1" 66 OmitFramePointers="TRUE" 64 67 OptimizeForWindowsApplication="TRUE" 65 68 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\OgreMain\include";..\..\Preprocessing\src" -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1287 r1288 196 196 197 197 //-- termination criteria for autopartition 198 Environment::GetSingleton()->GetIntValue(" OspTree.Termination.maxDepth", mTermMaxDepth);199 Environment::GetSingleton()->GetIntValue(" OspTree.Termination.maxLeaves", mTermMaxLeaves);200 Environment::GetSingleton()->GetIntValue(" OspTree.Termination.minObjects", mTermMinObjects);201 Environment::GetSingleton()->GetFloatValue(" OspTree.Termination.minProbability", mTermMinProbability);202 203 Environment::GetSingleton()->GetIntValue(" OspTree.Termination.missTolerance", mTermMissTolerance);198 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.maxDepth", mTermMaxDepth); 199 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.maxLeaves", mTermMaxLeaves); 200 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.minObjects", mTermMinObjects); 201 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minProbability", mTermMinProbability); 202 203 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.missTolerance", mTermMissTolerance); 204 204 205 205 //-- max cost ratio for early tree termination 206 Environment::GetSingleton()->GetFloatValue(" OspTree.Termination.maxCostRatio", mTermMaxCostRatio);207 208 Environment::GetSingleton()->GetFloatValue(" OspTree.Termination.minGlobalCostRatio",206 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.maxCostRatio", mTermMaxCostRatio); 207 208 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minGlobalCostRatio", 209 209 mTermMinGlobalCostRatio); 210 210 Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 211 211 212 212 //-- factors for bsp tree split plane heuristics 213 Environment::GetSingleton()->GetFloatValue(" OspTree.Termination.ct_div_ci", mCtDivCi);213 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.ct_div_ci", mCtDivCi); 214 214 215 215 //-- partition criteria 216 Environment::GetSingleton()->GetFloatValue(" OspTree.Construction.epsilon", mEpsilon);216 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.epsilon", mEpsilon); 217 217 218 218 // if only the driving axis is used for axis aligned split 219 Environment::GetSingleton()->GetBoolValue(" OspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis);220 Environment::GetSingleton()->GetFloatValue(" OspTree.maxStaticMemory", mMaxMemory);221 Environment::GetSingleton()->GetBoolValue(" OspTree.useCostHeuristics", mUseCostHeuristics);219 Environment::GetSingleton()->GetBoolValue("BvHierarchy.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 220 Environment::GetSingleton()->GetFloatValue("BvHierarchy.maxStaticMemory", mMaxMemory); 221 Environment::GetSingleton()->GetBoolValue("BvHierarchy.useCostHeuristics", mUseCostHeuristics); 222 222 223 223 224 224 char subdivisionStatsLog[100]; 225 Environment::GetSingleton()->GetStringValue(" OspTree.subdivisionStats", subdivisionStatsLog);225 Environment::GetSingleton()->GetStringValue("BvHierarchy.subdivisionStats", subdivisionStatsLog); 226 226 mSubdivisionStats.open(subdivisionStatsLog); 227 227 228 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.splitBorder", mSplitBorder); 229 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 228 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.splitBorder", mSplitBorder); 229 Environment::GetSingleton()->GetFloatValue( 230 "BvHierarchy.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 230 231 231 232 … … 279 280 // add the new nodes to the tree 280 281 BvhInterior *node = new BvhInterior(tData.mBoundingBox, leaf->GetParent()); 281 282 cout << "here55 " << tData.mBoundingBox << " | " << node->GetBoundingBox() << endl; 282 //cout << "bbox: " << tData.mBoundingBox << endl; 283 283 284 284 285 //-- the front and back traversal data is filled with the new values … … 288 289 frontData.mBoundingBox = ComputeBoundingBox(frontObjects, &(tData.mBoundingBox)); 289 290 backData.mBoundingBox = ComputeBoundingBox(backObjects, &(tData.mBoundingBox)); 290 //RemoveParentViewCellsPvs(leaf, *tData.mRays); 291 291 292 292 ///////////// 293 293 //-- create front and back leaf … … 317 317 ++ mBvhStats.splits; 318 318 319 //UpdateViewCellsPvs(front, *frontData.mRays);320 //UpdateViewCellsPvs(back, *backData.mRays);321 319 322 320 //////////////////////////////////// 323 324 //ProcessMultipleRefs(front);325 //ProcessMultipleRefs(back);326 321 327 322 frontData.mNode = front; … … 346 341 const bool globalCriteriaMet) 347 342 { 348 BvhSubdivisionCandidate *sc = dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 343 BvhSubdivisionCandidate *sc = 344 dynamic_cast<BvhSubdivisionCandidate *>(splitCandidate); 349 345 BvhTraversalData &tData = sc->mParentData; 350 346 … … 410 406 } 411 407 412 //-- cleanup 413 tData.Clear(); 408 tData.Clear(); // cleanup 414 409 415 410 return newNode; … … 425 420 splitCandidate.mBackObjects); 426 421 427 const bool success = ratio < mTermMaxCostRatio;428 429 422 BvhLeaf *leaf = splitCandidate.mParentData.mNode; 430 423 424 // cost ratio violated? 425 const bool maxCostRatioViolated = ratio < mTermMaxCostRatio; 426 427 splitCandidate.mMaxCostMisses = maxCostRatioViolated ? 428 splitCandidate.mParentData.mMaxCostMisses : 429 splitCandidate.mParentData.mMaxCostMisses + 1; 430 431 431 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 432 433 432 const float oldRenderCost = 434 433 splitCandidate.mParentData.mProbability * (float)leaf->mObjects.size() / viewSpaceVol; … … 443 442 const float renderCostDecr = oldRenderCost - newRenderCost; 444 443 445 Debug << "!!render cost decr: " << renderCostDecr << endl;444 //Debug << "render cost decr: " << renderCostDecr << endl; 446 445 splitCandidate.SetRenderCostDecrease(renderCostDecr); 447 446 … … 458 457 // compute global decrease in render cost 459 458 splitCandidate.SetPriority(priority); 460 461 splitCandidate.mMaxCostMisses =462 success ? splitCandidate.mParentData.mMaxCostMisses :463 splitCandidate.mParentData.mMaxCostMisses + 1;464 459 } 465 460 … … 468 463 { 469 464 // matt: TODO 470 return ( 471 //(data.mNode->mObjects.size() < mTermMinObjects) ||472 //(data.mProbability <= mTermMinProbability) ||473 (data.mDepth >= mTermMaxDepth)465 return ( 0 466 || (data.mNode->mObjects.size() < mTermMinObjects) 467 || (data.mProbability <= mTermMinProbability) 468 || (data.mDepth >= mTermMaxDepth) 474 469 ); 475 470 } … … 479 474 { 480 475 // matt: TODO 481 return ( 482 (mBvhStats.Leaves() >= mTermMaxLeaves)483 //mOutOfMemory ||484 // (mGlobalCostMisses >= mTermGlobalCostMissTolerance)476 return (0 477 || (mBvhStats.Leaves() >= mTermMaxLeaves) 478 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 479 //|| mOutOfMemory 485 480 ); 486 481 } … … 498 493 ++ mBvhStats.maxDepthNodes; 499 494 //Debug << "new max depth: " << mVspStats.maxDepthNodes << endl; 495 } 496 497 if (data.mDepth < mTermMaxDepth) 498 { 499 ++ mBvhStats.minDepthNodes; 500 500 } 501 501 … … 506 506 mBvhStats.accumDepth += data.mDepth; 507 507 508 // if ((int)(leaf->mObjects.size()) < mTermMinCost)509 // ++ mOspStats.minCostNodes;508 if ((int)(leaf->mObjects.size()) < mTermMinObjects) 509 ++ mBvhStats.minObjectsNodes; 510 510 511 511 if ((int)(leaf->mObjects.size()) > mBvhStats.maxObjectRefs) … … 914 914 915 915 916 void BvHierarchy::ClassifyViewCells(const ViewCellContainer &viewCells,917 const bool isFront) const918 {919 int mailed = 0;920 ViewCellContainer::const_iterator vit, vit_end = viewCells.end();921 922 // mail view cell923 for (vit = viewCells.begin(); vit != vit_end; ++ vit)924 {925 ViewCell *vc = *vit;926 927 if (isFront)928 {929 if (!vc->Mailed())930 {931 vc->Mail();932 //Debug << " " << vc->mMailBox << endl;933 ++ mailed;934 }935 }936 else937 {938 if (vc->Mailed())939 {940 vc->Mail(2);941 //Debug << " " << vc->mMailBox << endl;942 ++ mailed;943 }944 else if (!vc->Mailed(1) && !vc->Mailed(2))945 {946 vc->Mail(1);947 //Debug << " " << vc->mMailBox << endl;948 ++ mailed;949 }950 951 }952 }953 954 Debug << "mailed " << mailed << " view cells " << endl;955 }956 957 958 916 float BvHierarchy::EvalRenderCost(const BvhTraversalData &tData, 959 917 const ObjectContainer &objectsFront, … … 982 940 return newRenderCost; 983 941 } 984 985 986 /*float BvHierarchy::EvalRenderCostDecrease(const BvhTraversalData &tData,987 const ObjectContainer &objectsFront,988 const ObjectContainer &objectsBack,989 float &normalizedOldRenderCost) const990 {991 BvhLeaf *leaf = tData.mNode;992 993 // probability that view point lies in a view cell which sees this node994 float pOverall = 0;995 float pFront = 0;996 float pBack = 0;997 float pFrontAndBack = 0;998 999 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume();1000 1001 ViewCellContainer collectedViewCells;1002 ViewCellContainer viewCellsFront, viewCellsBack;1003 1004 // the view cells seen from the front bv1005 1006 CollectViewCells(objectsFront, viewCellsFront);1007 // the view cells seen from the back bv1008 CollectViewCells(objectsBack, viewCellsBack);1009 // the view cells seen from both bvs1010 // note: could be evaluated simpler1011 CollectViewCells(leaf->mObjects, collectedViewCells);1012 1013 1014 // sum up volume seen from the objects of left and right children1015 // => the volume is the weight for the render cost equation1016 1017 ViewCell::NewMail(3);1018 ClassifyViewCells(viewCellsFront, true);1019 ClassifyViewCells(viewCellsBack, false);1020 1021 ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end();1022 1023 // evaluate view cells volume contribution with respect to the mail id1024 for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit)1025 {1026 ViewCell *vc = *vit;1027 if (vc->Mailed())1028 pFront += vc->GetVolume();1029 else if (vc->Mailed(1))1030 pBack += vc->GetVolume();1031 else if (vc->Mailed(2))1032 pFrontAndBack += vc->GetVolume();1033 }1034 1035 const int totalObjects = (int)leaf->mObjects.size();1036 const int nObjectsFront = (int)objectsFront.size();1037 const int nObjectsBack = (int)objectsBack.size();1038 1039 // these are non-overlapping sets1040 pOverall = pFront + pBack + pFrontAndBack;1041 1042 //-- pvs rendering heuristics1043 const float oldRenderCost = pOverall * totalObjects;1044 const float newRenderCost = nObjectsFront * pFront +1045 nObjectsBack * pBack +1046 totalObjects * pFrontAndBack;1047 1048 // normalize volume with view space volume1049 const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol;1050 1051 Debug << "\n(((( eval render cost decrease ))))" << endl1052 << "back objects: " << nObjectsBack << " front objects " << nObjectsFront << " total objects: " << totalObjects << endl1053 << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol1054 << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << pOverall / viewSpaceVol << endl1055 << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl1056 << "render cost decrease: " << renderCostDecrease << endl;1057 1058 normalizedOldRenderCost = oldRenderCost / viewSpaceVol;1059 1060 return renderCostDecrease;1061 }*/1062 942 1063 943 … … 1469 1349 #endif 1470 1350 1471 // create osptraversal data1351 // create bvh traversal data 1472 1352 BvhTraversalData oData(bvhleaf, 0, mBoundingBox, prop); 1473 1353 … … 1503 1383 void BvhStatistics::Print(ostream &app) const 1504 1384 { 1505 app << "=========== OspTreestatistics ===============\n";1385 app << "=========== BvHierarchy statistics ===============\n"; 1506 1386 1507 1387 app << setprecision(4); … … 1517 1397 app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits << endl; 1518 1398 1519 1399 app << "#N_PMINDEPTHLEAVES ( Percentage of leaves at minimum depth )\n" 1400 << minDepthNodes * 100 / (double)Leaves() << endl; 1401 1520 1402 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n" 1521 1403 << maxDepthNodes * 100 / (double)Leaves() << endl; 1522 1404 1523 app << "#N_PMINPVSLEAVES ( Percentage of leaves with mininimal PVS )\n"1524 << minPvsNodes * 100 / (double)Leaves() << endl;1525 1526 1405 app << "#N_MAXCOSTNODES ( Percentage of leaves with terminated because of max cost ratio )\n" 1527 1406 << maxCostNodes * 100 / (double)Leaves() << endl; … … 1530 1409 << minProbabilityNodes * 100 / (double)Leaves() << endl; 1531 1410 1411 app << "#N_PMINOBJECTSLEAVES ( Percentage of leaves with mininum objects )\n" 1412 << minObjectsNodes * 100 / (double)Leaves() << endl; 1413 1532 1414 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 1533 1415 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1287 r1288 55 55 // minimum depth nodes 56 56 int minDepthNodes; 57 // max depth nodes 58 int minPvsNodes; 59 // nodes with minimum PVS 60 int minRaysNodes; 61 // max ray contribution nodes 62 int maxRayContribNodes; 57 // nodes with minimum objects 58 int minObjectsNodes; 63 59 // minimum area nodes 64 60 int minProbabilityNodes; … … 99 95 accumDepth = 0; 100 96 maxDepthNodes = 0; 101 minPvsNodes = 0; 102 minRaysNodes = 0; 103 maxRayContribNodes = 0; 97 minObjectsNodes = 0; 104 98 minProbabilityNodes = 0; 105 99 maxCostNodes = 0; … … 699 693 bool IsObjectInLeaf(BvhLeaf *, Intersectable *object) const; 700 694 701 /** Classifies view cells using the mail id.702 0 = front bv, 1 = back bv, 2 = both bvs703 */704 void ClassifyViewCells(705 const ViewCellContainer &objects,706 const bool isFront) const;707 708 695 SubdivisionCandidate *PrepareConstruction( 709 696 const VssRayContainer &sampleRays, 710 697 const ObjectContainer &objects 711 //,AxisAlignedBox3 *forcedObjectSpace712 698 ); 713 699 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1287 r1288 2237 2237 2238 2238 2239 /***************************************************************************/ 2240 /* Object space partition tree related options*/2241 /* **************************************************************************/2242 2239 2240 /***********************************************************************/ 2241 /* Object space partition tree related options */ 2242 /***********************************************************************/ 2243 2243 2244 2244 RegisterOption("OspTree.Construction.randomize", 2245 optBool,2246 "osp_construction_randomize=",2247 "false");2245 optBool, 2246 "osp_construction_randomize=", 2247 "false"); 2248 2248 2249 2249 RegisterOption("OspTree.Termination.maxDepth", … … 2265 2265 optFloat, 2266 2266 "osp_term_min_objects=", 2267 "0.000 1");2267 "0.00001"); 2268 2268 2269 2269 RegisterOption("OspTree.Termination.missTolerance", 2270 2270 optInt, 2271 2271 "osp_term_miss_tolerance=", 2272 " 4");2272 "8"); 2273 2273 2274 2274 RegisterOption("OspTree.Termination.maxCostRatio", … … 2293 2293 2294 2294 RegisterOption("OspTree.Construction.epsilon", 2295 2296 2297 2295 optFloat, 2296 "osp_construction_epsilon=", 2297 "0.00001"); 2298 2298 2299 2299 // if only the driving axis is used for axis aligned split 2300 2300 RegisterOption("OspTree.splitUseOnlyDrivingAxis", 2301 2302 2303 2301 optBool, 2302 "osp_split_only_driving_axis=", 2303 "false"); 2304 2304 2305 2305 RegisterOption("OspTree.maxStaticMemory", 2306 optFloat,2307 "osp_max_static_mem=",2308 "8.0");2306 optFloat, 2307 "osp_max_static_mem=", 2308 "8.0"); 2309 2309 2310 2310 RegisterOption("OspTree.useCostHeuristics", 2311 optBool,2312 "osp_use_cost_heuristics=",2313 "true");2311 optBool, 2312 "osp_use_cost_heuristics=", 2313 "true"); 2314 2314 2315 2315 RegisterOption("OspTree.subdivisionStats", … … 2324 2324 2325 2325 RegisterOption("OspTree.Construction.renderCostDecreaseWeight", 2326 optFloat, 2327 "osp_construction_render_cost_decrease_weight=", 2328 "0.99"); 2329 2326 optFloat, 2327 "osp_construction_render_cost_decrease_weight=", 2328 "0.99"); 2329 2330 2331 2332 /***********************************************************************/ 2333 /* Bounding Volume Hierarchy related options */ 2334 /***********************************************************************/ 2335 2336 RegisterOption("BvHierarchy.Construction.randomize", 2337 optBool, 2338 "bvh_construction_randomize=", 2339 "false"); 2340 2341 RegisterOption("BvHierarchy.Termination.maxDepth", 2342 optInt, 2343 "bvh_term_max_depth=", 2344 "30"); 2345 2346 RegisterOption("BvHierarchy.Termination.maxLeaves", 2347 optInt, 2348 "bvh_term_max_leaves=", 2349 "1000"); 2350 2351 RegisterOption("BvHierarchy.Termination.minObjects", 2352 optInt, 2353 "bvh_term_min_objects=", 2354 "1"); 2355 2356 RegisterOption("BvHierarchy.Termination.minProbability", 2357 optFloat, 2358 "bvh_term_min_objects=", 2359 "0.00001"); 2360 2361 RegisterOption("BvHierarchy.Termination.missTolerance", 2362 optInt, 2363 "osp_term_miss_tolerance=", 2364 "8"); 2365 2366 RegisterOption("BvHierarchy.Termination.maxCostRatio", 2367 optFloat, 2368 "bvh_term_max_cost_ratio=", 2369 "0.99"); 2370 2371 RegisterOption("BvHierarchy.Termination.minGlobalCostRatio", 2372 optFloat, 2373 "bvh_term_min_global_cost_ratio=", 2374 "0.00001"); 2375 2376 RegisterOption("BvHierarchy.Termination.globalCostMissTolerance", 2377 optInt, 2378 "bvh_term_global_cost_miss_tolerance=", 2379 "4"); 2380 2381 RegisterOption("BvHierarchy.Termination.ct_div_ci", 2382 optFloat, 2383 "bvh_term_ct_div_ci=", 2384 "0"); 2385 2386 RegisterOption("BvHierarchy.Construction.epsilon", 2387 optFloat, 2388 "bvh_construction_epsilon=", 2389 "0.00001"); 2390 2391 // if only the driving axis is used for axis aligned split 2392 RegisterOption("BvHierarchy.splitUseOnlyDrivingAxis", 2393 optBool, 2394 "bvh_split_only_driving_axis=", 2395 "false"); 2396 2397 RegisterOption("BvHierarchy.maxStaticMemory", 2398 optFloat, 2399 "bvh_max_static_mem=", 2400 "8.0"); 2401 2402 RegisterOption("BvHierarchy.useCostHeuristics", 2403 optBool, 2404 "bvh_use_cost_heuristics=", 2405 "true"); 2406 2407 RegisterOption("BvHierarchy.subdivisionStats", 2408 optString, 2409 "bvh_subdivision_stats=", 2410 "bvhSubdivisionStats.log"); 2411 2412 RegisterOption("BvHierarchy.Construction.splitBorder", 2413 optFloat, 2414 "bvh_construction_split_border=", 2415 "0.01"); 2416 2417 RegisterOption("BvHierarchy.Construction.renderCostDecreaseWeight", 2418 optFloat, 2419 "bvh_construction_render_cost_decrease_weight=", 2420 "0.99"); 2421 2422 2423 /*******************************************************************/ 2424 /* Hierarchy Manager related options */ 2425 /*******************************************************************/ 2330 2426 2331 2427 RegisterOption("Hierarchy.subdivisionStats", 2332 optString, 2333 "hierarchy_subdivision_stats=", 2334 "hierarchySubdivisionStats.log"); 2335 2428 optString, 2429 "hierarchy_subdivision_stats=", 2430 "hierarchySubdivisionStats.log"); 2431 2432 RegisterOption("Hierarchy.type", 2433 optString, 2434 "hierarchy_type=", 2435 "bvh"); 2436 2437 RegisterOption("Hierarchy.Termination.minGlobalCostRatio", 2438 optFloat, 2439 "hierarchy_term_min_global_cost_ratio=", 2440 "0.00001"); 2441 2442 RegisterOption("Hierarchy.Termination.globalCostMissTolerance", 2443 optInt, 2444 "hierarchy_term_global_cost_miss_tolerance=", 2445 "4"); 2446 2447 RegisterOption("Hierarchy.Termination.maxLeaves", 2448 optInt, 2449 "hierarchy_term_max_leaves=", 2450 "1000"); 2451 2336 2452 ////////////////////////////////////////////////////////////////////////////////// 2337 2453 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1287 r1288 62 62 mVspTree->mHierarchyManager = this; 63 63 64 ParseEnvironment(); 65 } 66 67 68 HierarchyManager::HierarchyManager(VspTree *vspTree, KdTree *kdTree): 69 mObjectSpaceSubdivisonType(KD_BASED_OBJ_SUBDIV), 70 mVspTree(vspTree), 71 mBvHierarchy(NULL) 72 { 73 mOspTree = new OspTree(*kdTree); 74 mOspTree->mVspTree = mVspTree; 75 76 //mOspTree->mHierarchyManager = this; 77 Debug << "creating osp tree" << endl; 78 79 if (mVspTree) 80 mVspTree->mHierarchyManager = this; 81 82 ParseEnvironment(); 83 } 84 85 86 void HierarchyManager::ParseEnvironment() 87 { 64 88 char subdivisionStatsLog[100]; 65 89 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", 66 90 subdivisionStatsLog); 67 91 mSubdivisionStats.open(subdivisionStatsLog); 68 } 69 70 71 HierarchyManager::HierarchyManager(VspTree *vspTree, KdTree *kdTree): 72 mObjectSpaceSubdivisonType(KD_BASED_OBJ_SUBDIV), 73 mVspTree(vspTree), 74 mBvHierarchy(NULL) 75 { 76 mOspTree = new OspTree(*kdTree); 77 mOspTree->mVspTree = mVspTree; 78 79 //mOspTree->mHierarchyManager = this; 80 Debug << "creating osp tree" << endl; 81 82 if (mVspTree) 83 mVspTree->mHierarchyManager = this; 84 85 char subdivisionStatsLog[100]; 86 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", 87 subdivisionStatsLog); 88 mSubdivisionStats.open(subdivisionStatsLog); 92 93 Environment::GetSingleton()->GetFloatValue( 94 "Hierarchy.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 95 Environment::GetSingleton()->GetIntValue( 96 "Hierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 97 98 //Debug << "max depth: " << mTermMaxDepth << endl; 99 Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 100 Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; 89 101 } 90 102 … … 183 195 bool HierarchyManager::GlobalTerminationCriteriaMet(SubdivisionCandidate *candidate) const 184 196 { 185 // TODO matt: make virtual by creating superclasss for traveral data 186 return candidate->GlobalTerminationCriteriaMet(); 197 return (0 198 || (mHierarchyStats.Leaves() >= mMaxLeaves) 199 || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 200 || candidate->GlobalTerminationCriteriaMet() 201 ); 187 202 } 188 203 … … 200 215 mVspTree->mVspStats.Reset(); 201 216 mVspTree->mVspStats.Start(); 217 218 mHierarchyStats.Reset(); 219 mHierarchyStats.Start(); 202 220 203 221 cout << "Constructing view space / object space tree ... \n"; … … 222 240 { 223 241 VspNode *n = mVspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 242 243 if (n->IsLeaf()) // local or global termination criteria failed 244 return false; 224 245 } 225 246 else … … 228 249 { 229 250 KdNode *n = mOspTree->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 251 252 if (n->IsLeaf()) // local or global termination criteria failed 253 return false; 230 254 } 231 255 else if (mObjectSpaceSubdivisonType == BV_BASED_OBJ_SUBDIV) 232 256 { 233 257 BvhNode *n = mBvHierarchy->Subdivide(mTQueue, sc, globalTerminationCriteriaMet); 234 } 235 } 236 237 return !globalTerminationCriteriaMet; 258 if (n->IsLeaf()) // local or global termination criteria failed 259 return false; 260 } 261 } 262 263 return true;//!globalTerminationCriteriaMet; 238 264 } 239 265 … … 241 267 void HierarchyManager::RunConstruction(const bool repair) 242 268 { 243 int numNodes = 0; 269 mHierarchyStats.nodes = 0; 270 mGlobalCostMisses = 0; 244 271 245 272 while (!FinishedConstruction()) … … 252 279 const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; 253 280 281 Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 254 282 if (costRatio < mTermMinGlobalCostRatio) 255 283 ++ mGlobalCostMisses; 256 257 /*Debug << "\n**********" << endl258 << "total cost: " << mTotalCost << " render cost decr: "259 << splitCandidate->GetRenderCostDecrease()260 << " cost ratio: " << costRatio << endl << endl;*/261 284 262 285 //-- subdivide leaf node … … 264 287 if (ApplySubdivisionCandidate(splitCandidate)) 265 288 { 289 mHierarchyStats.nodes += 2; 290 266 291 // subdivision successful 267 292 EvalSubdivisionStats(*splitCandidate); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1287 r1288 59 59 60 60 61 62 /** View space partition statistics. 63 */ 64 class HierarchyStatistics: public StatisticsBase 65 { 66 public: 67 68 /// total number of nodes 69 int nodes; 70 71 /// maximal reached depth 72 int maxDepth; 73 74 /// accumulated depth 75 int accumDepth; 76 77 // Constructor 78 HierarchyStatistics() 79 { 80 Reset(); 81 } 82 83 int Nodes() const {return nodes;} 84 int Interior() const { return nodes / 2; } 85 int Leaves() const { return (nodes / 2) + 1; } 86 87 // TODO: computation wrong 88 double AvgDepth() const { return accumDepth / (double)Leaves();} 89 90 91 void Reset() 92 { 93 nodes = 0; 94 maxDepth = 0; 95 accumDepth = 0; 96 } 97 98 99 void Print(ostream &app) const; 100 101 friend ostream &operator<<(ostream &s, const HierarchyStatistics &stat) 102 { 103 stat.Print(s); 104 return s; 105 } 106 }; 107 108 61 109 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 62 110 … … 213 261 const ObjectContainer &objects); 214 262 263 void ParseEnvironment(); 264 265 215 266 protected: 216 267 … … 235 286 float mTotalCost; 236 287 288 HierarchyStatistics mHierarchyStats; 289 290 int mMaxLeaves; 237 291 ofstream mSubdivisionStats; 238 292 }; -
GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp
r1287 r1288 203 203 204 204 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.splitBorder", mSplitBorder); 205 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 205 Environment::GetSingleton()->GetFloatValue( 206 "OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 206 207 207 208 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1287 r1288 420 420 else 421 421 { 422 //-- parse type of view cell container 423 422 // parse type of view cell container 424 423 Environment::GetSingleton()->GetStringValue("ViewCells.type", buf); 425 424 mViewCellsManager = CreateViewCellsManager(buf); … … 456 455 457 456 457 HierarchyManager *Preprocessor::CreateHierarchyManager(const char *name) 458 { 459 HierarchyManager *hierarchyManager; 460 461 if (strcmp(name, "osp") == 0) 462 { 463 // HACK for testing if per kd evaluation works!! 464 const bool ishack = true; 465 if (ishack) 466 hierarchyManager = new HierarchyManager(mVspTree, mKdTree); 467 else 468 hierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 469 } 470 else if (strcmp(name, "bvh") == 0) 471 { 472 hierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 473 } 474 475 return hierarchyManager; 476 } 477 478 458 479 ViewCellsManager *Preprocessor::CreateViewCellsManager(const char *name) 459 480 { … … 481 502 { 482 503 mVspTree = new VspTree(); 483 484 // HACK for testing if per kd evaluation works!! 485 const bool ishack = true; 486 487 /*if (ishack) 488 mHierarchyManager = new HierarchyManager(mVspTree, mKdTree); 489 else 490 mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 491 */ 492 mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 493 504 char buf[100]; 505 Environment::GetSingleton()->GetStringValue("Hierarchy.type", buf); 506 507 HierarchyManager *mHierarchyManager = CreateHierarchyManager(buf); 494 508 mViewCellsManager = new VspOspViewCellsManager(vcTree, mHierarchyManager); 495 509 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1287 r1288 149 149 VssRayContainer &vssRays); 150 150 151 /** Returns a view cells manager with respect tothe given name.151 /** Returns a view cells manager of the given name. 152 152 */ 153 153 ViewCellsManager *CreateViewCellsManager(const char *name); 154 /** Returns a hierarchy manager of the given name. 155 */ 156 HierarchyManager *CreateHierarchyManager(const char *name); 154 157 155 158 GlRendererBuffer *GetRenderer() { return renderer;} -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1233 r1288 672 672 673 673 // cost ratio of cost decrease / totalCost 674 float costRatio = splitCandidate. GetPriority()/ mTotalCost;674 float costRatio = splitCandidate.mRenderCostDecr / mTotalCost; 675 675 676 676 //Debug << "cost ratio: " << costRatio << endl; 677 678 677 if (costRatio < mTermMinGlobalCostRatio) 679 678 ++ mGlobalCostMisses; … … 1041 1040 1042 1041 1043 /* 1044 void VspBspTree::EvalSubdivisionCandidate(VspBspTraversalData &tData, 1045 VspBspSubdivisionCandidate &splitData) 1042 void VspBspTree::EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitCandidate) 1046 1043 { 1047 1044 VspBspTraversalData frontData; 1048 1045 VspBspTraversalData backData; 1049 1050 BspLeaf *leaf = dynamic_cast<BspLeaf *>( tData.mNode);1051 1046 1047 BspLeaf *leaf = dynamic_cast<BspLeaf *>(splitCandidate.mParentData.mNode); 1048 1052 1049 // compute locally best split plane 1053 bool success = SelectPlane(splitData.mSplitPlane, leaf, tData, 1054 frontData, backData, splitData.mSplitAxis); 1055 1056 // TODO: reuse 1057 delete frontData.mGeometry; 1058 delete backData.mGeometry; 1059 1060 // compute global decrease in render cost 1061 splitData.mPriority = EvalRenderCostDecrease(splitData.mSplitPlane, tData); 1062 splitData.mParentData = tData; 1063 splitData.mMaxCostMisses = success ? tData.mMaxCostMisses : tData.mMaxCostMisses + 1; 1064 } 1065 */ 1066 1067 void VspBspTree::EvalSubdivisionCandidate(VspBspSubdivisionCandidate &splitCandidate) 1068 { 1069 VspBspTraversalData frontData; 1070 VspBspTraversalData backData; 1071 1072 BspLeaf *leaf = dynamic_cast<BspLeaf *>(splitCandidate.mParentData.mNode); 1073 1074 // compute locally best split plane 1075 bool success = SelectPlane(splitCandidate.mSplitPlane, leaf, splitCandidate.mParentData, 1076 frontData, backData, splitCandidate.mSplitAxis); 1050 const bool costRatioViolated = 1051 SelectPlane(splitCandidate.mSplitPlane, 1052 leaf, 1053 splitCandidate.mParentData, 1054 frontData, 1055 backData, 1056 splitCandidate.mSplitAxis); 1057 1058 // max cost threshold violated? 1059 splitCandidate.mMaxCostMisses = costRatioViolated ? 1060 splitCandidate.mParentData.mMaxCostMisses : 1061 splitCandidate.mParentData.mMaxCostMisses + 1; 1077 1062 1078 1063 float oldRenderCost; … … 1101 1086 1102 1087 splitCandidate.mPriority = priority; 1103 1104 // max cost threshold violated?1105 splitCandidate.mMaxCostMisses =1106 success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1;1107 1088 } 1108 1089 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r1251 r1288 156 156 157 157 158 structVspBspSubdivisionCandidate158 class VspBspSubdivisionCandidate 159 159 { 160 /// the current split plane 161 Plane3 mSplitPlane; 162 /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 163 int mSplitAxis; 164 /// the number of misses of max cost ratio until this split 165 int mMaxCostMisses; 166 167 // parent data 168 VspBspTraversalData mParentData; 169 // prioriry of this split 170 float mPriority; 171 172 float mRenderCostDecr; 160 public: 173 161 174 162 VspBspSubdivisionCandidate(): mPriority(0), mRenderCostDecr(0) … … 189 177 #endif 190 178 } 179 180 /// the current split plane 181 Plane3 mSplitPlane; 182 /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned) 183 int mSplitAxis; 184 /// the number of misses of max cost ratio until this split 185 int mMaxCostMisses; 186 187 /// parent data 188 VspBspTraversalData mParentData; 189 /// prioriry of this split 190 float mPriority; 191 192 float mRenderCostDecr; 193 191 194 192 195 friend bool operator<(const VspBspSubdivisionCandidate &a, const VspBspSubdivisionCandidate &b)
Note: See TracChangeset
for help on using the changeset viewer.