Changeset 590 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 02/04/06 21:36:40 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r588 r590 98 98 useViewcells true 99 99 updateSubdivision true 100 loadI nitialSamples false100 loadIfnitialSamples false 101 101 storeInitialSamples false 102 102 } … … 212 212 useRaysForMerge false 213 213 refine false 214 compress false214 compress true 215 215 } 216 216 … … 287 287 epsilon 0.005 288 288 randomize false 289 renderCostWeight 0.5289 renderCostWeight 1.0 290 290 } 291 291 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r589 r590 107 107 mValid(true), 108 108 mParent(NULL), 109 mTimeStamp(0) 109 mTimeStamp(0), 110 mIsActive(false) 110 111 { 111 112 } … … 118 119 mValid(true), 119 120 mParent(NULL), 120 mTimeStamp(0) 121 mTimeStamp(0), 122 mIsActive(false) 121 123 { 122 124 } … … 1310 1312 if (vc->IsLeaf() || ((viewCells.size() + tqueue.size()) >= numViewCells)) 1311 1313 { 1314 // todo: should be done with a function taking the active flag and some 1315 // time stamp so I don't have to reset view cells, this also means that 1316 // the leaf view cells can be set active fist 1317 vc->mIsActive = true; 1312 1318 viewCells.push_back(vc); 1313 1319 } … … 1502 1508 int ViewCellsTree::GetNumPvsEntries(ViewCell *vc) const 1503 1509 { 1504 int pvsSize = vc->GetPvs().GetSize(); 1510 int pvsSize = 0; 1511 // only count leaves for uncompressed method for fairness 1512 if (mIsCompressed || vc->IsLeaf()) 1513 pvsSize = vc->GetPvs().GetSize(); 1505 1514 1506 1515 if (!vc->IsLeaf()) … … 1523 1532 { 1524 1533 return mIsCompressed; 1534 } 1535 1536 1537 ViewCell *ViewCellsTree::GetActiveViewCell(ViewCell *vc) const 1538 { 1539 while (vc->GetParent() && !vc->mIsActive) 1540 { 1541 vc = vc->GetParent(); 1542 } 1543 1544 return vc; 1525 1545 } 1526 1546 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r586 r590 190 190 static int sReservedMailboxes; 191 191 192 bool mIsActive; 192 193 193 194 protected: 195 194 196 195 197 /// the potentially visible objects … … 322 324 bool IsCompressed() const; 323 325 326 ViewCell *GetActiveViewCell(ViewCell *vc) const; 327 324 328 protected: 325 329 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r589 r590 15 15 #include <stack> 16 16 17 18 17 19 //-- static members 18 20 … … 173 175 174 176 175 BspLeaf::BspLeaf( BspViewCell *viewCell):177 BspLeaf::BspLeaf(ViewCell *viewCell): 176 178 mViewCell(viewCell) 177 179 { … … 185 187 186 188 187 BspLeaf::BspLeaf(BspInterior *parent, BspViewCell *viewCell):189 BspLeaf::BspLeaf(BspInterior *parent, ViewCell *viewCell): 188 190 BspNode(parent), mViewCell(viewCell), mPvs(NULL) 189 191 { 190 192 } 191 193 192 BspViewCell *BspLeaf::GetViewCell() const194 ViewCell *BspLeaf::GetViewCell() const 193 195 { 194 196 return mViewCell; 195 197 } 196 198 197 void BspLeaf::SetViewCell( BspViewCell *viewCell)199 void BspLeaf::SetViewCell(ViewCell *viewCell) 198 200 { 199 201 mViewCell = viewCell; … … 218 220 Randomize(); // initialise random generator for heuristics 219 221 220 // the view cell corresponding to unbounded space 221 mRootCell = new BspViewCell(); 222 mOutOfBoundsCell = GetOrCreateOutOfBoundsCell(); 222 223 223 224 //-- termination criteria for autopartition … … 443 444 DEL_PTR(mRoot); 444 445 445 // HACK: view cells not generated => root cell not used 446 if (mGenerateViewCells) 447 DEL_PTR(mRootCell); 448 } 449 450 BspViewCell *BspTree::GetRootCell() const 451 { 452 return mRootCell; 453 } 446 // TODO must be deleted if used!! 447 //if (mGenerateViewCells) DEL_PTR(mOutOfBoundsCell); 448 } 449 450 BspViewCell *BspTree::GetOutOfBoundsCell() 451 { 452 return mOutOfBoundsCell; 453 } 454 455 456 BspNode *BspTree::GetRoot() const 457 { 458 return mRoot; 459 } 460 461 BspViewCell *BspTree::GetOrCreateOutOfBoundsCell() 462 { 463 if (!mOutOfBoundsCell) 464 { 465 mOutOfBoundsCell = new BspViewCell(); 466 mOutOfBoundsCell->SetId(-1); 467 mOutOfBoundsCell->SetValid(false); 468 } 469 470 return mOutOfBoundsCell; 471 } 472 454 473 455 474 void BspTree::InsertViewCell(ViewCell *viewCell) … … 466 485 } 467 486 487 468 488 void BspTree::InsertPolygons(PolygonContainer *polys) 469 489 { … … 477 497 polys, 478 498 0, 479 m RootCell,499 mOutOfBoundsCell, 480 500 new BoundedRayContainer(), 481 501 0, … … 510 530 511 531 // extract view cells associated with the split polygons 512 ViewCell *frontViewCell = mRootCell;513 ViewCell *backViewCell = mRootCell;532 ViewCell *frontViewCell = GetOrCreateOutOfBoundsCell(); 533 ViewCell *backViewCell = GetOrCreateOutOfBoundsCell(); 514 534 515 535 BspTraversalData frontData(interior->GetFront(), 516 536 frontPolys, 517 537 tData.mDepth + 1, 518 m RootCell,538 mOutOfBoundsCell, 519 539 tData.mRays, 520 540 tData.mPvs, … … 525 545 backPolys, 526 546 tData.mDepth + 1, 527 m RootCell,547 mOutOfBoundsCell, 528 548 tData.mRays, 529 549 tData.mPvs, … … 640 660 } 641 661 642 AddMeshToPolygons(mesh, polys, m RootCell);662 AddMeshToPolygons(mesh, polys, mOutOfBoundsCell); 643 663 } 644 664 } … … 814 834 polys, 815 835 0, 816 mRootCell,836 GetOrCreateOutOfBoundsCell(), 817 837 rays, 818 838 ComputePvsSize(*rays), … … 881 901 882 902 //-- add pvs 883 if (viewCell != m RootCell)903 if (viewCell != mOutOfBoundsCell) 884 904 { 885 905 int conSamp = 0, sampCon = 0; … … 909 929 PolygonContainer coincident; 910 930 911 BspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, m RootCell,931 BspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, mOutOfBoundsCell, 912 932 new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); 913 BspTraversalData tBackData(NULL, new PolygonContainer(), tData.mDepth + 1, m RootCell,933 BspTraversalData tBackData(NULL, new PolygonContainer(), tData.mDepth + 1, mOutOfBoundsCell, 914 934 new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); 915 935 … … 1812 1832 } 1813 1833 1814 1815 BspNode *BspTree::GetRoot() const1816 {1817 return mRoot;1818 }1819 1834 1820 1835 void BspTree::EvaluateLeafStats(const BspTraversalData &data) … … 2055 2070 } 2056 2071 2057 bool BspTree::Export(const string filename)2058 {2059 Exporter *exporter = Exporter::GetExporter(filename);2060 2061 if (exporter)2062 {2063 exporter->ExportBspTree(*this);2064 return true;2065 }2066 2067 return false;2068 }2069 2072 2070 2073 void BspTree::CollectViewCells(ViewCellContainer &viewCells) const … … 2689 2692 if (ray->mViewCells.size() < 2) 2690 2693 continue; 2691 //TODO viewcellhierarchy 2694 2692 2695 iit = ray->mViewCells.begin(); 2693 2696 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*(iit ++)); … … 3023 3026 } 3024 3027 3028 3025 3029 void BspNodeGeometry::IncludeInBox(AxisAlignedBox3 &box) 3026 3030 { 3027 3031 Polygon3::IncludeInBox(mPolys, box); 3028 3032 } 3033 3034 3035 bool BspTree::Export(ofstream &stream) 3036 { 3037 ExportNode(mRoot, stream); 3038 3039 return true; 3040 } 3041 3042 3043 void BspTree::ExportNode(BspNode *node, ofstream &stream) 3044 { 3045 if (node->IsLeaf()) 3046 { 3047 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 3048 3049 int id = -1; 3050 if (leaf->GetViewCell() != mOutOfBoundsCell) 3051 id = leaf->GetViewCell()->GetId(); 3052 3053 stream << "<Leaf viewCellId=\"" << id << "\" />" << endl; 3054 } 3055 else 3056 { 3057 BspInterior *interior = dynamic_cast<BspInterior *>(node); 3058 3059 Plane3 plane = interior->GetPlane(); 3060 stream << "<Interior plane=\"" << plane.mNormal.x << " " 3061 << plane.mNormal.y << " " << plane.mNormal.z << " " 3062 << plane.mD << "\">" << endl; 3063 3064 ExportNode(interior->GetBack(), stream); 3065 ExportNode(interior->GetFront(), stream); 3066 3067 stream << "</Interior>" << endl; 3068 } 3069 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r587 r590 20 20 class ViewCellsStatistics; 21 21 class ViewCellsManager; 22 23 22 class ViewCellsTree; 24 23 25 24 class BspNodeGeometry … … 322 321 public: 323 322 BspLeaf(); 324 BspLeaf( BspViewCell *viewCell);323 BspLeaf(ViewCell *viewCell); 325 324 BspLeaf(BspInterior *parent); 326 BspLeaf(BspInterior *parent, BspViewCell *viewCell);325 BspLeaf(BspInterior *parent, ViewCell *viewCell); 327 326 328 327 ~BspLeaf(); … … 334 333 /** Returns pointer of view cell. 335 334 */ 336 BspViewCell *GetViewCell() const;335 ViewCell *GetViewCell() const; 337 336 338 337 /** Sets pointer to view cell. 339 338 */ 340 void SetViewCell( BspViewCell *viewCell);339 void SetViewCell(ViewCell *viewCell); 341 340 342 341 /// Rays piercing this leaf. … … 352 351 353 352 /// if NULL this does not correspond to feasible viewcell 354 BspViewCell *mViewCell;353 ViewCell *mViewCell; 355 354 }; 356 355 … … 500 499 BspNode *GetRoot() const; 501 500 502 /** Exports Bsp tree to file. 503 */ 504 bool Export(const string filename); 501 502 //bool Export(const string filename); 505 503 506 504 /** Collects the leaf view cells of the tree … … 558 556 BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 559 557 560 /** Returns view cell corresponding to unbounded space.561 */562 BspViewCell *GetRootCell() const;563 558 564 559 /** Returns epsilon of this tree. … … 571 566 int CollectMergeCandidates(const VssRayContainer &rays, 572 567 vector<MergeCandidate> &candidates); 568 569 /** Exports Bsp tree to file. 570 */ 571 bool Export(ofstream &stream); 572 573 574 /** Returns view cell corresponding to 575 the invalid view space. If it does not exist, it is created. 576 */ 577 BspViewCell *GetOutOfBoundsCell(); 578 579 ViewCellsTree *mViewCellsTree; 580 573 581 protected: 574 582 … … 593 601 }; 594 602 603 void ExportNode(BspNode *node, ofstream &stream); 604 595 605 /** Evaluates tree stats in the BSP tree leafs. 596 606 */ … … 850 860 851 861 852 862 /** Returns view cell corresponding to 863 the invalid view space. If it does not exist, it is created. 864 */ 865 BspViewCell *GetOrCreateOutOfBoundsCell(); 853 866 854 867 /// Pointer to the root of the tree. … … 877 890 878 891 /// view cell corresponding to unbounded space 879 BspViewCell *m RootCell;892 BspViewCell *mOutOfBoundsCell; 880 893 881 894 /// if view cells should be generated or the given view cells should be used. -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r587 r590 686 686 { 687 687 mViewCells.clear(); 688 688 689 CollectViewCells(); 689 690 690 691 mViewCellsStats.Reset(); 691 692 EvaluateViewCellsStats(); 693 692 694 // has to be recomputed 693 695 mTotalAreaValid = false; … … 699 701 return mMaxPvsSize; 700 702 } 703 701 704 702 705 void … … 921 924 environment->GetIntValue("BspTree.Construction.samples", mInitialSamples); 922 925 mBspTree->SetViewCellsManager(this); 926 mBspTree->mViewCellsTree = mViewCellsTree; 923 927 } 924 928 … … 1024 1028 if (!ViewCellsTreeConstructed()) 1025 1029 { 1030 1026 1031 mBspTree->CollectViewCells(mViewCells); 1027 1032 } 1028 1033 else 1029 1034 { 1035 1030 1036 // we can use the view cells tree hierarchy to get the right set 1031 1037 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); … … 1069 1075 } 1070 1076 1077 1078 // view cells already finished before post processing step (i.e. because they were loaded) 1079 if (mViewCellsFinished) 1080 { 1081 FinalizeViewCells(true); 1082 EvaluateViewCellsStats(); 1083 1084 return 0; 1085 } 1086 1071 1087 //-- post processing of bsp view cells 1072 1088 int vcSize = 0; … … 1098 1114 m.mDiffuseColor = RgbColor(0, 1, 0); 1099 1115 exporter->SetForcedMaterial(m); 1116 1100 1117 exporter->SetWireframe(); 1101 1118 … … 1132 1149 FinalizeViewCells(true); 1133 1150 1134 // for output we need unique ids for each view cell 1135 CreateUniqueViewCellIds(); 1151 // HACK: removes view cells in bsp leaves with active ones 1152 if (0) 1153 AddCurrentViewCellsToHierarchy(); 1136 1154 1137 1155 // write view cells to disc … … 1186 1204 else 1187 1205 exporter->SetFilled(); 1206 1188 1207 ExportViewCellsForViz(exporter); 1189 1208 … … 1486 1505 1487 1506 1488 /**********************************************************************/ 1489 /* KdViewCellsManager implementation */ 1490 /**********************************************************************/ 1507 1508 bool BspViewCellsManager::ExportViewCells(const string filename) 1509 { 1510 cout << "exporting view cells to xml ... "; 1511 std::ofstream stream; 1512 1513 // for output we need unique ids for each view cell 1514 CreateUniqueViewCellIds(); 1515 1516 1517 stream.open(filename.c_str()); 1518 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; 1519 stream << "<Visibility_Solution>" << endl; 1520 1521 //-- the view space bounding box 1522 stream << "<ViewSpaceBox" 1523 << " min=\"" << mViewSpaceBox.Min().x << " " << mViewSpaceBox.Min().y << " " << mViewSpaceBox.Min().z << "\"" 1524 << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 1525 1526 //-- the type of the view cells hierarchy 1527 //stream << "<Hierarchy name=\"bspTree\" />" << endl; 1528 stream << "<Hierarchy name=\"vspBspTree\" />" << endl; // write vsp bsp here because can use same tree and is bug free 1529 //-- load the view cells itself, i.e., the ids and the pvs 1530 stream << "<ViewCells>" << endl; 1531 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1532 for (it = mViewCells.begin(); it != it_end; ++ it) 1533 ExportViewCell(*it, stream); 1534 1535 stream << "</ViewCells>" << endl; 1536 1537 //-- load the hierarchy 1538 stream << "<Hierarchy>" << endl; 1539 mBspTree->Export(stream); 1540 stream << endl << "</Hierarchy>" << endl; 1541 1542 stream << "</Visibility_Solution>" << endl; 1543 stream.close(); 1544 1545 cout << "finished" << endl; 1546 1547 return true; 1548 } 1549 1550 1551 void BspViewCellsManager::AddCurrentViewCellsToHierarchy() 1552 { 1553 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 1554 for (it = mViewCells.begin(); it != it_end; ++ it) 1555 { 1556 ViewCell *vc = *it; 1557 ViewCellContainer leaves; 1558 mViewCellsTree->CollectLeaves(vc, leaves); 1559 1560 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 1561 1562 for (lit = leaves.begin(); lit != lit_end; ++ lit) 1563 { 1564 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*lit); 1565 bspVc->mLeaf->SetViewCell(vc); 1566 } 1567 } 1568 } 1569 1570 /************************************************************************/ 1571 /* KdViewCellsManager implementation */ 1572 /************************************************************************/ 1491 1573 1492 1574 … … 2177 2259 environment->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 2178 2260 mVspBspTree->SetViewCellsManager(this); 2261 mVspBspTree->mViewCellsTree = mViewCellsTree; 2179 2262 } 2180 2263 … … 2199 2282 if (!ViewCellsTreeConstructed()) 2200 2283 { 2201 mVspBspTree->CollectViewCells(mViewCells, true);2284 mVspBspTree->CollectViewCells(mViewCells, false); 2202 2285 } 2203 2286 else … … 2568 2651 FinalizeViewCells(true); 2569 2652 2570 // for output we need unique ids for each view cell 2571 CreateUniqueViewCellIds(); 2653 // HACK: removes view cells in bsp leaves with active ones 2654 if (0) 2655 AddCurrentViewCellsToHierarchy(); 2656 2572 2657 2573 2658 // write view cells to disc … … 2966 3051 2967 3052 void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 2968 3053 ViewCell *vc) const 2969 3054 { 2970 3055 if (vc->GetMesh()) 2971 3056 { 2972 3057 exporter->ExportMesh(vc->GetMesh()); 3058 2973 3059 return; 2974 3060 } … … 3023 3109 delete vc->GetMesh(); 3024 3110 3111 3025 3112 BspNodeGeometry geom; 3113 3114 mVspBspTree->ConstructGeometry(vc, geom); 3026 3115 3027 mVspBspTree->ConstructGeometry(vc, geom);3028 3029 3116 Mesh *mesh = new Mesh(); 3030 3117 geom.AddToMesh(*mesh); … … 3043 3130 if (parser.ParseFile(filename, &vm, objects)) 3044 3131 { 3045 vm->PrepareLoadedViewCells();3132 //vm->PrepareLoadedViewCells(); 3046 3133 vm->ResetViewCells(); 3047 3134 … … 3052 3139 3053 3140 Debug << (int)vm->mViewCells.size() << " view cells loaded" << endl; 3054 3055 //vm->ExportViewCells("test.xml");3056 3141 } 3057 3142 else … … 3078 3163 3079 3164 // for output we need unique ids for each view cell 3080 //CreateUniqueViewCellIds(); 3165 CreateUniqueViewCellIds(); 3166 3081 3167 3082 3168 stream.open(filename.c_str()); … … 3101 3187 3102 3188 //-- load the hierarchy 3103 stream << "< BspTree>" << endl;3189 stream << "<Hierarchy>" << endl; 3104 3190 mVspBspTree->Export(stream); 3105 stream << endl << "</ BspTree>" << endl;3191 stream << endl << "</Hierarchy>" << endl; 3106 3192 3107 3193 stream << "</Visibility_Solution>" << endl; … … 3151 3237 { 3152 3238 // TODO: do I still need this here? 3239 if (0) 3153 3240 mVspBspTree->RepairViewCellsLeafLists(); 3154 3241 } … … 3176 3263 3177 3264 3265 void VspBspViewCellsManager::AddCurrentViewCellsToHierarchy() 3266 { 3267 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 3268 for (it = mViewCells.begin(); it != it_end; ++ it) 3269 { 3270 } 3271 } 3178 3272 3179 3273 ////////////////////////////////// -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r587 r590 514 514 void Finalize(ViewCell *viewCell, const bool createMesh); 515 515 516 bool ExportViewCells(const string filename); 517 516 518 protected: 519 520 /** HACK 521 */ 522 void AddCurrentViewCellsToHierarchy(); 517 523 518 524 void CollectViewCells(); … … 719 725 protected: 720 726 727 /** HACK 728 */ 729 void AddCurrentViewCellsToHierarchy(); 730 721 731 /** Merges the view cells. 722 732 */ -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.cpp
r580 r590 28 28 #include "VspBspTree.h" 29 29 #include "ViewCellBsp.h" 30 #include "VspKdTree.h" 30 31 #include "ViewCellsManager.h" 31 32 … … 98 99 { 99 100 // go one up in the tree 100 if (mCurrent Node->GetParent())101 if (mCurrentBspNode->GetParent()) 101 102 { cout << "]"; 102 mCurrent Node = mCurrentNode->GetParent();103 mCurrentBspNode = mCurrentBspNode->GetParent(); 103 104 } 104 105 } … … 213 214 vector<int> objIndices; 214 215 215 ViewCell *viewCell = mViewCellsManager->GenerateViewCell(); 216 //hack!! 217 218 ViewCell *viewCell = new ViewCellInterior();//mViewCellsManager->GenerateViewCell(); 219 viewCell->mIsActive = true; 220 216 221 mViewCells.push_back(viewCell); 217 222 218 223 for (int i = 0; i < len; ++ i) 219 224 { … … 316 321 { 317 322 BspLeaf * leaf = 318 new BspLeaf(dynamic_cast<BspInterior *>(mCurrent Node), NULL);319 320 if (mCurrent Node) // replace front or (if not NULL) back child321 { 322 dynamic_cast<BspInterior *>(mCurrent Node)->ReplaceChildLink(NULL, leaf);323 new BspLeaf(dynamic_cast<BspInterior *>(mCurrentBspNode), NULL); 324 325 if (mCurrentBspNode) // replace front or (if not NULL) back child 326 { 327 dynamic_cast<BspInterior *>(mCurrentBspNode)->ReplaceChildLink(NULL, leaf); 323 328 } 324 329 else … … 353 358 } 354 359 360 355 361 if (viewCellId >= 0) // valid view cell 356 362 { 357 363 // TODO: get view cell with specified id 358 BspViewCelldummyVc;364 ViewCellInterior dummyVc; 359 365 dummyVc.SetId(viewCellId); 360 366 … … 362 368 lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 363 369 364 BspViewCell *viewCell = dynamic_cast<BspViewCell *>(*vit); 370 ViewCellInterior *viewCell = dynamic_cast<ViewCellInterior *>(*vit); 371 372 // giant hack!! 373 BspViewCell *l = dynamic_cast<BspViewCell *>(mViewCellsManager->GenerateViewCell()); 374 viewCell->SetupChildLink(l); 365 375 366 376 if (viewCell->GetId() == viewCellId) 367 377 { 368 leaf->SetViewCell(viewCell); 378 leaf->SetViewCell(l); 379 l->mLeaf = leaf; 369 380 } 370 381 else … … 405 416 BspInterior* interior = new BspInterior(plane); 406 417 407 if (mCurrent Node) // replace NULL child of parent with current node408 { 409 BspInterior *current = dynamic_cast<BspInterior *>(mCurrent Node);418 if (mCurrentBspNode) // replace NULL child of parent with current node 419 { 420 BspInterior *current = dynamic_cast<BspInterior *>(mCurrentBspNode); 410 421 411 422 current->ReplaceChildLink(NULL, interior); … … 424 435 } 425 436 426 mCurrent Node = interior;437 mCurrentBspNode = interior; 427 438 } 428 439 … … 436 447 437 448 mBspTree = new BspTree(); 438 mCurrentNode = mBspTree->GetRoot(); 449 mBspTree->mBox = mViewSpaceBox; 450 mCurrentBspNode = mBspTree->GetRoot(); 439 451 440 452 mViewCellsManager = new BspViewCellsManager(mBspTree); … … 445 457 446 458 mVspBspTree = new VspBspTree(); 447 mCurrent Node = mVspBspTree->GetRoot();459 mCurrentBspNode = mVspBspTree->GetRoot(); 448 460 449 461 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 450 462 463 mVspBspTree->mBox = mViewSpaceBox; 451 464 Debug << "creating vsp bsp view cells manager" << endl; 452 465 } 453 /*else if (strcmp(name, "vspKdTree") == 0)454 { 455 mVspKdTree = new VspKdTree();456 457 mViewCellsManager = VspKdViewCellsManager(mVspKdTree);458 } */466 else if (strcmp(name, "vspKdTree") == 0) 467 { 468 // TODO 469 mVspKdTree = new VspKdTree(); 470 mViewCellsManager = new VspKdViewCellsManager(mVspKdTree); 471 } 459 472 else 460 473 { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParserXerces.h
r577 r590 14 14 15 15 class VspBspTree; 16 class VspKdTree; 16 17 class BspTree; 17 18 class ViewCellsManager; … … 64 65 65 66 VspBspTree *mVspBspTree; 67 VspKdTree *mVspKdTree; 66 68 BspTree *mBspTree; 67 69 68 BspNode *mCurrent Node;70 BspNode *mCurrentBspNode; 69 71 ViewCellContainer mViewCells; 70 72 ViewCellsManager *mViewCellsManager; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r589 r590 17 17 #include "ViewCellsManager.h" 18 18 #include "Beam.h" 19 19 20 20 21 //-- static members … … 1741 1742 void VspBspTree::CollapseViewCells() 1742 1743 { 1744 // TODO 1745 #if VC_HISTORY 1743 1746 stack<BspNode *> nodeStack; 1744 1747 … … 1762 1765 1763 1766 ViewCellContainer leaves; 1764 mViewCells Manager->GetViewCellsTree()->CollectLeaves(viewCell, leaves);1767 mViewCellsTree->CollectLeaves(viewCell, leaves); 1765 1768 1766 1769 ViewCellContainer::const_iterator it, it_end = leaves.end(); … … 1788 1791 1789 1792 Debug << "invalid leaves: " << mBspStats.invalidLeaves << endl; 1793 #endif 1790 1794 } 1791 1795 … … 1855 1859 if (!onlyValid || node->TreeValid()) 1856 1860 { 1857 ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 1858 1861 ViewCell *viewCell = 1862 mViewCellsTree->GetActiveViewCell(dynamic_cast<BspLeaf *>(node)->GetViewCell()); 1863 1859 1864 if (!onlyUnmailed || !viewCell->Mailed()) 1860 1865 { … … 1872 1877 } 1873 1878 } 1879 1874 1880 } 1875 1881 … … 2058 2064 { 2059 2065 ViewCellContainer leaves; 2060 mViewCellsManager->GetViewCellsTree()->CollectLeaves(vc, leaves); 2066 2067 mViewCellsTree->CollectLeaves(vc, leaves); 2061 2068 2062 2069 ViewCellContainer::const_iterator it, it_end = leaves.end(); … … 2065 2072 { 2066 2073 BspLeaf *l = dynamic_cast<BspViewCell *>(*it)->mLeaf; 2074 2067 2075 ConstructGeometry(l, vcGeom); 2068 2076 } … … 2433 2441 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 2434 2442 2435 if (!leaf->GetViewCell()->Mailed()) 2436 { 2437 viewcells.push_back(leaf->GetViewCell()); 2438 leaf->GetViewCell()->Mail(); 2443 ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2444 if (!viewCell->Mailed()) 2445 { 2446 viewcells.push_back(viewCell); 2447 viewCell->Mail(); 2439 2448 ++ hits; 2440 2449 } … … 2497 2506 BspNode *VspBspTree::CollapseTree(BspNode *node, int &collapsed) 2498 2507 { 2508 // TODO 2509 #if VC_HISTORY 2499 2510 if (node->IsLeaf()) 2500 2511 return node; … … 2530 2541 } 2531 2542 } 2532 2543 #endif 2533 2544 return node; 2534 2545 } … … 2551 2562 void VspBspTree::RepairViewCellsLeafLists() 2552 2563 { 2564 // TODO 2565 #if VC_HISTORY 2553 2566 // list not valid anymore => clear 2554 2567 stack<BspNode *> nodeStack; … … 2567 2580 2568 2581 BspViewCell *viewCell = leaf->GetViewCell(); 2569 // TODO 2570 #if VC_HISTORY 2582 2571 2583 if (!viewCell->Mailed()) 2572 2584 { … … 2576 2588 2577 2589 viewCell->mLeaves.push_back(leaf); 2590 2591 } 2592 else 2593 { 2594 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2595 2596 nodeStack.push(interior->GetFront()); 2597 nodeStack.push(interior->GetBack()); 2598 } 2599 } 2578 2600 // TODO 2579 2601 #endif 2580 }2581 else2582 {2583 BspInterior *interior = dynamic_cast<BspInterior *>(node);2584 2585 nodeStack.push(interior->GetFront());2586 nodeStack.push(interior->GetBack());2587 }2588 }2589 2602 } 2590 2603 … … 2929 2942 { 2930 2943 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 2931 2944 ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 2945 2932 2946 int id = -1; 2933 if ( leaf->GetViewCell()!= mOutOfBoundsCell)2934 id = leaf->GetViewCell()->GetId();2947 if (viewCell != mOutOfBoundsCell) 2948 id = viewCell->GetId(); 2935 2949 2936 2950 stream << "<Leaf viewCellId=\"" << id << "\" />" << endl; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r587 r590 23 23 class MergeCandidate; 24 24 class Beam; 25 class ViewCellsTree; 25 26 26 27 struct BspRay; … … 298 299 void CollapseViewCells(); 299 300 301 ViewCellsTree *mViewCellsTree; 300 302 protected: 301 303 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r589 r590 535 535 AxisAlignedBox3 vbox = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 536 536 537 mSceneGraph->CollectObjects(&mObjects); 538 537 539 //-- load view cells from file if requested 538 540 if (!mLoadViewCells) … … 546 548 mViewCellsManager->PrintStatistics(Debug); 547 549 } 548 549 550 else 551 { 552 553 VssRayContainer dummies; 554 mViewCellsManager->Visualize(mObjects, dummies); 555 mViewCellsManager->ExportViewCells("test.xml"); 556 } 550 557 VssTree *vssTree = NULL; 551 558 552 mSceneGraph->CollectObjects(&mObjects);559 553 560 554 561 long initialTime = GetTime();
Note: See TracChangeset
for help on using the changeset viewer.