Changeset 1284 for GTP/trunk/Lib/Vis
- Timestamp:
- 08/25/06 10:14:56 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1279 r1284 574 574 575 575 const int colorCode = 0; 576 const int maxPvs = 200;//mOspTree.GetStatistics().maxPvs;577 578 exporter->ExportOspTree(*mOspTree, colorCode == 0 ? 0 : maxPvs);576 const int maxPvs = 0;//mOspTree.GetStatistics().maxPvs; 577 578 exporter->ExportOspTree(*mOspTree, 0); 579 579 580 580 delete exporter; -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1233 r1284 95 95 return 0; 96 96 } 97 } 98 97 } 99 98 100 99 // compute leaf pvs … … 120 119 121 120 // add #objects exclusivly in this node 122 pvs += leaf->mObjects.size();121 pvs += (int)leaf->mObjects.size(); 123 122 } 124 123 else // traverse tree -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1264 r1284 104 104 ViewCell::ViewCell(): 105 105 MeshInstance(NULL), 106 mPiercingRays(0),107 106 mArea(-1), 108 107 mVolume(-1), … … 118 117 ViewCell::ViewCell(Mesh *mesh): 119 118 MeshInstance(mesh), 120 mPiercingRays(0),121 119 mArea(-1), 122 120 mVolume(-1), -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1264 r1284 191 191 bool AddPvsSample(Intersectable *sample, const float pdf, float &contribution); 192 192 193 194 193 /// Rays piercing this view cell. 195 RayContainer mPiercingRays; 196 194 //RayContainer mPiercingRays; 197 195 198 196 /** if this is a view cell correspending to a leaf in a hierarchy. … … 294 292 { 295 293 friend class ViewCellsManager; 294 296 295 public: 297 296 ViewCellInterior(); … … 300 299 ViewCellInterior(Mesh *mesh); 301 300 302 303 301 /** Sets pointer from parent to child and vice versa. 304 302 */ … … 307 305 bool IsLeaf() const; 308 306 309 ViewCellContainer mChildren; 310 311 void SetCost(const float c) { 312 mCost = c; 313 } 314 float GetCost() const { 315 return mCost; 316 } 307 void SetCost(const float c) { 308 mCost = c; 309 } 310 311 float GetCost() const { 312 return mCost; 313 } 317 314 315 ViewCellContainer mChildren; 316 318 317 protected: 319 318 /** overall cost resulting from the merge */ -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1278 r1284 264 264 } 265 265 266 void ViewCellsManager::CollectEmptyViewCells()267 {268 mEmptyViewCells.clear();269 ViewCellContainer leaves;270 mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves);271 272 ViewCellContainer::const_iterator it, it_end = leaves.end();273 274 cout << "collecting empty view cells" << endl;275 276 for (it = leaves.begin(); it != it_end; ++ it)277 {278 if ((*it)->GetPvs().Empty())279 {280 mEmptyViewCells.push_back(*it);281 }282 }283 Debug << "empty view cells found: " << (int)mEmptyViewCells.size() << endl;284 }285 286 266 287 267 bool ViewCellsManager::EqualToSpatialNode(ViewCell *viewCell) const 288 268 { 289 269 return false; 290 }291 292 293 void ViewCellsManager::TestEmptyViewCells(const ObjectContainer &obj)294 {295 ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end();296 297 char buf[50];298 int i = 0;299 for (it = mEmptyViewCells.begin(); it != it_end; ++ it)300 {301 if (!(*it)->GetPvs().Empty())302 {303 sprintf(buf, "empty-viewcells-%09d.x3d", i/*(*it)->GetId()*/);304 Exporter *exporter = Exporter::GetExporter(buf);305 306 if (exporter && i < 20)307 {308 Ray *pray = (*it)->mPiercingRays[0];309 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: "310 << (*it)->GetPvs().CountObjectsInPvs() << " " << (int)pray->intersections.size() << endl;311 312 exporter->ExportRays((*it)->mPiercingRays);313 314 exporter->SetFilled();315 exporter->SetForcedMaterial(RgbColor(0,0,1));316 317 for (int j = 0; j < (int)pray->intersections.size(); ++ j)318 {319 if (pray->intersections[j].mObject)320 exporter->ExportIntersectable(pray->intersections[j].mObject);321 }322 323 //exporter->SetWireframe();324 exporter->SetForcedMaterial(RgbColor(0,1,0));325 exporter->ExportGeometry(obj);326 327 exporter->SetFilled();328 329 exporter->SetForcedMaterial(RgbColor(1,0,0));330 ExportViewCellGeometry(exporter, *it);331 332 delete exporter;333 }334 335 336 ++ i;337 }338 }339 Debug << "\nSampled " << i << " new view cells ("340 << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl;341 270 } 342 271 … … 1582 1511 vc->GetPvs().Merge(right->GetPvs()); 1583 1512 1584 //-- merge ray sets1585 if (0)1586 {1587 stable_sort(left->mPiercingRays.begin(), left->mPiercingRays.end());1588 stable_sort(right->mPiercingRays.begin(), right->mPiercingRays.end());1589 1590 std::merge(left->mPiercingRays.begin(), left->mPiercingRays.end(),1591 right->mPiercingRays.begin(), right->mPiercingRays.end(),1592 vc->mPiercingRays.begin());1593 }1594 1595 1513 // set only links to child (not from child to parent, maybe not wished!!) 1596 1514 vc->mChildren.push_back(left); … … 2003 1921 { 2004 1922 if (ViewCellsTreeConstructed()) 1923 { 2005 1924 mViewCellsTree->CreateUniqueViewCellsIds(); 2006 else 1925 } 1926 else // no view cells tree, handle view cells "myself" 1927 { 2007 1928 for (int i = 0; i < (int)mViewCells.size(); ++ i) 1929 { 2008 1930 mViewCells[i]->SetId(i); 1931 } 1932 } 2009 1933 } 2010 1934 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1278 r1284 671 671 bool mShowVisualization; 672 672 673 // HACK in order to detect empty view cells674 void CollectEmptyViewCells();675 void TestEmptyViewCells(const ObjectContainer &obj);676 677 ViewCellContainer mEmptyViewCells;678 679 673 int mRenderCostEvaluationType; 680 674 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1278 r1284 311 311 AttributeList& attributes) 312 312 { 313 //if (!mViewCellsManager)return;314 315 313 //-- use cell type according to the chosen method 316 317 314 switch (mObjectSpaceHierarchyType) 318 315 { … … 336 333 if (element == "Interior") 337 334 { 338 Debug<< "[";335 cout << "["; 339 336 StartViewCellInterior(attributes); 340 337 } … … 342 339 if (element == "Leaf") 343 340 { 344 Debug<< "l";341 cout << "l"; 345 342 StartViewCellLeaf(attributes); 346 343 } … … 390 387 if (element == "BoundingBox") 391 388 { 392 Debug<< "b";389 cout << "b"; 393 390 StartBoundingBox(attributes); 394 391 } … … 415 412 416 413 417 void ViewCellsParseHandlers:: StartViewCell(ViewCell *viewCell,418 414 void ViewCellsParseHandlers::ParseViewCellPvs(ViewCell *viewCell, 415 AttributeList& attributes) 419 416 { 420 417 int len = attributes.getLength(); … … 468 465 else 469 466 { 470 Debug<< "error: object with id " << objId << " does not exist" << endl;467 cout << "error: object with id " << objId << " does not exist" << endl; 471 468 } 472 469 } … … 524 521 if (strcmp(ptr, "bsp") == 0) 525 522 { 526 cout << " view space hierarchy: Bsp" << endl;523 cout << "\nview space hierarchy: Bsp" << endl; 527 524 mViewSpaceHierarchyType = BSP; 528 525 } 529 526 else if (strcmp(ptr, "vsp") == 0) 530 527 { 531 Debug << "view space hierarchy: Vsp" << endl;528 cout << "\nview space hierarchy: Vsp" << endl; 532 529 mViewSpaceHierarchyType = VSP; 533 530 } … … 557 554 558 555 Vector3 bmin, bmax; 559 556 cout << "here3" << endl; 560 557 for (int i = 0; i < len; ++ i) 561 558 { … … 569 566 if (strcmp(ptr, "osp") == 0) 570 567 { 571 Debug << "object space hierarchy: Osp" << endl; 572 mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 568 cout << "\nobject space hierarchy: Osp" << endl; 569 mHierarchyManager = 570 new HierarchyManager(mVspTree, HierarchyManager::KD_BASED_OBJ_SUBDIV); 573 571 } 574 572 else if (strcmp(ptr, "bvh") == 0) 575 573 { 576 Debug << "object space hierarchy: Bvh" << endl; 577 mHierarchyManager = new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 574 cout << "\nobject space hierarchy: Bvh" << endl; 575 mHierarchyManager = 576 new HierarchyManager(mVspTree, HierarchyManager::BV_BASED_OBJ_SUBDIV); 578 577 } 579 578 } … … 650 649 } 651 650 } 652 653 651 654 652 if (viewCellId >= 0) // valid view cell found … … 665 663 if (viewCell->GetId() == viewCellId) 666 664 { 665 // create new view cell for bsp nodes 667 666 leaf->SetViewCell(viewCell); 668 667 viewCell->mLeaf = leaf; … … 670 669 else 671 670 { 672 Debug<< "error: view cell does not exist" << endl;671 cout << "error: view cell does not exist" << endl; 673 672 } 674 673 } … … 724 723 void ViewCellsParseHandlers::StartViewCellLeaf(AttributeList& attributes) 725 724 { 726 BspViewCell *viewCell = new BspViewCell();725 ViewCellLeaf *viewCell = new ViewCellLeaf(); 727 726 728 727 if (mCurrentViewCell) // replace front or (if not NULL) back child 729 728 { 730 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 729 ViewCellInterior *interior = 730 dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 731 731 interior->SetupChildLink(viewCell); 732 732 } … … 736 736 } 737 737 738 StartViewCell(viewCell, attributes);738 ParseViewCellPvs(viewCell, attributes); 739 739 740 740 // collect leaves … … 746 746 { 747 747 ViewCellInterior* interior = new ViewCellInterior(); 748 748 cout << "here7"<<endl; 749 749 if (mCurrentViewCell) // replace NULL child of parent with current node 750 750 { … … 760 760 mCurrentViewCell = interior; 761 761 762 StartViewCell(interior, attributes);762 ParseViewCellPvs(interior, attributes); 763 763 } 764 764 … … 766 766 void ViewCellsParseHandlers::CreateViewSpaceHierarchy() 767 767 { 768 ViewCellContainer::iterator it, it_end = mViewCells.end(); 769 Debug << endl; 770 for (it = mViewCells.begin(); it != it_end; ++ it) 771 { 772 Debug << (*it)->GetId() << " "; 773 } 774 Debug << endl; 768 775 if (mViewSpaceHierarchyType == BSP) 769 776 { … … 774 781 // set view space box 775 782 mVspBspTree->mBox = mViewSpaceBox; 783 784 ViewCellContainer::iterator vit, vit_end = mViewCells.end(); 785 786 // reset view cells using the current node type 787 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 788 { 789 ViewCell *vc = *vit; 790 791 BspViewCell *bspVc = new BspViewCell(); 792 bspVc->SetPvs(vc->GetPvs()); 793 bspVc->SetId(vc->GetId()); 794 795 if (vc->IsRoot()) 796 { 797 mViewCellsTree->mRoot = bspVc; 798 } 799 else 800 { 801 vc->GetParent()->SetupChildLink(bspVc); 802 vc->GetParent()->RemoveChildLink(vc); 803 } 804 805 DEL_PTR(vc); 806 (*vit) = bspVc; 807 } 808 776 809 } 777 810 else if (mViewSpaceHierarchyType == VSP) … … 784 817 mVspTree->mBoundingBox = mViewSpaceBox; 785 818 786 // object space hierarchy already constructed 819 ViewCellContainer::iterator vit, vit_end = mViewCells.end(); 820 821 // reset view cells using the current node type 822 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 823 { 824 ViewCell *vc = *vit; 825 826 VspViewCell *vspVc = new VspViewCell(); 827 vspVc->SetPvs(vc->GetPvs()); 828 vspVc->SetId(vc->GetId()); 829 830 if (vc->IsRoot()) 831 { 832 mViewCellsTree->mRoot = vspVc; 833 } 834 else 835 { 836 vc->GetParent()->SetupChildLink(vspVc); 837 vc->GetParent()->RemoveChildLink(vc); 838 } 839 840 DEL_PTR(vc); 841 (*vit) = vspVc; 842 } 843 844 // if object space hierarchy already constructed 787 845 if (mHierarchyManager) 788 846 { … … 791 849 } 792 850 } 793 851 Debug << "************************" << endl; 852 it_end = mViewCells.end(); 853 for (it = mViewCells.begin(); it != it_end; ++ it) 854 { 855 Debug << (*it)->GetId() << " "; 856 } 857 Debug << endl; 794 858 cout << "\nview space box: " << mViewSpaceBox << endl; 795 859 } … … 879 943 dummyVc.SetId(viewCellId); 880 944 945 cout << "\nsearching view cell with id " << viewCellId << endl; 946 881 947 ViewCellContainer::iterator vit = 882 948 lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 883 949 950 if (vit == mViewCells.end()) 951 cout << "error: view cell " << viewCellId << " not found" << endl; 952 884 953 VspViewCell *viewCell = dynamic_cast<VspViewCell *>(*vit); 885 954 … … 891 960 else 892 961 { 893 Debug<< "error: view cell does not exist" << endl;962 cout << "error: view cell does not exist" << endl; 894 963 } 895 964 } … … 917 986 if (attrName == "plane") 918 987 { 919 sscanf(ptr, "%d %f", 920 &plane.mAxis, &plane.mPosition); 988 sscanf(ptr, "%d %f", &plane.mAxis, &plane.mPosition); 921 989 } 922 990 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r1278 r1284 118 118 void EndVspInterior(); 119 119 120 void StartViewCell(ViewCell *viewCell, AttributeList& attributes);120 void ParseViewCellPvs(ViewCell *viewCell, AttributeList& attributes); 121 121 void EndViewCells(); 122 122 void EndBoundingBoxes(); -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1272 r1284 134 134 #endif 135 135 136 cerr<<"HERE!\n";137 136 int returnCode = 0; 138 137
Note: See TracChangeset
for help on using the changeset viewer.