Changeset 590 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 02/04/06 21:36:40 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.