Changeset 1121 for GTP/trunk/Lib/Vis
- Timestamp:
- 07/12/06 00:52:51 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1112 r1121 2054 2054 RegisterOption("VspBspTree.Construction.renderCostDecreaseWeight", 2055 2055 optFloat, 2056 "vsp_bsp_ post_process_render_cost_decrease_weight=",2056 "vsp_bsp_construction_render_cost_decrease_weight=", 2057 2057 "0.99"); 2058 2058 … … 2098 2098 "vsp_construction_samples=", 2099 2099 "10000"); 2100 2101 2102 RegisterOption("VspTree.Construction.renderCostDecreaseWeight", 2103 optFloat, 2104 "vsp_construction_render_cost_decrease_weight=", 2105 "0.99"); 2100 2106 2101 2107 RegisterOption("VspTree.Termination.maxDepth", … … 2282 2288 "false"); 2283 2289 2284 2285 2290 RegisterOption("OspTree.subdivisionStats", 2286 2291 optString, … … 2293 2298 "0.01"); 2294 2299 2300 RegisterOption("OspTree.Construction.renderCostDecreaseWeight", 2301 optFloat, 2302 "osp_construction_render_cost_decrease_weight=", 2303 "0.99"); 2304 2305 RegisterOption("OspTree.Evaluation.countKdPvs", 2306 optBool, 2307 "osp_evaluation_count_kd_pvs=", 2308 "false"); 2295 2309 2296 2310 -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r863 r1121 1 2 1 #include "X3dExporter.h" 3 2 #include "VrmlExporter.h" 3 #include "VspOspTree.h" 4 #include "KdTree.h" 5 4 6 5 7 namespace GtpVisibilityPreprocessor { … … 26 28 } 27 29 30 31 bool Exporter::ExportOspTree(const OspTree &ospTree, const int maxPvs) 32 { 33 vector<KdLeaf *> leaves; 34 ospTree.CollectLeaves(leaves); 35 36 mUseForcedMaterial = true; 37 38 vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 39 40 Material white; 41 white.mDiffuseColor.r = 1; 42 white.mDiffuseColor.g = 1; 43 white.mDiffuseColor.b = 1; 44 45 for (it = leaves.begin(); it != it_end; ++ it) 46 { 47 KdLeaf *leaf = *it; 48 49 SetWireframe(); 50 SetForcedMaterial(white); 51 ExportBox(ospTree.GetBBox(leaf)); 52 53 SetFilled(); 54 55 if (maxPvs) // color code pvs 56 { 57 mForcedMaterial.mDiffuseColor.b = 1.0f; 58 const float importance = (float)ospTree.ComputePvsSize(leaf->mObjects) / (float)maxPvs; 59 60 mForcedMaterial.mDiffuseColor.r = importance; 61 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 62 } 63 else 64 { 65 SetForcedMaterial(RandomMaterial()); 66 } 67 68 ExportGeometry(leaf->mObjects); 69 } 70 71 return true; 28 72 } 73 74 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h
r1112 r1121 70 70 71 71 virtual bool 72 ExportOspTree(const OspTree &tree )= 0;72 ExportOspTree(const OspTree &tree, const int maxPvs);// = 0; 73 73 74 74 // virtual bool -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1112 r1121 163 163 }; 164 164 165 class SplitCandidate; 165 166 166 167 /** Implementation of the kd-tree leaf node */ … … 209 210 /// pvs of view cells seeing this node. 210 211 // ViewCellPvs mViewCellPvs; 212 SplitCandidate *mSplitCandidate; 211 213 212 214 /** pointer to view cell. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1027 r1121 7 7 #include "Mesh.h" 8 8 #include "Intersectable.h" 9 #include " MeshKdTree.h"9 #include "KdTree.h" 10 10 #include "Triangle3.h" 11 11 #include "common.h" … … 29 29 30 30 31 typedef priority_queue<ViewCell *, vector<ViewCell *>, myless<vector<ViewCell *>::value_type> > TraversalQueue; 31 typedef priority_queue<ViewCell *, vector<ViewCell *>, 32 myless<vector<ViewCell *>::value_type> > TraversalQueue; 32 33 33 34 int ViewCell::sMailId = 21843194198; … … 257 258 return result; 258 259 } 259 260 260 261 261 … … 1675 1675 1676 1676 1677 int ViewCellsTree::GetPvsSize(ViewCell *vc) const 1677 int ViewCellsTree::CountKdPvs(const ViewCellLeaf *vc) const 1678 { 1679 ObjectPvsMap::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 1680 1681 int pvsSize = 0; 1682 1683 Intersectable::NewMail(); 1684 1685 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1686 { 1687 Intersectable *obj = (*oit).first; 1688 1689 set<KdLeaf *>::const_iterator kit, kit_end = obj->mKdLeaves.end(); 1690 1691 for (kit = obj->mKdLeaves.begin(); kit != kit_end; ++ kit) 1692 { 1693 KdLeaf *leaf = *kit; 1694 1695 pvsSize += ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 1696 1697 //-- handle objects of several kd leaves separately 1698 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 1699 1700 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 1701 { 1702 Intersectable *object = *oit; 1703 1704 // object not previously in left pvs 1705 if (!object->Mailed()) 1706 { 1707 object->Mail(); 1708 ++ pvsSize; 1709 } 1710 } 1711 } 1712 } 1713 1714 return pvsSize; 1715 } 1716 1717 1718 int ViewCellsTree::GetPvsSize(ViewCell *vc, const bool countKdPvs) const 1678 1719 { 1679 1720 int pvsSize = 0; … … 1691 1732 if (vc->IsLeaf()) 1692 1733 { 1693 pvsSize = vc->GetPvs().GetSize(); 1734 if (countKdPvs) 1735 pvsSize = vc->GetPvs().GetSize(); 1736 else 1737 pvsSize = CountKdPvs(dynamic_cast<ViewCellLeaf *>(vc)); 1694 1738 break; 1695 1739 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1010 r1121 350 350 }; 351 351 352 /** 353 Leaf of the view cell hierarchy correspondingto a leaf in a spatial hierarchy.352 /** Leaf of the view cell hierarchy corresponding 353 to a leaf in a spatial hierarchy. 354 354 */ 355 355 template<typename T> … … 420 420 void UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat); 421 421 422 423 422 /** Get costs resulting from each merge step. 424 423 */ 425 424 void GetCostFunction(vector<float> &costFunction); 426 427 425 428 426 /** Returns optimal set of view cells for a given number of view cells. … … 442 440 /** Returns pvs size of view cell. 443 441 */ 444 int GetPvsSize(ViewCell *vc) const; 442 //int GetPvsSize(ViewCell *vc) const; 443 int GetPvsSize(ViewCell *vc, const bool countKdPvs = false) const; 445 444 446 445 /** Returns actual number of object in this pvs and the children. … … 502 501 */ 503 502 void ResetPvs(); 503 504 /** Counts pvs of the view cell taking the kd cells into account. 505 */ 506 int CountKdPvs(const ViewCellLeaf *vc) const; 504 507 505 508 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h
r1084 r1121 51 51 */ 52 52 float GetArea() const; 53 53 54 /** Returns volume of this node geometry. 54 55 */ … … 215 216 } 216 217 217 int Nodes() const { return nodes;}218 int Nodes() const { return nodes; } 218 219 int Interior() const { return nodes / 2; } 219 220 int Leaves() const { return (nodes / 2) + 1; } 220 221 221 222 // TODO: computation wrong 222 double AvgDepth() const { return accumDepth / (double)Leaves(); };223 double AvgRays() const { return accumRays / (double)Leaves(); };223 double AvgDepth() const { return accumDepth / (double)Leaves(); } 224 double AvgRays() const { return accumRays / (double)Leaves(); } 224 225 225 226 void Reset() … … 304 305 bool IsSibling(BspNode *n) const; 305 306 306 /** returns depth of the node.307 /** Returns depth of the node. 307 308 */ 308 309 int GetDepth() const; 309 310 310 /** returns true if the whole subtree is valid311 /** Returns true if the whole subtree is valid 311 312 */ 312 313 bool TreeValid() const; 313 314 315 /** Sets the valid flag for the subtree with this node as root. 316 */ 314 317 void SetTreeValid(const bool v); 315 318 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1112 r1121 99 99 Environment::GetSingleton()->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs); 100 100 Environment::GetSingleton()->GetBoolValue("ViewCells.exportPvs", mExportPvs); 101 Environment::GetSingleton()->GetBoolValue("ViewCells.Evaluation.countKdPvs", mCountKdPvs); 101 102 102 103 char buf[100]; … … 212 213 Debug << "export bounding boxes: " << mExportBboxesForPvs << endl; 213 214 Debug << "export pvs for view cells: " << mExportPvs << endl; 214 215 Debug << "count kd pvs: " << mCountKdPvs << endl; 216 215 217 Debug << endl; 216 218 } … … 783 785 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 784 786 785 maxPvs = mViewCellsTree->GetPvsSize(viewCells.back() );787 maxPvs = mViewCellsTree->GetPvsSize(viewCells.back(), mCountKdPvs); 786 788 minVal = 0; 787 789 … … 791 793 maxVal = max(histoMaxVal, maxPvs); 792 794 793 Debug << "histogram minpvssize: " << minVal << " maxpvssize: " << maxVal << " real maxpvs " << maxPvs << endl; 795 Debug << "histogram minpvssize: " << minVal << " maxpvssize: " << maxVal 796 << " real maxpvs " << maxPvs << endl; 794 797 795 798 int histoIntervals; … … 826 829 827 830 while ((i < (int)viewCells.size()) && 828 (mViewCellsTree->GetPvsSize(viewCells[i] ) < currentPvs))831 (mViewCellsTree->GetPvsSize(viewCells[i], mCountKdPvs) < currentPvs)) 829 832 { 830 833 volDif += viewCells[i]->GetVolume(); … … 837 840 838 841 if (0 && (i < (int)viewCells.size())) 839 Debug << "new pvs size increase: " << mViewCellsTree->GetPvsSize(viewCells[i]) << " " << currentPvs << endl; 842 Debug << "new pvs size increase: " << mViewCellsTree->GetPvsSize(viewCells[i], mCountKdPvs) 843 << " " << currentPvs << endl; 840 844 841 845 const float volRatioDif = volDif / totalVol; … … 1685 1689 void ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 1686 1690 { 1687 // update pvs of view cells tree if necessary 1688 UpdatePvs(); 1689 1690 ViewCellContainer::const_iterator it = mViewCells.begin(); 1691 1692 stat.viewcells = 0; 1693 stat.minPvs = 100000000; 1694 stat.maxPvs = 0; 1695 stat.avgPvs = 0.0f; 1696 1697 for (; it != mViewCells.end(); ++ it) 1698 { 1699 ViewCell *viewcell = *it; 1700 1701 const int pvsSize = mViewCellsTree->GetPvsSize(viewcell); 1702 1703 if (pvsSize < stat.minPvs) 1704 stat.minPvs = pvsSize; 1705 if (pvsSize > stat.maxPvs) 1706 stat.maxPvs = pvsSize; 1707 stat.avgPvs += pvsSize; 1708 1709 ++ stat.viewcells; 1710 } 1711 1712 if (stat.viewcells) 1713 stat.avgPvs/=stat.viewcells; 1691 // update pvs of view cells tree if necessary 1692 UpdatePvs(); 1693 1694 ViewCellContainer::const_iterator it = mViewCells.begin(); 1695 1696 stat.viewcells = 0; 1697 stat.minPvs = 100000000; 1698 stat.maxPvs = 0; 1699 stat.avgPvs = 0.0f; 1700 1701 for (; it != mViewCells.end(); ++ it) 1702 { 1703 ViewCell *viewcell = *it; 1704 1705 const int pvsSize = mViewCellsTree->GetPvsSize(viewcell, mCountKdPvs); 1706 1707 if (pvsSize < stat.minPvs) 1708 stat.minPvs = pvsSize; 1709 if (pvsSize > stat.maxPvs) 1710 stat.maxPvs = pvsSize; 1711 1712 stat.avgPvs += pvsSize; 1713 1714 ++ stat.viewcells; 1715 } 1716 1717 if (stat.viewcells) 1718 stat.avgPvs/=stat.viewcells; 1714 1719 } 1715 1720 … … 1949 1954 float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 1950 1955 { 1951 return mViewCellsTree->GetPvsSize(viewCell );1956 return mViewCellsTree->GetPvsSize(viewCell, mCountKdPvs); 1952 1957 } 1953 1958 … … 2399 2404 { 2400 2405 if (mCurrentViewCellsStats.maxPvs) 2401 importance = (float)mViewCellsTree->GetPvsSize(vc) / (float)mCurrentViewCellsStats.maxPvs; 2406 { 2407 importance = 2408 (float)mViewCellsTree->GetPvsSize(vc, mCountKdPvs) / 2409 (float)mCurrentViewCellsStats.maxPvs; 2410 } 2402 2411 } 2403 2412 break; … … 2633 2642 Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 2634 2643 2635 2636 int savedColorCode= mColorCode;2644 // save color code 2645 const int savedColorCode = mColorCode; 2637 2646 2638 2647 //BspLeaf::NewMail(); … … 2685 2694 cout << "finished" << endl; 2686 2695 } 2687 2688 2689 // only for testing 2696 2697 // only for debugging: test valitidy 2690 2698 TestSubdivision(); 2691 2699 … … 4379 4387 Exporter *exporter = Exporter::GetExporter(s); 4380 4388 4381 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc ) << endl;4389 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc, mCountKdPvs) << endl; 4382 4390 4383 4391 //-- export the sample rays … … 5311 5319 5312 5320 exporter->SetWireframe(); 5313 exporter->ExportOspTree(*mOspTree); 5321 5322 const int savedColorCode = mColorCode; 5323 const int maxPvs = 200;//mOspTree.GetStatistics().maxPvs; 5324 5325 exporter->ExportOspTree(*mOspTree, mColorCode == 0 ? 0 : maxPvs); 5314 5326 5315 5327 delete exporter; … … 5368 5380 Exporter *exporter = Exporter::GetExporter(s); 5369 5381 5370 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc ) << endl;5382 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc, mCountKdPvs) << endl; 5371 5383 5372 5384 //-- export the sample rays … … 5440 5452 5441 5453 //-- export view cell geometry 5454 5442 5455 exporter->SetWireframe(); 5443 5456 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1074 r1121 559 559 const ViewCellContainer &viewCells); 560 560 561 562 561 /** Creates clip plane for visualization. 563 562 */ … … 656 655 /// if pvs should be exported with view cells 657 656 bool mExportPvs; 657 658 bool mCountKdPvs; 658 659 }; 659 660 -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
r1108 r1121 222 222 tStack.push(pair<BspNode *, BspNodeGeometry *>(tree.GetRoot(), geom)); 223 223 224 // color code pvs 224 225 if (maxPvs) 226 { 225 227 mUseForcedMaterial = true; 226 228 } 229 227 230 while (!tStack.empty()) 228 231 { … … 647 650 delete mesh; 648 651 return true; 649 }650 651 652 bool VrmlExporter::ExportOspTree(const OspTree &ospTree)653 {654 vector<KdLeaf *> leaves;655 ospTree.CollectLeaves(leaves);656 657 mUseForcedMaterial = true;658 659 vector<KdLeaf *>::const_iterator it, it_end = leaves.end();660 661 Material white;662 white.mDiffuseColor.r = 1;663 white.mDiffuseColor.g = 1;664 white.mDiffuseColor.b = 1;665 666 for (it = leaves.begin(); it != it_end; ++ it)667 {668 SetWireframe();669 SetForcedMaterial(white);670 ExportBox(ospTree.GetBBox(*it));671 672 SetFilled();673 SetForcedMaterial(RandomMaterial());674 ExportGeometry((*it)->mObjects);675 }676 677 return true;678 652 } 679 653 -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.h
r1112 r1121 47 47 ExportKdTree(const KdTree &tree); 48 48 49 bool 50 ExportOspTree(const OspTree &tree); 49 //bool ExportOspTree(const OspTree &tree); 51 50 52 51 bool -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1111 r1121 22 22 23 23 #define USE_FIXEDPOINT_T 0 24 #define COUNT_OBJECTS 124 #define COUNT_OBJECTS 0 25 25 26 26 //-- static members … … 50 50 void VspTreeStatistics::Print(ostream &app) const 51 51 { 52 app << "===== VspTree statistics ===============\n";52 app << "=========== VspTree statistics ===============\n"; 53 53 54 54 app << setprecision(4); … … 99 99 //app << "#N_PVS: " << pvs << endl; 100 100 101 app << "===== END OF VspTree statistics ==========\n";101 app << "========== END OF VspTree statistics ==========\n"; 102 102 } 103 103 … … 352 352 //-- partition criteria 353 353 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.epsilon", mEpsilon); 354 Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 354 355 355 356 // if only the driving axis is used for axis aligned split … … 392 393 Debug << "use cost heuristics: " << mUseCostHeuristics << endl; 393 394 Debug << "subdivision stats log: " << subdivisionStatsLog << endl; 394 395 Debug << "render cost decrease weight: " << mRenderCostDecreaseWeight << endl; 396 395 397 Debug << "circulating axis: " << mCirculatingAxis << endl; 396 398 Debug << "minband: " << mMinBand << endl; … … 598 600 tBackData.mMaxCostMisses = maxCostMisses; 599 601 600 602 601 603 if (1) 602 604 { … … 620 622 } 621 623 622 624 623 625 //-- evaluate new split candidates for global greedy cost heuristics 624 626 VspSplitCandidate *frontCandidate = new VspSplitCandidate(tFrontData); … … 630 632 tQueue.Push(frontCandidate); 631 633 tQueue.Push(backCandidate); 632 634 635 // delete old view cell 636 delete tData.mNode->GetViewCell(); 633 637 // delete old leaf node 634 638 DEL_PTR(tData.mNode); … … 747 751 parent->ReplaceChildLink(leaf, interior); 748 752 interior->SetParent(parent); 753 754 // remove "parent" view cell from pvs of all objects (traverse trough rays) 755 RemoveParentViewCellReferences(tData.mNode->GetViewCell()); 749 756 } 750 757 else // new root … … 770 777 CreateViewCell(backData); 771 778 772 // TODO:779 773 780 // create front and back view cell 774 // remove "parent" view cell from pvs of all objects (traverse trough rays)775 781 // add front and back view cell to "Potentially Visbilie View Cells" 776 782 // of the objects in front and back pvs 777 RemoveParentViewCellReferences(tData.mNode->GetViewCell());778 783 AddViewCellReferences(frontLeaf->GetViewCell()); 779 784 AddViewCellReferences(backLeaf->GetViewCell()); 780 781 785 782 786 interior->mTimeStamp = mTimeStamp ++; … … 1144 1148 void VspTree::AddContriToPvs(KdLeaf *leaf, int &pvs) const 1145 1149 { 1146 if ( !leaf->Mailed())1147 {1148 leaf->Mail();1149 1150 // add objects without those which are part of several kd leaves 1151 pvs += ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size());1152 1153 //-- handle objects of several kd leaves separately 1154 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end();1155 1156 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 1157 {1158 Intersectable *object = *oit;1159 1160 // object not previously in left pvs 1161 if (!object->Mailed())1162 {1163 object->Mail();1164 ++ pvs;1165 }1150 if (leaf->Mailed()) 1151 return; 1152 1153 leaf->Mail(); 1154 1155 // add objects without those which are part of several kd leaves 1156 pvs += ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 1157 1158 //-- handle objects of several kd leaves separately 1159 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 1160 1161 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 1162 { 1163 Intersectable *object = *oit; 1164 1165 // object not previously in left pvs 1166 if (!object->Mailed()) 1167 { 1168 object->Mail(); 1169 ++ pvs; 1166 1170 } 1167 1171 } … … 1513 1517 // take render cost of node into account 1514 1518 // otherwise danger of being stuck in a local minimum!! 1515 const float factor = 0.99f;1519 const float factor = mRenderCostDecreaseWeight; 1516 1520 1517 1521 const float normalizedOldRenderCost = oldRenderCost / mBoundingBox.GetVolume(); … … 2554 2558 2555 2559 2556 2557 2558 2560 int VspTree::ComputeBoxIntersections(const AxisAlignedBox3 &box, 2559 2561 ViewCellContainer &viewCells) const … … 2606 2608 2607 2609 2610 2611 void VspTree::CollectDirtyCandidates(VspSplitCandidate *sc, 2612 vector<SplitCandidate *> &dirtyList) 2613 { 2614 VspLeaf *node = sc->mParentData.mNode; 2615 2616 ViewCellLeaf *vc = node->GetViewCell(); 2617 2618 ObjectPvsMap::const_iterator oit, oit_end = vc->GetPvs().mEntries.end(); 2619 2620 KdLeaf::NewMail(); 2621 2622 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 2623 { 2624 Intersectable *obj = (*oit).first; 2625 2626 set<KdLeaf *>::const_iterator kit, kit_end = obj->mKdLeaves.end(); 2627 2628 for (kit = obj->mKdLeaves.begin(); kit != kit_end; ++ kit) 2629 { 2630 KdLeaf *leaf = *kit; 2631 2632 if (!leaf->Mailed()) 2633 { 2634 leaf->Mail(); 2635 dirtyList.push_back(leaf->mSplitCandidate); 2636 } 2637 } 2638 } 2639 } 2640 2641 2608 2642 /*****************************************************************/ 2609 2643 /* class OspTree implementation */ … … 2655 2689 2656 2690 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.splitBorder", mSplitBorder); 2657 //mSplitBorder = 0.1f; 2658 2659 2691 Environment::GetSingleton()->GetFloatValue("OspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 2692 2660 2693 //-- debug output 2661 2694 … … 2679 2712 2680 2713 Debug << "split borders: " << mSplitBorder << endl; 2714 Debug << "render cost decrease weight: " << mRenderCostDecreaseWeight << endl; 2681 2715 2682 2716 … … 2761 2795 const AxisAlignedBox3 box = (*mi)->GetBox(); 2762 2796 2763 if (box.Max(axis) > position )2797 if (box.Max(axis) > position + mEpsilon) 2764 2798 ++ objectsFront; 2765 2799 2766 if (box.Min(axis) < position )2800 if (box.Min(axis) < position - mEpsilon) 2767 2801 ++ objectsBack; 2768 2802 } … … 2843 2877 // delete old leaf node 2844 2878 DEL_PTR(tData.mNode); 2845 DEL_PTR(tData.mNode->mViewCell);2846 2879 } 2847 2880 … … 2892 2925 { 2893 2926 // matt: TODO 2894 Debug << "here888 " << mTermMaxLeaves << " " << mOspStats.Leaves() << endl;2895 2927 return ( 2896 2928 (mOspStats.Leaves() >= mTermMaxLeaves) … … 2952 2984 int &objectsBack) 2953 2985 { 2954 2986 // sort so we can use a sweep 2955 2987 SortSplitCandidates(node, axis); 2956 2988 … … 2984 3016 2985 3017 float sum = (float)pvsSize * sizeBox; 3018 float dummy1 = 0; 3019 float dummy2 = 0; 2986 3020 2987 3021 vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 2988 3022 cout << "***********" << endl; 2989 3023 //-- traverse through visibility events 2990 3024 for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 2991 3025 { 3026 int pvslold = pvsl; 2992 3027 EvalPvsIncr(*ci, pvsl, pvsr); 3028 3029 cout << "incr: " << ci->mObject->mViewCellPvs.GetSize() << " obj id " 3030 << ci->mObject->GetId() << endl; 2993 3031 2994 3032 // Note: sufficient to compare size of bounding boxes of front and back side? … … 2997 3035 sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 2998 3036 2999 //Debug << "pos=" << (*ci).value << "\t pvs=(" << pvsl << "," << pvsr << ")" << "\t cost= " << sum << endl; 3037 cout << "pos=" << (*ci).value << "\t pvs=(" << pvsl << "," 3038 << pvsr << ")" << "\t cost= " << sum << endl; 3000 3039 3001 3040 if (sum < minSum) … … 3012 3051 } 3013 3052 3014 3015 // -- compute cost 3053 //-- compute cost 3016 3054 3017 3055 const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); … … 3035 3073 3036 3074 //if (axis != 1) 3037 Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 3038 <<"\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 3075 Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" 3076 << position << " t=" << (position - minBox) / (maxBox - minBox) 3077 << "\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 3039 3078 3040 3079 return ratio; 3041 3080 } 3042 3081 3082 3043 3083 void OspTree::SortSplitCandidates(KdLeaf *node, const int axis) 3044 3084 { 3045 3085 mSplitCandidates->clear(); 3046 3086 3047 int requestedSize = 2 *(int)node->mObjects.size();3087 int requestedSize = 2 * (int)node->mObjects.size(); 3048 3088 3049 3089 // creates a sorted split candidates array … … 3074 3114 stable_sort(mSplitCandidates->begin(), mSplitCandidates->end()); 3075 3115 } 3076 3077 3116 3078 3117 … … 3085 3124 return object->mViewCellPvs.GetSize(); 3086 3125 #endif 3126 } 3127 3128 3129 const OspTreeStatistics &OspTree::GetStatistics() const 3130 { 3131 return mOspStats; 3087 3132 } 3088 3133 … … 3124 3169 break; 3125 3170 } 3171 3172 cout << "pvs left: " << pvsLeft << " pvs right " << pvsRight << endl; 3126 3173 } 3127 3174 … … 3241 3288 float OspTree::EvalViewCellPvsIncr(Intersectable *object) const 3242 3289 { 3243 // TODO3290 #if COUNT_OBJECTS 3244 3291 return 1; 3292 #else 3293 return (float)object->mViewCellPvs.GetSize(); 3294 #endif 3245 3295 } 3246 3296 … … 3276 3326 const float pvsIncr = EvalViewCellPvsIncr(obj); 3277 3327 totalPvs += pvsIncr; 3328 cout << "totalpvs " << totalPvs << " incr " << pvsIncr << endl; 3278 3329 3279 3330 if (box.Max(candidatePlane.mAxis) > candidatePlane.mPosition) … … 3310 3361 const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 3311 3362 3312 Debug << "old: " << oldRenderCost << " new: " << newRenderCost << " decrease: " << oldRenderCost - newRenderCost << endl; 3363 Debug << "old: " << oldRenderCost << " new: " << newRenderCost << " decrease: " 3364 << oldRenderCost - newRenderCost << endl; 3313 3365 const float renderCostDecrease = (oldRenderCost - newRenderCost) / mBoundingBox.GetVolume(); 3314 3366 3315 3367 // take render cost of node into account 3316 3368 // otherwise danger of being stuck in a local minimum!! 3317 const float factor = 0.99f;3369 const float factor = mRenderCostDecreaseWeight; 3318 3370 3319 3371 const float normalizedOldRenderCost = oldRenderCost / mBoundingBox.GetVolume(); 3320 3321 3372 return factor * renderCostDecrease + (1.0f - factor) * normalizedOldRenderCost; 3322 3373 } … … 3429 3480 3430 3481 3482 void OspTree::CollectViewCells(KdLeaf *leaf, ViewCellContainer &viewCells) 3483 { 3484 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 3485 3486 ViewCell::NewMail(); 3487 3488 // loop through all object and collect view cell pvs of this node 3489 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 3490 { 3491 Intersectable *obj = *oit; 3492 3493 ViewCellPvsMap::const_iterator vit, vit_end = obj->mViewCellPvs.mEntries.end(); 3494 3495 for (vit = obj->mViewCellPvs.mEntries.begin(); vit != vit_end; ++ vit) 3496 { 3497 ViewCell *vc = (*vit).first; 3498 3499 if (!vc->Mailed()) 3500 { 3501 vc->Mail(); 3502 viewCells.push_back(vc); 3503 } 3504 } 3505 } 3506 3507 } 3508 3509 3510 void OspTree::CollectDirtyCandidates(OspSplitCandidate *sc, 3511 vector<SplitCandidate *> &dirtyList) 3512 { 3513 KdLeaf *node = sc->mParentData.mNode; 3514 3515 ObjectContainer::const_iterator oit, oit_end = node->mObjects.end(); 3516 3517 ViewCellContainer viewCells; 3518 3519 CollectViewCells(node, viewCells); 3520 3521 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 3522 3523 // through split candidates corresponding to view cell pvs of this 3524 // node into dirty list 3525 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 3526 { 3527 VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 3528 3529 VspLeaf *leaf = vc->mLeaf; 3530 dirtyList.push_back(leaf->GetSplitCandidate()); 3531 } 3532 } 3533 3534 3535 int OspTree::ComputePvsSize(const ObjectContainer &objects) const 3536 { 3537 int pvsSize = 0; 3538 3539 ObjectContainer::const_iterator oit, oit_end = objects.end(); 3540 3541 for (oit = objects.begin(); oit != oit_end; ++ oit) 3542 { 3543 pvsSize += (*oit)->mViewCellPvs.GetSize(); 3544 } 3545 3546 return pvsSize; 3547 } 3548 3549 3431 3550 /********************************************************************/ 3432 3551 /* class HierarchyManager implementation */ … … 3445 3564 SplitCandidate *splitCandidate = mTQueue.Top(); 3446 3565 3447 Debug<< "next candidate: " << splitCandidate->Type()3566 cout << "next candidate: " << splitCandidate->Type() 3448 3567 << ", priority: " << splitCandidate->GetPriority() << endl; 3449 3568 … … 3454 3573 3455 3574 3456 void HierarchyManager::PrepareConstruction(const VssRayContainer &sampleRays, 3457 const ObjectContainer &objects, 3458 AxisAlignedBox3 *forcedViewSpace, 3459 RayInfoContainer &rays) 3460 { 3461 mVspTree.PrepareConstruction(sampleRays, forcedViewSpace); 3575 void HierarchyManager::ProcessRays(const VssRayContainer &sampleRays, 3576 RayInfoContainer &rays, 3577 ObjectContainer &sampledObjects) 3578 { 3579 VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 3462 3580 3463 3581 long startTime = GetTime(); … … 3467 3585 Intersectable::NewMail(); 3468 3586 3469 VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 3470 3471 //-- store rays 3587 //-- store rays and objects 3472 3588 for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 3473 3589 { 3474 3590 VssRay *ray = *rit; 3475 3476 3591 float minT, maxT; 3477 3478 3592 static Ray hray; 3593 3479 3594 hray.Init(*ray); 3480 3595 … … 3489 3604 rays.push_back(RayInfo(ray, minT / len, maxT / len)); 3490 3605 } 3606 3607 // store objects 3608 if (ray->mTerminationObject && !ray->mTerminationObject->Mailed()) 3609 { 3610 ray->mTerminationObject->Mail(); 3611 sampledObjects.push_back(ray->mTerminationObject); 3612 } 3613 3614 if (ray->mOriginObject && !ray->mOriginObject->Mailed()) 3615 { 3616 ray->mOriginObject->Mail(); 3617 sampledObjects.push_back(ray->mOriginObject); 3618 } 3491 3619 } 3492 3620 3493 3621 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 3494 3495 3496 int pvsSize = mVspTree.ComputePvsSize(rays); 3497 3622 } 3623 3624 3625 void HierarchyManager::PrepareVsp(const VssRayContainer &sampleRays, 3626 AxisAlignedBox3 *forcedViewSpace, 3627 RayInfoContainer &rays) 3628 { 3629 // prepare bounding box 3630 mVspTree.PrepareConstruction(sampleRays, forcedViewSpace); 3631 3632 // get clipped rays 3633 ObjectContainer sampledObjects; 3634 ProcessRays(sampleRays, rays, sampledObjects); 3635 3636 //const int pvsSize = mVspTree.ComputePvsSize(rays); 3637 const int pvsSize = (int)sampledObjects.size(); 3638 3639 cout << "here450 pvs size: " << pvsSize << endl; 3498 3640 // -- prepare view space partition 3499 3641 … … 3507 3649 0, 3508 3650 &rays, 3509 //(int)objects.size(),3510 3651 pvsSize, 3511 3652 prop, … … 3513 3654 3514 3655 3656 // create first view cell 3657 mVspTree.CreateViewCell(vData); 3658 3659 // add first view cell to all the objects view cell pvs 3660 ObjectPvsMap::const_iterator oit, 3661 oit_end = leaf->GetViewCell()->GetPvs().mEntries.end(); 3662 3663 cout << "here23 " << leaf->GetViewCell()->GetPvs().mEntries.size(); 3664 3665 for (oit = leaf->GetViewCell()->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 3666 { 3667 Intersectable *obj = (*oit).first; 3668 cout << "obj: " << obj->GetId() << endl; 3669 obj->mViewCellPvs.AddSample(leaf->GetViewCell(), 1); 3670 } 3671 3515 3672 // compute first split candidate 3516 3673 VspTree::VspSplitCandidate *splitCandidate = new VspTree::VspSplitCandidate(vData); … … 3518 3675 3519 3676 mTQueue.Push(splitCandidate); 3520 3521 3522 //-- object space partition 3523 3677 } 3678 3679 3680 void HierarchyManager::PrepareOsp(const ObjectContainer &objects, 3681 AxisAlignedBox3 *forcedViewSpace) 3682 { 3524 3683 mOspTree.PrepareConstruction(objects, forcedViewSpace); 3525 3684 … … 3530 3689 mOspTree.mRoot = kdleaf; 3531 3690 3532 3691 // TODO matt: this is something different than pvs size. 3692 const int pvsSize = mOspTree.ComputePvsSize(objects); 3693 const float prop = mOspTree.mBoundingBox.GetVolume(); 3694 3695 cout << "here40 pvs size: " << pvsSize << endl; 3533 3696 // first osp traversal data 3534 3697 OspTree::OspTraversalData oData(kdleaf, … … 3542 3705 3543 3706 // compute first split candidate 3544 OspTree::OspSplitCandidate *oSplitCandidate = new OspTree::OspSplitCandidate(oData); 3707 OspTree::OspSplitCandidate *oSplitCandidate = 3708 new OspTree::OspSplitCandidate(oData); 3545 3709 mOspTree.EvalSplitCandidate(*oSplitCandidate); 3546 3710 3547 mTQueue.Push(splitCandidate); 3711 mTQueue.Push(oSplitCandidate); 3712 } 3713 3714 3715 void HierarchyManager::PrepareConstruction(const VssRayContainer &sampleRays, 3716 const ObjectContainer &objects, 3717 AxisAlignedBox3 *forcedViewSpace, 3718 RayInfoContainer &rays) 3719 { 3720 PrepareVsp(sampleRays, forcedViewSpace, rays); 3721 PrepareOsp(objects, forcedViewSpace); 3548 3722 } 3549 3723 … … 3561 3735 { 3562 3736 RayInfoContainer *rays = new RayInfoContainer(); 3563 3564 mVspTree.PrepareConstruction(sampleRays, forcedViewSpace); 3737 PrepareVsp(sampleRays, forcedViewSpace, *rays); 3565 3738 3566 3739 long startTime = GetTime(); 3567 3568 cout << "storing rays ... "; 3569 3570 Intersectable::NewMail(); 3571 3572 VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 3573 3574 //-- store rays 3575 for (rit = sampleRays.begin(); rit != rit_end; ++ rit) 3576 { 3577 VssRay *ray = *rit; 3578 3579 float minT, maxT; 3580 3581 static Ray hray; 3582 hray.Init(*ray); 3583 3584 // TODO: not very efficient to implictly cast between rays types 3585 if (mVspTree.GetBoundingBox().GetRaySegment(hray, minT, maxT)) 3586 { 3587 float len = ray->Length(); 3588 3589 if (!len) 3590 len = Limits::Small; 3591 3592 rays->push_back(RayInfo(ray, minT / len, maxT / len)); 3593 } 3594 } 3595 3596 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 3597 3598 const int pvsSize = mVspTree.ComputePvsSize(*rays); 3599 3600 3601 // -- prepare view space partition 3602 3603 // add first candidate for view space partition 3604 VspLeaf *vspleaf = new VspLeaf(); 3605 3606 mVspTree.mRoot = vspleaf; 3607 const float prop = mVspTree.mBoundingBox.GetVolume(); 3608 3609 // first vsp traversal data 3610 VspTree::VspTraversalData vData(vspleaf, 3611 0, 3612 rays, 3613 pvsSize, 3614 prop, 3615 mVspTree.mBoundingBox); 3616 3617 3618 //-- compute first split candidate 3619 VspTree::VspSplitCandidate *splitCandidate = new VspTree::VspSplitCandidate(vData); 3620 mVspTree.EvalSplitCandidate(*splitCandidate); 3621 3622 mTQueue.Push(splitCandidate); 3623 3740 cout << "starting vsp contruction ... " << endl; 3624 3741 int i = 0; 3625 3742 … … 3631 3748 GlobalTerminationCriteriaMet(splitCandidate); 3632 3749 3633 //cout << "vsp nodes: " << i ++ << endl;3750 cout << "vsp nodes: " << i ++ << endl; 3634 3751 3635 3752 // cost ratio of cost decrease / totalCost 3636 3753 const float costRatio = splitCandidate->GetPriority() / mTotalCost; 3637 // Debug<< "cost ratio: " << costRatio << endl;3754 //cout << "cost ratio: " << costRatio << endl; 3638 3755 3639 3756 if (costRatio < mTermMinGlobalCostRatio) … … 3646 3763 dynamic_cast<VspTree::VspSplitCandidate *>(splitCandidate); 3647 3764 3765 3648 3766 VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 3649 3767 3650 3768 DEL_PTR(splitCandidate); 3651 3769 } … … 3654 3772 mVspTree.mVspStats.Stop(); 3655 3773 3656 Debug << "object space" << endl; 3774 startTime = GetTime(); 3775 cout << "starting osp contruction ... " << endl; 3657 3776 3658 3777 //-- object space partition 3659 3660 mOspTree.PrepareConstruction(objects, forcedViewSpace); 3661 3662 // add first candidate for view space partition 3663 KdLeaf *leaf = new KdLeaf(NULL, 0); 3664 leaf->mObjects = objects; 3665 3666 mOspTree.mRoot = leaf; 3667 3668 3669 //-- first osp traversal data 3670 OspTree::OspTraversalData oData(leaf, 3671 0, 3672 pvsSize, 3673 prop, 3674 mOspTree.mBoundingBox); 3675 3676 3677 mOspTree.ProcessLeafObjects(leaf, NULL); 3678 3679 // compute first split candidate 3680 OspTree::OspSplitCandidate *oSplitCandidate = new OspTree::OspSplitCandidate(oData); 3681 mOspTree.EvalSplitCandidate(*oSplitCandidate); 3682 3683 mTQueue.Push(oSplitCandidate); 3778 PrepareOsp(objects, forcedViewSpace); 3684 3779 3685 3780 i = 0; … … 3733 3828 while (!FinishedConstruction()) 3734 3829 { 3735 SplitCandidate *splitCandidate = NextSplitCandidate();3736 3830 mCurrentCandidate = NextSplitCandidate(); 3831 3737 3832 const bool globalTerminationCriteriaMet = 3738 GlobalTerminationCriteriaMet( splitCandidate);3833 GlobalTerminationCriteriaMet(mCurrentCandidate); 3739 3834 3740 3835 cout << "view cells: " << i ++ << endl; 3741 3836 3742 3837 // cost ratio of cost decrease / totalCost 3743 const float costRatio = splitCandidate->GetPriority() / mTotalCost;3838 const float costRatio = mCurrentCandidate->GetPriority() / mTotalCost; 3744 3839 //Debug << "cost ratio: " << costRatio << endl; 3745 3840 … … 3750 3845 3751 3846 // we have either a object space or view space split 3752 if ( splitCandidate->Type() == SplitCandidate::VIEW_SPACE)3847 if (mCurrentCandidate->Type() == SplitCandidate::VIEW_SPACE) 3753 3848 { 3754 3849 VspTree::VspSplitCandidate *sc = 3755 dynamic_cast<VspTree::VspSplitCandidate *>( splitCandidate);3850 dynamic_cast<VspTree::VspSplitCandidate *>(mCurrentCandidate); 3756 3851 3757 3852 VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); … … 3760 3855 { 3761 3856 OspTree::OspSplitCandidate *sc = 3762 dynamic_cast<OspTree::OspSplitCandidate *>( splitCandidate);3857 dynamic_cast<OspTree::OspSplitCandidate *>(mCurrentCandidate); 3763 3858 3764 3859 KdNode *r = mOspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 3765 3860 } 3766 3861 3767 DEL_PTR(splitCandidate); 3862 // reevaluate affected candidates 3863 RepairQueue(); 3864 3865 DEL_PTR(mCurrentCandidate); 3768 3866 } 3769 3867 … … 3780 3878 3781 3879 3782 void HierarchyManager::RepairQueue(const vector<SplitCandidate *> &dirtyList) 3880 void HierarchyManager::CollectDirtyCandidates(vector<SplitCandidate *> &dirtyList) 3881 { 3882 // we have either a object space or view space split 3883 if (mCurrentCandidate->Type() == SplitCandidate::VIEW_SPACE) 3884 { 3885 VspTree::VspSplitCandidate *sc = 3886 dynamic_cast<VspTree::VspSplitCandidate *>(mCurrentCandidate); 3887 3888 mVspTree.CollectDirtyCandidates(sc, dirtyList); 3889 } 3890 else // object space split 3891 { 3892 OspTree::OspSplitCandidate *sc = 3893 dynamic_cast<OspTree::OspSplitCandidate *>(mCurrentCandidate); 3894 3895 mOspTree.CollectDirtyCandidates(sc, dirtyList); 3896 } 3897 } 3898 3899 3900 void HierarchyManager::RepairQueue() 3783 3901 { 3784 3902 // TODO … … 3799 3917 // split candidate 3800 3918 3919 // collect list of "dirty" candidates 3920 vector<SplitCandidate *> dirtyList; 3921 CollectDirtyCandidates(dirtyList); 3922 3923 //-- reevaluate the dirty list 3801 3924 vector<SplitCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 3802 3925 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1110 r1121 429 429 void SetViewCell(ViewCellLeaf *viewCell); 430 430 431 SplitCandidate *GetSplitCandidate() const 432 { return mSplitCandidate; } 433 434 public: 435 431 436 /// Rays piercing this leaf. 432 437 VssRayContainer mVssRays; … … 439 444 440 445 protected: 441 446 447 /// pointer to a split plane candidate splitting this leaf 448 SplitCandidate *mSplitCandidate; 449 442 450 /// if NULL this does not correspond to feasible viewcell 443 451 ViewCellLeaf *mViewCell; … … 986 994 float GetMemUsage() const; 987 995 988 void ProcessViewCellObjects(ViewCell *parent, ViewCell *front, ViewCell *back) const; 996 void ProcessViewCellObjects(ViewCell *parent, 997 ViewCell *front, 998 ViewCell *back) const; 989 999 990 1000 void CreateViewCell(VspTraversalData &tData); 1001 1002 void CollectDirtyCandidates(VspSplitCandidate *sc, 1003 vector<SplitCandidate *> &dirtyList); 991 1004 992 1005 protected: … … 1077 1090 /// number of currenly generated view cells 1078 1091 int mCreatedViewCells; 1092 1093 /// weight between render cost decrease and node render cost 1094 float mRenderCostDecreaseWeight; 1079 1095 }; 1080 1096 … … 1224 1240 ~OspTree(); 1225 1241 1226 /** Returns BSP Tree statistics.1227 */ 1228 const KdTreeStatistics &GetStatistics() const;1242 /** Returns tree statistics. 1243 */ 1244 const OspTreeStatistics &GetStatistics() const; 1229 1245 1230 1246 /** Returns bounding box of the specified node. … … 1310 1326 int ComputeBoxIntersections(const AxisAlignedBox3 &box, 1311 1327 ViewCellContainer &viewCells) const; 1328 1329 1330 /** Compute "pvs size of this object container 1331 @ note bot relly pvs size just weighted sum of object taking their 1332 appearances in pvss into account 1333 */ 1334 int ComputePvsSize(const ObjectContainer &objects) const; 1312 1335 1313 1336 … … 1470 1493 float &totalPvs) const; 1471 1494 1472 /** Computes PVS size induced by the rays.1473 */1474 int ComputePvsSize(const RayInfoContainer &rays) const;1475 1476 1495 /** Returns true if tree can be terminated. 1477 1496 */ … … 1535 1554 AxisAlignedBox3 *forcedBoundingBox); 1536 1555 1556 void CollectDirtyCandidates(OspSplitCandidate *sc, 1557 vector<SplitCandidate *> &dirtyList); 1558 1559 void CollectViewCells(KdLeaf *leaf, 1560 ViewCellContainer &viewCells); 1537 1561 1538 1562 protected: 1539 1563 1564 /// The view cells manager 1540 1565 ViewCellsManager *mViewCellsManager; 1566 1567 /// candidates for placing split planes during cost heuristics 1541 1568 vector<SortableEntry> *mSplitCandidates; 1542 1569 … … 1544 1571 KdNode *mRoot; 1545 1572 1573 /// Statistics for the object space partition 1546 1574 OspTreeStatistics mOspStats; 1547 1575 … … 1568 1596 1569 1597 //-- global criteria 1598 1570 1599 float mTermMinGlobalCostRatio; 1571 1600 int mTermGlobalCostMissTolerance; … … 1609 1638 /// represents min and max band for sweep 1610 1639 float mSplitBorder; 1640 1641 /// weight between render cost decrease and node render cost 1642 float mRenderCostDecreaseWeight; 1611 1643 }; 1612 1644 … … 1656 1688 const ObjectContainer &objects, 1657 1689 AxisAlignedBox3 *forcedViewSpace); 1690 1658 1691 public: 1659 1692 VspTree &mVspTree; … … 1670 1703 1671 1704 bool FinishedConstruction(); 1705 1672 1706 SplitCandidate *NextSplitCandidate(); 1673 1707 1674 void RepairQueue(const vector<SplitCandidate *> &dirtyList); 1708 void RepairQueue(); 1709 1710 void CollectDirtyCandidates(vector<SplitCandidate *> &dirtyList); 1711 1712 void PrepareVsp(const VssRayContainer &sampleRays, 1713 AxisAlignedBox3 *forcedViewSpace, 1714 RayInfoContainer &rays); 1715 1716 void PrepareOsp(const ObjectContainer &objects, AxisAlignedBox3 *forcedViewSpace); 1717 1718 void ProcessRays(const VssRayContainer &sampleRays, 1719 RayInfoContainer &rays, 1720 ObjectContainer &sampledObjects); 1721 1722 1723 protected: 1675 1724 1676 1725 AxisAlignedBox3 mBoundingBox; 1677 1726 1678 1727 SplitQueue mTQueue; 1728 1729 SplitCandidate *mCurrentCandidate; 1679 1730 1680 1731 //-- global criteria -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r1112 r1121 1292 1292 1293 1293 1294 bool X3dExporter::ExportOspTree(const OspTree &ospTree) 1295 { 1296 vector<KdLeaf *> leaves; 1297 ospTree.CollectLeaves(leaves); 1298 1299 mUseForcedMaterial = true; 1300 1301 vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 1302 1303 for (it = leaves.begin(); it != it_end; ++ it) 1304 { 1305 SetWireframe(); 1306 ExportBox(ospTree.GetBBox(*it)); 1307 1308 SetForcedMaterial(RandomMaterial()); 1309 1310 ExportGeometry((*it)->mObjects); 1311 } 1312 1313 return true; 1314 } 1315 1316 1317 } 1318 1294 } 1295 -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.h
r1112 r1121 60 60 ); 61 61 62 bool 63 ExportOspTree(const OspTree &tree); 62 // bool ExportOspTree(const OspTree &tree); 64 63 65 64 bool ExportBspTree(const BspTree &tree);
Note: See TracChangeset
for help on using the changeset viewer.