Changeset 1279 for GTP/trunk/Lib
- Timestamp:
- 08/24/06 18:05:53 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1272 r1279 499 499 if ((int)(leaf->mObjects.size()) > mBvhStats.maxObjectRefs) 500 500 mBvhStats.maxObjectRefs = (int)leaf->mObjects.size(); 501 502 501 } 503 502 … … 1594 1593 } 1595 1594 1596 } 1597 1595 1596 void BvhStatistics::Print(ostream &app) const 1597 { 1598 app << "=========== OspTree statistics ===============\n"; 1599 1600 app << setprecision(4); 1601 1602 app << "#N_CTIME ( Construction time [s] )\n" << Time() << " \n"; 1603 1604 app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 1605 1606 app << "#N_INTERIORS ( Number of interior nodes )\n" << Interior() << "\n"; 1607 1608 app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 1609 1610 app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits << endl; 1611 1612 1613 app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n" 1614 << maxDepthNodes * 100 / (double)Leaves() << endl; 1615 1616 app << "#N_PMINPVSLEAVES ( Percentage of leaves with mininimal PVS )\n" 1617 << minPvsNodes * 100 / (double)Leaves() << endl; 1618 1619 app << "#N_MAXCOSTNODES ( Percentage of leaves with terminated because of max cost ratio )\n" 1620 << maxCostNodes * 100 / (double)Leaves() << endl; 1621 1622 app << "#N_PMINPROBABILITYLEAVES ( Percentage of leaves with mininum probability )\n" 1623 << minProbabilityNodes * 100 / (double)Leaves() << endl; 1624 1625 app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 1626 1627 app << "#N_PMINDEPTH ( Minimal reached depth )\n" << minDepth << endl; 1628 1629 app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 1630 1631 app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 1632 1633 app << "#N_MAXOBJECTREFS ( Max number of object refs / leaf )\n" << maxObjectRefs << "\n"; 1634 1635 //app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 1636 1637 app << "========== END OF VspTree statistics ==========\n"; 1638 } 1639 1640 1641 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1264 r1279 34 34 35 35 36 HierarchyManager::HierarchyManager(VspTree &vspTree, OspTree &ospTree) 37 //:mVspTree(vspTree), mOspTree(ospTree) 38 { 36 HierarchyManager::HierarchyManager(VspTree *vspTree, 37 const int objectSpaceSubdivisionType): 38 mObjectSpaceSubdivisonType(objectSpaceSubdivisionType), 39 mVspTree(vspTree), 40 mOspTree(NULL), 41 mBvHierarchy(NULL) 42 { 43 switch(mObjectSpaceSubdivisonType) 44 { 45 case KD_BASED_OBJ_SUBDIV: 46 mOspTree = new OspTree(); 47 mOspTree->mVspTree = mVspTree; 48 //mOspTree->mHierarchyManager = this; 49 Debug << "creating osp tree" << endl; 50 break; 51 case BV_BASED_OBJ_SUBDIV: 52 mBvHierarchy = new BvHierarchy(); 53 mBvHierarchy->mVspTree = mVspTree; 54 //mBvHierarchy->mHierarchyManager = this; 55 Debug << "creating bv hierachy" << endl; 56 break; 57 default: 58 break; 59 } 60 61 if (mVspTree) 62 mVspTree->mHierarchyManager = this; 63 39 64 char subdivisionStatsLog[100]; 40 65 Environment::GetSingleton()->GetStringValue("Hierarchy.subdivisionStats", 41 66 subdivisionStatsLog); 42 67 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); 89 } 90 91 92 HierarchyManager::~HierarchyManager() 93 { 94 DEL_PTR(mOspTree); 95 //DEL_PTR(mVspTree); 96 DEL_PTR(mBvHierarchy); 97 } 98 99 100 void HierarchyManager::SetViewCellsManager(ViewCellsManager *vcm) 101 { 102 mVspTree->SetViewCellsManager(vcm); 103 104 if (mOspTree) 105 mOspTree->SetViewCellsManager(vcm); 106 if (mBvHierarchy) 107 mBvHierarchy->SetViewCellsManager(vcm); 108 } 109 110 111 void HierarchyManager::SetViewCellsTree(ViewCellsTree *vcTree) 112 { 113 mVspTree->SetViewCellsTree(vcTree); 43 114 } 44 115 … … 211 282 mVspTree.mStoreObjectPvs = false; 212 283 #endif 213 214 284 SubdivisionCandidate *vsc = 215 285 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 216 286 217 287 // add to queue 218 288 mTQueue.Push(vsc); … … 409 479 410 480 411 } 481 void HierarchyManager::ExportObjectSpaceHierarchy(OUT_STREAM &stream) 482 { 483 // the type of the view cells hierarchy 484 switch (mObjectSpaceSubdivisonType) 485 { 486 case KD_BASED_OBJ_SUBDIV: 487 stream << "<ObjectSpaceHierarchy type=\"osp\">" << endl; 488 mOspTree->Export(stream); 489 stream << endl << "</ObjectSpaceHierarchy>" << endl; 490 break; 491 492 case BV_BASED_OBJ_SUBDIV: 493 stream << "<ObjectSpaceHierarchy type=\"bvh\">" << endl; 494 mBvHierarchy->Export(stream); 495 stream << endl << "</ObjectSpaceHierarchy>" << endl; 496 break; 497 } 498 } 499 500 501 bool HierarchyManager::AddSampleToPvs(Intersectable *obj, 502 const Vector3 &hitPoint, 503 ViewCell *vc, 504 const float pdf, 505 float &contribution) const 506 { 507 if (!obj) return false; 508 509 switch (mObjectSpaceSubdivisonType) 510 { 511 case NO_OBJ_SUBDIV: 512 // potentially visible objects 513 return vc->AddPvsSample(obj, pdf, contribution); 514 515 case KD_BASED_OBJ_SUBDIV: 516 { 517 // potentially visible kd cells 518 KdLeaf *leaf = mOspTree->GetLeaf(hitPoint/*ray->mOriginNode*/); 519 return mOspTree->AddLeafToPvs(leaf, vc, pdf, contribution); 520 } 521 case BV_BASED_OBJ_SUBDIV: 522 { 523 BvhLeaf *leaf = mBvHierarchy->GetLeaf(obj); 524 return mBvHierarchy->AddLeafToPvs(leaf, vc, pdf, contribution); 525 } 526 default: 527 return false; 528 } 529 } 530 531 532 void HierarchyManager::PrintObjectSpaceHierarchyStatistics(ofstream &stream) const 533 { 534 switch (mObjectSpaceSubdivisonType) 535 { 536 case KD_BASED_OBJ_SUBDIV: 537 { 538 stream << mOspTree->GetStatistics(); 539 break; 540 } 541 case BV_BASED_OBJ_SUBDIV: 542 { 543 stream << mBvHierarchy->GetStatistics(); 544 break; 545 } 546 default: 547 break; 548 } 549 } 550 551 552 void HierarchyManager::ExportObjectSpaceHierarchyForViz(const ObjectContainer &objects) const 553 { 554 if (mOspTree && mOspTree->GetRoot()) 555 { 556 //-- export final object partition 557 Exporter *exporter = Exporter::GetExporter("final_object_partition.wrl"); 558 559 if (exporter) 560 { 561 cout << "exporting object space partition ... "; 562 563 if (1) 564 { 565 exporter->ExportGeometry(objects); 566 } 567 568 #if 0 569 // export rays 570 exporter->ExportRays(visRays, RgbColor(0, 1, 0)); 571 #endif 572 573 exporter->SetWireframe(); 574 575 const int colorCode = 0; 576 const int maxPvs = 200;//mOspTree.GetStatistics().maxPvs; 577 578 exporter->ExportOspTree(*mOspTree, colorCode == 0 ? 0 : maxPvs); 579 580 delete exporter; 581 582 cout << "finished" << endl; 583 } 584 } 585 } 586 587 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1259 r1279 89 89 friend OspTree; 90 90 friend BvHierarchy; 91 friend ViewCellsParseHandlers; 91 92 92 93 public: 93 /** Constructor taking an object space partition and a view space partition tree. 94 */ 95 HierarchyManager(VspTree &vspTree, OspTree &ospTree); 94 /** Constructor with the object space hierarchy type as argument. 95 */ 96 HierarchyManager(VspTree *vspTree, const int objectSpaceHierarchyType); 97 /** Hack: OspTree will copy the content from this kd tree. 98 Only view space hierarchy will be constructed. 99 */ 100 HierarchyManager(VspTree *vspTree, KdTree *kdTree); 96 101 97 102 /** Constructs the view space and object space subdivision from a given set of rays … … 130 135 } 131 136 137 void SetViewCellsManager(ViewCellsManager *vcm); 138 139 void SetViewCellsTree(ViewCellsTree *vcTree); 140 141 void ExportObjectSpaceHierarchy(OUT_STREAM &stream); 142 143 bool AddSampleToPvs( 144 Intersectable *obj, 145 const Vector3 &hitPoint, 146 ViewCell *vc, 147 const float pdf, 148 float &contribution) const; 149 150 void PrintObjectSpaceHierarchyStatistics(ofstream &stream) const; 151 152 VspTree *GetVspTree() { return mVspTree; } 153 154 void ExportObjectSpaceHierarchyForViz(const ObjectContainer &objects) const; 155 132 156 protected: 133 157 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1272 r1279 17 17 #include "ObjParser.h" 18 18 #include "BvHierarchy.h" 19 #include "HierarchyManager.h" 19 20 20 21 #ifdef GTP_INTERNAL … … 125 126 mVspBspTree(NULL), 126 127 mVspTree(NULL), 127 mOspTree(NULL), 128 mBvHierarchy(NULL), 128 mHierarchyManager(NULL), 129 129 mViewCellsManager(NULL), 130 130 mRenderSimulator(NULL), 131 mPass(0) 131 mPass(0), 132 mRayCastMethod(0) 132 133 { 133 134 Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); … … 142 143 Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 143 144 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportVisibility", mExportVisibility ); 145 //#if GTP_INTERNAL // choose other ray cast method 144 146 Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", mRayCastMethod); 145 147 //#endif 146 148 char buffer[256]; 147 149 Environment::GetSingleton()->GetStringValue("Preprocessor.visibilityFile", buffer); … … 177 179 cout << "done.\n"; 178 180 179 cout << "Deleting osp tree...\n";180 DEL_PTR(m OspTree);181 cout << "Deleting hierarchy manager...\n"; 182 DEL_PTR(mHierarchyManager); 181 183 cout << "done.\n"; 182 184 … … 479 481 { 480 482 mVspTree = new VspTree(); 481 //mOspTree = new OspTree(); 482 483 483 484 // HACK for testing if per kd evaluation works!! 484 mOspTree = new OspTree(*mKdTree); 485 486 mViewCellsManager = new VspOspViewCellsManager(vcTree, mVspTree, mOspTree); 485 const bool ishack = true; 486 487 if (ishack) 488 { 489 mHierarchyManager = new HierarchyManager(mVspTree, mKdTree); 490 } 491 else 492 { 493 mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 494 } 495 496 mViewCellsManager = new VspOspViewCellsManager(vcTree, mHierarchyManager); 487 497 } 488 498 else if (strcmp(name, "sceneDependent") == 0) … … 500 510 } 501 511 502 //vcTree->SetViewCellsManager(mViewCellsManager);503 512 return mViewCellsManager; 504 513 } … … 767 776 // return new ObjectsInteriorDistribution(*this); 768 777 default: // no valid strategy 778 Debug << "warning: no valid sampling strategy" << endl; 769 779 return NULL; 770 780 } … … 844 854 //Debug << "intel ray: " << *vssRay << endl; 845 855 } 856 846 857 //cout << "a"; 847 858 return hits; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1272 r1279 25 25 class GlRendererBuffer; 26 26 class VspTree; 27 class OspTree;27 class HierarchyManager; 28 28 class BvHierarchy; 29 29 class Intersectable; … … 178 178 // view space partition tree 179 179 VspTree *mVspTree; 180 /// object space partition tree 181 OspTree *mOspTree; 180 HierarchyManager *mHierarchyManager; 182 181 /// BSP tree representing the viewcells 183 182 BspTree *mBspTree; 184 185 BvHierarchy *mBvHierarchy;186 183 187 184 /// list of all loaded occluders
Note: See TracChangeset
for help on using the changeset viewer.