- Timestamp:
- 02/18/06 18:02:12 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env
r650 r651 36 36 loadInitialSamples false 37 37 storeInitialSamples false 38 useViewSpaceBox false38 useViewSpaceBox true 39 39 # testBeamSampling true 40 40 } … … 185 185 186 186 exportToFile false 187 loadFromFile false187 loadFromFile true 188 188 189 189 #type kdTree 190 190 #type vspKdTree 191 type bspTree192 #type vspBspTree191 #type bspTree 192 type vspBspTree 193 193 194 194 #type sceneDependent … … 288 288 VspBspTree { 289 289 Construction { 290 samples 50000 0290 samples 50000 291 291 epsilon 0.00005 292 292 randomize false … … 420 420 minProbability 0.00001 421 421 maxRayContribution 9999 422 maxViewCells 100 422 maxViewCells 1000 423 423 424 424 # used for pvs criterium -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r650 r651 1262 1262 1263 1263 int totalPvs; 1264 float totalRenderCost, float avgRenderCost, floatexpectedCost;1264 float totalRenderCost, avgRenderCost, expectedCost; 1265 1265 1266 1266 float deviation = 0; … … 1270 1270 ofstream stats; 1271 1271 stats.open("mergeStats.log"); 1272 1273 Debug << "here343" << endl;1274 1272 1275 1273 stats … … 1347 1345 1348 1346 1349 /*float ViewCellsTree::ComputeVolume(ViewCell *vc) 1347 #if 0 1348 float ViewCellsTree::ComputeVolume(ViewCell *vc) 1350 1349 { 1351 1350 if (vc->IsLeaf()) … … 1369 1368 return volume; 1370 1369 } 1371 } */1372 1370 } 1371 #endif 1373 1372 1374 1373 void ViewCellsTree::SetRoot(ViewCell *root) … … 1621 1620 1622 1621 1623 void ViewCellsTree::Propagate UpPvs(ViewCell *vc)1622 void ViewCellsTree::PropagatePvs(ViewCell *vc) 1624 1623 { 1625 1624 while (vc->GetParent()) … … 1627 1626 vc->GetParent()->GetPvs().Merge(vc->GetPvs()); 1628 1627 vc = vc->GetParent(); 1628 } 1629 1630 if (vc->IsLeaf()) 1631 return; 1632 1633 stack<ViewCell *> tstack; 1634 1635 tstack.push(vc); 1636 1637 while (!tstack.empty()) 1638 { 1639 ViewCell *viewCell = tstack.top(); 1640 tstack.pop(); 1641 1642 if (viewCell != vc) 1643 { 1644 viewCell->GetPvs().Merge(vc->GetPvs()); 1645 } 1646 1647 if (!viewCell->IsLeaf()) 1648 { 1649 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell); 1650 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1651 1652 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1653 { 1654 tstack.push(*it); 1655 } 1656 } 1629 1657 } 1630 1658 } … … 1727 1755 1728 1756 1757 void ViewCellsTree::CreateUniqueViewCellsIds() 1758 { 1759 stack<ViewCell *> tstack; 1760 1761 int currentId = 0; 1762 1763 tstack.push(mRoot); 1764 1765 while (!tstack.empty()) 1766 { 1767 ViewCell *vc = tstack.top(); 1768 tstack.pop(); 1769 1770 vc->SetId(currentId ++); 1771 1772 if (!vc->IsLeaf()) 1773 { 1774 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1775 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1776 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1777 { 1778 tstack.push(*it); 1779 } 1780 } 1781 } 1782 } 1783 1784 1729 1785 void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream) 1730 1786 { 1731 1787 ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 1732 1733 if (0) // test with empty pvs1734 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it)1735 {1736 stream << (*it).first->GetId() << " ";1737 }1738 1739 stream << "\" />" << endl;1740 1788 1741 1789 if (viewCell->IsLeaf()) … … 1746 1794 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 1747 1795 stream << "pvs=\""; 1748 stream << "</Leaf>" << endl; 1796 if (0)// test with empty pvs 1797 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 1798 { 1799 stream << (*it).first->GetId() << " "; 1800 } 1801 1802 1803 stream << "\" />" << endl; 1804 //stream << " </Leaf>" << endl; 1749 1805 } 1750 1806 else … … 1757 1813 stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 1758 1814 stream << "pvs=\""; 1815 1816 if (0)// test with empty pvs 1817 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 1818 { 1819 stream << (*it).first->GetId() << " "; 1820 } 1821 1822 stream << "\" >" << endl; 1759 1823 1760 1824 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r650 r651 301 301 */ 302 302 int RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 303 304 303 304 /** Assign colors to the viewcells so that they can be renderered interactively without 305 305 color flickering. 306 */ 307 void AssignRandomColors(); 306 */ 307 void AssignRandomColors(); 308 308 309 /** Updates view cell stats for this particular view cell 309 310 */ … … 311 312 312 313 313 314 314 /** Get costs resulting from each merge step. */ 315 void GetCostFunction(vector<float> &costFunction); 315 316 316 317 … … 351 352 ViewCell *GetActiveViewCell(ViewCell *vc) const; 352 353 353 /** Propagates pvs up the tree to the root .354 */ 355 void Propagate UpPvs(ViewCell *vc);354 /** Propagates pvs up the tree to the root and downwards the tree. 355 */ 356 void PropagatePvs(ViewCell *vc); 356 357 357 358 bool Export(ofstream &stream); … … 366 367 367 368 //float ComputeVolume(ViewCell *vc); 369 370 /** Assignes unique ids to view cells. 371 */ 372 void CreateUniqueViewCellsIds(); 373 368 374 369 375 protected: -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r650 r651 908 908 void ViewCellsManager::CreateUniqueViewCellIds() 909 909 { 910 for (int i = 0; i < (int)mViewCells.size(); ++ i) 911 mViewCells[i]->SetId(i); 910 if (ViewCellsTreeConstructed()) 911 mViewCellsTree->CreateUniqueViewCellsIds(); 912 else 913 for (int i = 0; i < (int)mViewCells.size(); ++ i) 914 mViewCells[i]->SetId(i); 912 915 } 913 916 … … 2948 2951 2949 2952 2950 if ( 0) // export view cells2953 if (1) // export view cells 2951 2954 { // hack pvs 2952 2955 int savedColorCode = mColorCode; 2953 mColorCode = 1;2956 mColorCode = 0; 2954 2957 Exporter *exporter = Exporter::GetExporter("final_view_cells.x3d"); 2955 2958 … … 3169 3172 exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 3170 3173 } 3171 3172 3174 3173 3175 3174 3176 if (1) … … 3195 3197 } 3196 3198 3197 3198 3199 3199 3200 3200 exporter->SetWireframe(); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r650 r651 531 531 protected: 532 532 533 struct TraversalData534 {535 ViewCellInterior *mParentViewCell;536 BspNode *mNode;537 538 539 TraversalData() {}540 TraversalData(BspNode *node, ViewCellInterior *vc):541 mNode(node), mParentViewCell(vc)542 {}543 544 bool operator<(const TraversalData &b) const545 {546 return mNode->mTimeStamp < b.mNode->mTimeStamp;547 }548 };549 550 typedef priority_queue<TraversalData> TraversalQueue;551 533 552 534 /** HACK … … 765 747 protected: 766 748 767 struct TraversalData 768 { 769 ViewCellInterior *mParentViewCell; 770 BspNode *mNode; 771 772 773 TraversalData() {} 774 TraversalData(BspNode *node, ViewCellInterior *vc): 775 mNode(node), mParentViewCell(vc) 776 {} 777 778 bool operator<(const TraversalData &b) const 779 { 780 return mNode->mTimeStamp < b.mNode->mTimeStamp; 781 } 782 }; 783 784 typedef priority_queue<TraversalData> TraversalQueue; 785 749 786 750 /** Returns node of the spatial hierarchy corresponding to the view cell 787 751 if such a node exists. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r590 r651 70 70 , mVspBspTree(NULL) 71 71 , mBspTree(NULL) 72 , mViewCellsTree(NULL) 73 , mParseViewCells(true) 74 , mCurrentViewCell(NULL) 75 , mCurrentBspNode(NULL) 72 76 { 73 77 mObjects = objects; … … 89 93 StrX lname(name); 90 94 string element(lname.LocalForm()); 91 if (element == "Interior") 92 EndBspInterior(); 95 93 96 if (element == "ViewCells") 94 97 EndViewCells(); 98 99 if (mParseViewCells) 100 { 101 if (element == "Interior") 102 EndViewCellInterior(); 103 } 104 else 105 { 106 if (element == "Interior") 107 EndBspInterior(); 108 } 95 109 } 96 110 … … 105 119 } 106 120 121 122 void ViewCellsParseHandlers::EndViewCellInterior() 123 { 124 // go one up in the tree 125 if (mCurrentViewCell->GetParent()) 126 { cout << "]"; 127 mCurrentViewCell = mCurrentViewCell->GetParent(); 128 } 129 } 107 130 108 131 inline bool vlt(ViewCell *v1, ViewCell *v2) … … 151 174 if (element == "Leaf") 152 175 { 176 cout << "l"; 177 Debug << "leaf" << endl; 153 178 StartBspLeaf(attributes); 154 179 } … … 163 188 164 189 // decides the used view cell hierarchy 190 if (element == "ViewCells") 191 { 192 cout << "parsing view cells" << endl; 193 mParseViewCells = true; 194 } 195 165 196 if (element == "Hierarchy") 166 197 { 167 cout << "h"; 198 cout << "parsing spatial hierarchy" << endl; 199 mParseViewCells = false; 168 200 StartHierarchy(attributes); 169 201 } … … 172 204 if (element == "ViewSpaceBox") 173 205 { 174 cout << " vsb";206 cout << "b"; 175 207 StartViewSpaceBox(attributes); 176 208 } 177 209 178 if (element == "ViewCell")179 {180 cout << "v";181 StartViewCell(attributes);182 }183 210 184 211 // use different methods for the given view cell hierarchy types 185 if (mViewCellsManager) 186 { 187 switch (mViewCellsManager->GetType()) 188 { 189 case ViewCellsManager::BSP: 190 case ViewCellsManager::VSP_BSP: 191 startBspElement(element, attributes); 192 break; 212 if (!mParseViewCells) 213 { 214 if (mViewCellsManager) 215 { 216 switch (mViewCellsManager->GetType()) 217 { 218 case ViewCellsManager::BSP: 219 case ViewCellsManager::VSP_BSP: 220 startBspElement(element, attributes); 221 break; 193 222 194 default: 195 Debug << "not implemented" << endl; 196 break; 223 default: 224 Debug << "not implemented" << endl; 225 break; 226 } 227 } 228 } 229 else 230 { 231 if (element == "Interior") 232 { 233 cout << "["; 234 StartViewCellInterior(attributes); 235 } 236 237 if (element == "Leaf") 238 { 239 cout << "l"; 240 StartViewCellLeaf(attributes); 197 241 } 198 242 } … … 209 253 210 254 211 void ViewCellsParseHandlers::StartViewCell( AttributeList& attributes)255 void ViewCellsParseHandlers::StartViewCell(ViewCell *viewCell, AttributeList& attributes) 212 256 { 213 257 int len = attributes.getLength(); 214 258 vector<int> objIndices; 215 216 //hack!! 217 218 ViewCell *viewCell = new ViewCellInterior();//mViewCellsManager->GenerateViewCell(); 219 viewCell->mIsActive = true; 220 221 mViewCells.push_back(viewCell); 222 259 223 260 for (int i = 0; i < len; ++ i) 224 261 { … … 284 321 viewCell->SetId(id); 285 322 } 323 else if (attrName == "active") 324 { 325 StrX attrValue(attributes.getValue(i)); 326 327 const char *ptr = attrValue.LocalForm(); 328 char *endptr = NULL; 329 const bool isActive = (bool)strtol(ptr, &endptr, 10); 330 331 viewCell->mIsActive = isActive; 332 } 333 else if (attrName == "mergecost") 334 { 335 StrX attrValue(attributes.getValue(i)); 336 337 const char *ptr = attrValue.LocalForm(); 338 char *endptr = NULL; 339 const float cost = (float)strtod(ptr, &endptr); 340 341 viewCell->SetMergeCost(cost); 342 } 286 343 } 287 344 } … … 357 414 } 358 415 } 359 416 Debug << "here22" << endl; 360 417 361 418 if (viewCellId >= 0) // valid view cell … … 368 425 lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 369 426 370 ViewCellInterior *viewCell = dynamic_cast<ViewCellInterior *>(*vit); 371 372 // giant hack!! 373 BspViewCell *l = dynamic_cast<BspViewCell *>(mViewCellsManager->GenerateViewCell()); 374 viewCell->SetupChildLink(l); 427 BspViewCell *viewCell = dynamic_cast<BspViewCell *>(*vit); 428 429 Debug << "here44" << endl; 375 430 376 431 if (viewCell->GetId() == viewCellId) 377 432 { 378 leaf->SetViewCell( l);379 l->mLeaf = leaf;433 leaf->SetViewCell(viewCell); 434 viewCell->mLeaf = leaf; 380 435 } 381 436 else … … 392 447 mVspBspTree->PropagateUpValidity(leaf); 393 448 } 394 } 449 }Debug << "here33" << endl; 395 450 } 396 451 … … 439 494 440 495 496 void ViewCellsParseHandlers::StartViewCellLeaf(AttributeList& attributes) 497 { 498 Debug << "here111" << endl; 499 BspViewCell *viewCell = new BspViewCell(); 500 501 if (mCurrentViewCell) // replace front or (if not NULL) back child 502 { 503 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 504 interior->SetupChildLink(viewCell); 505 } 506 else // root 507 { 508 mViewCellsTree->SetRoot(viewCell); 509 } 510 511 StartViewCell(viewCell, attributes); 512 513 // collect leaves 514 mViewCells.push_back(viewCell); 515 } 516 517 518 void ViewCellsParseHandlers::StartViewCellInterior(AttributeList& attributes) 519 { 520 Debug << "here222" << endl; 521 ViewCellInterior* interior = new ViewCellInterior(); 522 523 if (mCurrentViewCell) // replace NULL child of parent with current node 524 { 525 ViewCellInterior *current = dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 526 527 current->SetupChildLink(interior); 528 } 529 else 530 { 531 mViewCellsTree->SetRoot(interior); 532 } 533 534 mCurrentViewCell = interior; 535 536 StartViewCell(interior, attributes); 537 } 538 539 441 540 442 541 void ViewCellsParseHandlers::CreateViewCellsManager(const char *name) … … 448 547 mBspTree = new BspTree(); 449 548 mBspTree->mBox = mViewSpaceBox; 450 mCurrentBspNode = mBspTree->GetRoot();549 //mCurrentBspNode = mBspTree->GetRoot(); 451 550 452 551 mViewCellsManager = new BspViewCellsManager(mBspTree); … … 457 556 458 557 mVspBspTree = new VspBspTree(); 459 mCurrentBspNode = mVspBspTree->GetRoot();558 //mCurrentBspNode = mVspBspTree->GetRoot(); 460 559 461 560 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); … … 476 575 } 477 576 577 mViewCellsTree = mViewCellsManager->GetViewCellsTree(); 478 578 mViewCellsManager->SetViewSpaceBox(mViewSpaceBox); 479 579 } … … 625 725 // assign new view cells manager 626 726 *viewCells = handler.mViewCellsManager; 627 727 628 728 if (errorCount > 0) 629 729 return false; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r590 r651 17 17 class BspTree; 18 18 class ViewCellsManager; 19 class ViewCellsTree; 19 20 20 21 class ViewCellsParseHandlers: public HandlerBase … … 67 68 VspKdTree *mVspKdTree; 68 69 BspTree *mBspTree; 69 70 ViewCellsTree *mViewCellsTree; 71 70 72 BspNode *mCurrentBspNode; 73 ViewCell *mCurrentViewCell; 74 71 75 ViewCellContainer mViewCells; 72 76 ViewCellsManager *mViewCellsManager; … … 75 79 AxisAlignedBox3 mViewSpaceBox; 76 80 81 bool mParseViewCells; 82 77 83 // Handlers for X3D 78 84 void StartBspLeaf(AttributeList& attributes); … … 80 86 void EndBspInterior(); 81 87 82 void StartViewCell( AttributeList& attributes);88 void StartViewCell(ViewCell *viewCell, AttributeList& attributes); 83 89 void EndViewCells(); 84 90 85 91 void StartHierarchy(AttributeList& attributes); 86 92 87 93 void startBspElement(string element, AttributeList& attributes); 88 94 void StartViewSpaceBox(AttributeList& attributes); 95 96 void StartViewCellLeaf(AttributeList& attributes); 97 void StartViewCellInterior(AttributeList& attributes); 98 void EndViewCellInterior(); 99 100 89 101 // ----------------------------------------------------------------------- 90 102 // Handlers for the SAX ErrorHandler interface 91 103 // ----------------------------------------------------------------------- 104 92 105 void warning(const SAXParseException& exc); 93 106 void error(const SAXParseException& exc); -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r639 r651 568 568 } 569 569 else 570 { 571 570 { 572 571 VssRayContainer dummies; 573 572 mViewCellsManager->Visualize(mObjects, dummies); 574 573 mViewCellsManager->ExportViewCells("test.xml"); 575 574 } 575 576 576 VssTree *vssTree = NULL; 577 578 577 579 578 … … 624 623 cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 625 624 cout << "#TotalSamples=" << totalSamples/1000 626 << " k#SampleContributions=" << passSampleContributions << " ("625 << "#SampleContributions=" << passSampleContributions << " (" 627 626 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 628 627 << pvsSize/(float)mObjects.size() << endl
Note: See TracChangeset
for help on using the changeset viewer.