Changeset 1680
- Timestamp:
- 10/26/06 11:09:58 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh
r1679 r1680 12 12 13 13 #SCENE=vsposp_typical 14 #SCENE=soda5_vsposp14 SCENE=soda5_vsposp 15 15 #SCENE=soda_vsposp 16 SCENE=vienna_vsposp16 #SCENE=vienna_vsposp 17 17 #SCENE=arena_vsposp 18 18 #SCENE=vsposp_citymodel … … 86 86 echo "$SCENE $METHOD" 87 87 88 $PROGRAM $ENVIRONMENT \88 # $PROGRAM $ENVIRONMENT \ 89 89 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 90 90 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 107 107 echo "$SCENE $METHOD" 108 108 109 $PROGRAM $ENVIRONMENT \109 #$PROGRAM $ENVIRONMENT \ 110 110 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 111 111 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 131 131 echo "$SCENE $METHOD" 132 132 133 $PROGRAM $ENVIRONMENT \133 # $PROGRAM $ENVIRONMENT \ 134 134 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 135 135 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 149 149 echo "$SCENE $METHOD" 150 150 151 $PROGRAM $ENVIRONMENT \151 #$PROGRAM $ENVIRONMENT \ 152 152 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 153 153 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 168 168 echo "$SCENE $METHOD" 169 169 170 $PROGRAM $ENVIRONMENT \170 # $PROGRAM $ENVIRONMENT \ 171 171 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 172 172 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 187 187 echo "$SCENE $METHOD" 188 188 189 $PROGRAM $ENVIRONMENT \189 # $PROGRAM $ENVIRONMENT \ 190 190 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 191 191 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 204 204 echo "$SCENE $METHOD" 205 205 206 $PROGRAM $ENVIRONMENT \206 #$PROGRAM $ENVIRONMENT \ 207 207 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 208 208 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1679 r1680 332 332 333 333 334 void BvHierarchy::UpdateNode(const BvhSubdivisionCandidate &sc) 335 { 336 BvhInterior *node = NULL;//sc->mParentData.mNode; 337 //AssociateObjectsWithLeaf(node->GetBack()); 338 //AssociateObjectsWithLeaf(node->GetFront()); 339 340 node->mRenderCostDecr += sc.GetRenderCostDecrease(); 341 node->mPvsEntriesIncr += sc.GetPvsEntriesIncr(); 342 343 } 344 345 334 346 BvhInterior *BvHierarchy::SubdivideNode(const BvhSubdivisionCandidate &sc, 335 347 BvhTraversalData &frontData, … … 418 430 // set the time stamp so the order of traversal can be reconstructed 419 431 node->mTimeStamp = mHierarchyManager->mTimeStamp ++; 420 cout << "here4 " << node->mTimeStamp << endl;432 //cout << "here4 " << node->mTimeStamp << endl; 421 433 node->mRenderCostDecr = sc.GetRenderCostDecrease(); 422 434 node->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); … … 1281 1293 if (useVisibilityBasedHeuristics) 1282 1294 { 1283 //cout << "v";1295 cout << "v"; 1284 1296 /////////// 1285 1297 //-- heuristics using objects weighted by view cells volume … … 1288 1300 } 1289 1301 else 1290 { //cout << "e";1302 { cout << "e"; 1291 1303 ////////////////// 1292 1304 //-- view cells not constructed yet => use surface area heuristic … … 1668 1680 { 1669 1681 // rather use the simple version 1670 if (!object) return NULL; 1682 if (!object) 1683 return NULL; 1684 1671 1685 return object->mBvhLeaf; 1672 1686 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1679 r1680 468 468 } 469 469 470 471 470 /// pointer to parent tree. 472 471 static BvHierarchy *sBvHierarchy; 472 473 473 /// parent data 474 474 BvhTraversalData mParentData; … … 516 516 /** Evaluates candidate for splitting. 517 517 */ 518 void EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitData, bool computeSplitPlane = true); 518 void EvalSubdivisionCandidate(BvhSubdivisionCandidate &splitData, 519 bool computeSplitPlane = true); 519 520 520 521 /** Returns list of leaves with pvs smaller than … … 532 533 */ 533 534 BvhNode *GetRoot() const; 534 535 /** A ray is cast possible intersecting the tree.536 @param the ray that is cast.537 @returns the number of intersections with objects stored in the tree.538 */539 //int CastRay(Ray &ray);540 535 541 536 /** finds neighbouring leaves of this tree node. … … 601 596 */ 602 597 float GetMemUsage() const; 598 599 void UpdateNode(const BvhSubdivisionCandidate &sc); 603 600 604 601 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1679 r1680 1575 1575 } 1576 1576 1577 } 1577 /*typedef priority_queue<ViewCell *, vector<ViewCell *>, 1578 myless<vector<ViewCell *>::value_type> > ViewCellsQueue; 1579 1580 typedef priority_queue<BvhNode *, vector<BvhNode *>, 1581 myless<vector<BvhNode *>::value_type> > BvhQueue; 1582 1583 typedef priority_queue<VspNode *, vector<VspNode *>, 1584 myless<vector<VspNode *>::value_type> > VspQueue; 1585 */ 1586 static void UpdateStats(ofstream &stats, 1587 const int splits, 1588 const float totalRenderCost, 1589 const int entriesInPvs, 1590 const float memoryCost, 1591 const bool vsp) 1592 { 1593 stats << "#Pass\n" << 0 << endl 1594 << "#Splits\n" << splits << endl 1595 << "#TotalRenderCost\n" << totalRenderCost << endl 1596 << "#TotalEntriesInPvs\n" << entriesInPvs << endl 1597 << "#Memory\n" << memoryCost << endl 1598 << "#Vsp\n" << (vsp ? 1 : 0) << endl 1599 << endl; 1600 } 1601 1602 1603 void HierarchyManager::EvaluateSubdivision(const VssRayContainer &sampleRays, 1604 const ObjectContainer &objects, 1605 const string &filename) 1606 { 1607 mHierarchyStats.Reset(); 1608 mHierarchyStats.Start(); 1609 1610 mHierarchyStats.mNodes = 2; 1611 1612 VspTree *oldVspTree = mVspTree; 1613 //BvHierarchy *oldHierarchy = mBvHierarchy; 1614 1615 //mBvHierarchy = new BvHierarchy(); 1616 //mBvHierarchy->mHierarchyManager = this; 1617 1618 mVspTree = new VspTree(); 1619 mVspTree->mHierarchyManager = this; 1620 1621 // create first nodes 1622 mVspTree->Initialise(sampleRays, &oldVspTree->mBoundingBox); 1623 InitialiseObjectSpaceSubdivision(objects); 1624 1625 // hack: assume that object space can be seen from view space 1626 mHierarchyStats.mTotalCost = mInitialRenderCost = (float)objects.size(); 1627 1628 // only one entry for start 1629 mHierarchyStats.mPvsEntries = 1; 1630 mHierarchyStats.mMemory = (float)ObjectPvs::GetEntrySizeByte(); 1631 1632 EvalSubdivisionStats(); 1633 Debug << "setting total cost to " << mHierarchyStats.mTotalCost << endl; 1634 1635 const long startTime = GetTime(); 1636 cout << "Constructing view space / object space tree ... \n"; 1637 1638 ExportStats(filename, objects, oldVspTree); 1639 1640 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 1641 1642 mHierarchyStats.Stop(); 1643 mVspTree->mVspStats.Stop(); 1644 1645 FinishObjectSpaceSubdivision(objects, !mUseMultiLevelConstruction); 1646 } 1647 1648 1649 void HierarchyManager::ExportStats(const string &mergeStats, 1650 const ObjectContainer &objects, 1651 VspTree *oldVspTree) 1652 { 1653 ofstream stats; 1654 stats.open(mergeStats.c_str()); 1655 /* 1656 BvhQueue bvhQueue; 1657 VspQueue vspQueue; 1658 //ViewCellsQueue viewCellsQueue; 1659 1660 bvhQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 1661 vspQueue.push(mHierarchyManager->GetVspTree()->GetRoot()); 1662 1663 int numSteps = 1; 1664 1665 const AxisAlignedBox3 box = mViewSpaceBox; 1666 const float vol = box.GetVolume(); 1667 */ 1668 float totalRenderCost = (float)objects.size();//(float)mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 1669 int entriesInPvs = 1;//mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 1670 1671 cout << "exporting vsposp stats ... " << endl; 1672 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 1673 1674 ///////////// 1675 //-- first view cell 1676 // UpdateStats(stats, 2, totalRenderCost, entriesInPvs, memoryCost, true); 1677 1678 1679 /* 1680 1681 1682 //-- go through tree in the order of render cost decrease 1683 //-- which is the same order as the view cells were merged 1684 //-- or the reverse order of subdivision for subdivision-only 1685 //-- view cell hierarchies. 1686 int i = 0; 1687 while (!(bvhQueue.empty() && vspQueue.empty())) 1688 { 1689 const float vspCost = !vspQueue.empty() ? vspQueue.top()->GetMergeCost() : -99999999.0; 1690 const float ospCost = !bvhQueue.empty() ? bvhQueue.top()->GetMergeCost() : -99999999.0; 1691 1692 if (vspCost > ospCost) 1693 { 1694 cout << "vsp: " << (int)-vspCost << endl; 1695 cout << "v"; 1696 VspNode *vspNode = vspQueue.top(); 1697 1698 if (!vspNode) 1699 { 1700 cerr << "big error!" << endl; 1701 break; 1702 } 1703 1704 vspQueue.pop(); 1705 1706 vspNode->mParent->SetupChildLink(); 1707 1708 if (!vspNode->IsLeaf()) 1709 { 1710 SubdivisionCandidate sc = new VspSubdivisionCandidate(); 1711 1712 mVspTree->EvalPriority(sc, false); 1713 1714 UpdateStats(stats, splits 1715 totalRenderCost -= vspNode->mRenderCostDecr; 1716 entriesInPvs += vspNode->mPvsEntriesIncr; 1717 1718 splits ++; 1719 1720 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 1721 UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, true); 1722 1723 VspNode *front = dynamic_cast<VspInterior *>(vspNode)->GetFront(); 1724 VspNode *back= dynamic_cast<VspInterior *>(vspNode)->GetBack(); 1725 1726 RecreateLeaves(); 1727 if (!front->IsLeaf()) 1728 { 1729 SuddivisionCandidate *candidate = new SubdivisionCandidate; 1730 candidate->mParentData.mNode ? front; 1731 candidate->mParentData.mrays = 0; 1732 SuddivisionCandidate *candidate2 = new SubdivisionCandidate; 1733 candidate->mParentData.mNode = back; 1734 candidate->mParentData.mrays = 0; 1735 1736 1737 vspQueue.push(front); 1738 if (!back->IsLeaf()) 1739 vspQueue.push(back); 1740 } 1741 } 1742 } 1743 else // object space split 1744 { 1745 cout << "o"; 1746 BvhNode *bvhNode = bvhQueue.top(); 1747 cout << "bvh: " << (int)-ospCost << endl; 1748 if (!bvhNode) 1749 { 1750 cerr << "big error!" << endl; 1751 break; 1752 } 1753 bvhQueue.pop(); 1754 1755 if (!bvhNode->IsLeaf()) 1756 { 1757 totalRenderCost -= bvhNode->mRenderCostDecr; 1758 entriesInPvs += bvhNode->mPvsEntriesIncr; 1759 1760 i ++; 1761 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 1762 UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, false); 1763 1764 BvhNode *front = dynamic_cast<BvhInterior *>(bvhNode)->GetFront(); 1765 BvhNode *back= dynamic_cast<BvhInterior *>(bvhNode)->GetBack(); 1766 1767 if (!front->IsLeaf()) 1768 bvhQueue.push(front); 1769 if (!back->IsLeaf()) 1770 bvhQueue.push(back); 1771 } 1772 } 1773 cout << i << endl; 1774 1775 } 1776 */ 1777 stats.close(); 1778 } 1779 1780 1781 } -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1679 r1680 440 440 441 441 442 void EvaluateSubdivision(const VssRayContainer &sampleRays, 443 const ObjectContainer &objects, 444 const string &filename); 445 446 void ExportStats(const string &mergeStats, const ObjectContainer &objects, VspTree *oldVspTree); 442 447 protected: 443 448 -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1615 r1680 12 12 class KdLeaf; 13 13 class BvhLeaf; 14 14 class BvhNode; 15 15 class Intersectable; 16 16 struct Face; … … 45 45 int mCounter; 46 46 47 /// pointer to the contain erbvh leaf47 /// pointer to the containing bvh leaf 48 48 BvhLeaf *mBvhLeaf; 49 49 //BvhNode *mBvhLeaf; 50 50 /// some rays piercing this intersectable 51 51 VssRayContainer mVssRays; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1679 r1680 5619 5619 5620 5620 5621 typedef priority_queue<ViewCell *, vector<ViewCell *>,5622 myless<vector<ViewCell *>::value_type> > ViewCellsQueue;5623 5624 typedef priority_queue<BvhNode *, vector<BvhNode *>,5625 myless<vector<BvhNode *>::value_type> > BvhQueue;5626 5627 typedef priority_queue<VspNode *, vector<VspNode *>,5628 myless<vector<VspNode *>::value_type> > VspQueue;5629 5630 static void UpdateStats(ofstream &stats,5631 const int splits,5632 const float totalRenderCost,5633 const int entriesInPvs,5634 const float memoryCost,5635 const bool vsp)5636 {5637 stats << "#Pass\n" << 0 << endl5638 << "#Splits\n" << splits << endl5639 << "#TotalRenderCost\n" << totalRenderCost << endl5640 << "#TotalEntriesInPvs\n" << entriesInPvs << endl5641 << "#Memory\n" << memoryCost << endl5642 << "#Vsp\n" << (vsp ? 1 : 0) << endl5643 << endl;5644 }5645 5646 /*5647 void VspOspViewCellsManager::ExportStats(const string &mergeStats)5648 {5649 ofstream stats;5650 stats.open(mergeStats.c_str());5651 5652 BvhQueue bvhQueue;5653 VspQueue vspQueue;5654 //ViewCellsQueue viewCellsQueue;5655 5656 bvhQueue.push(mHierarchyManager->mBvHierarchy->GetRoot());5657 vspQueue.push(mHierarchyManager->GetVspTree()->GetRoot());5658 5659 int numSteps = 1;5660 5661 const AxisAlignedBox3 box = mViewSpaceBox;5662 const float vol = box.GetVolume();5663 5664 float totalRenderCost = (float)mPreprocessor->mObjects.size();//(float)mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot());5665 int entriesInPvs = 1;//mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot());5666 5667 cout << "exporting vsposp stats ... " << endl;5668 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize();5669 5670 /////////////5671 //-- first view cell5672 UpdateStats(stats, 2, totalRenderCost, entriesInPvs, memoryCost, true);5673 5674 //-- go through tree in the order of render cost decrease5675 //-- which is the same order as the view cells were merged5676 //-- or the reverse order of subdivision for subdivision-only5677 //-- view cell hierarchies.5678 int i = 0;5679 while (!(bvhQueue.empty() && vspQueue.empty()))5680 {5681 const float vspCost = !vspQueue.empty() ? vspQueue.top()->GetMergeCost() : -99999999.0;5682 const float ospCost = !bvhQueue.empty() ? bvhQueue.top()->GetMergeCost() : -99999999.0;5683 5684 if (vspCost > ospCost)5685 {5686 cout << "vsp: " << (int)-vspCost << endl;5687 cout << "v";5688 VspNode *vspNode = vspQueue.top();5689 5690 if (!vspNode)5691 {5692 cerr << "big error!" << endl;5693 break;5694 }5695 vspQueue.pop();5696 5697 if (!vspNode->IsLeaf())5698 {5699 totalRenderCost -= vspNode->mRenderCostDecr;5700 entriesInPvs += vspNode->mPvsEntriesIncr;5701 5702 i ++;5703 5704 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize();5705 UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, true);5706 5707 VspNode *front = dynamic_cast<VspInterior *>(vspNode)->GetFront();5708 VspNode *back= dynamic_cast<VspInterior *>(vspNode)->GetBack();5709 5710 if (!front->IsLeaf())5711 vspQueue.push(front);5712 if (!back->IsLeaf())5713 vspQueue.push(back);5714 }5715 }5716 else // object space split5717 {5718 cout << "o";5719 BvhNode *bvhNode = bvhQueue.top();5720 cout << "bvh: " << (int)-ospCost << endl;5721 if (!bvhNode)5722 {5723 cerr << "big error!" << endl;5724 break;5725 }5726 bvhQueue.pop();5727 5728 if (!bvhNode->IsLeaf())5729 {5730 totalRenderCost -= bvhNode->mRenderCostDecr;5731 entriesInPvs += bvhNode->mPvsEntriesIncr;5732 5733 i ++;5734 const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize();5735 UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, false);5736 5737 BvhNode *front = dynamic_cast<BvhInterior *>(bvhNode)->GetFront();5738 BvhNode *back= dynamic_cast<BvhInterior *>(bvhNode)->GetBack();5739 5740 if (!front->IsLeaf())5741 bvhQueue.push(front);5742 if (!back->IsLeaf())5743 bvhQueue.push(back);5744 }5745 }5746 cout << i << endl;5747 5748 }5749 5750 stats.close();5751 }5752 */5753 5754 5621 #if TEST_EVALUATION 5755 5622 void VspOspViewCellsManager::EvalViewCellPartition() -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1679 r1680 980 980 // set the time stamp so the order of traversal can be reconstructed 981 981 interior->mTimeStamp = mHierarchyManager->mTimeStamp ++; 982 cout << "here6 " << interior->mTimeStamp << endl;982 983 983 return interior; 984 } 985 986 void VspTree::UpdateNode(const AxisAlignedPlane &splitPlane, 987 VspTraversalData &tData, 988 VspTraversalData &frontData, 989 VspTraversalData &backData) 990 { 991 VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 992 /* 993 // replace a link from node's parent 994 if (parent) 995 { 996 parent->ReplaceChildLink(leaf, interior); 997 interior->SetParent(parent); 998 } 999 else // new root 1000 { 1001 mRoot = interior; 1002 } 1003 1004 VspLeaf *frontLeaf = new VspLeaf(interior); 1005 VspLeaf *backLeaf = new VspLeaf(interior); 1006 1007 // and setup child links 1008 interior->SetupChildLinks(frontLeaf, backLeaf); 1009 1010 // add bounding box 1011 interior->SetBoundingBox(tData.mBoundingBox); 1012 1013 // set front and back leaf 1014 frontData.mNode = frontLeaf; 1015 backData.mNode = backLeaf; 1016 1017 // explicitely create front and back view cell 1018 CreateViewCell(frontData, false); 1019 CreateViewCell(backData, false); 1020 */ 984 1021 } 985 1022 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1679 r1680 693 693 #endif 694 694 695 void UpdateNode(const AxisAlignedPlane &splitPlane, 696 VspTraversalData &tData, 697 VspTraversalData &frontData, 698 VspTraversalData &backData); 695 699 protected: 696 700
Note: See TracChangeset
for help on using the changeset viewer.