Ignore:
Timestamp:
02/04/06 21:36:40 (18 years ago)
Author:
mattausch
Message:

implemented some code for merge history loading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r589 r590  
    1515#include <stack> 
    1616 
     17 
     18 
    1719//-- static members 
    1820 
     
    173175 
    174176 
    175 BspLeaf::BspLeaf(BspViewCell *viewCell):  
     177BspLeaf::BspLeaf(ViewCell *viewCell):  
    176178mViewCell(viewCell) 
    177179{ 
     
    185187 
    186188 
    187 BspLeaf::BspLeaf(BspInterior *parent, BspViewCell *viewCell):  
     189BspLeaf::BspLeaf(BspInterior *parent, ViewCell *viewCell):  
    188190BspNode(parent), mViewCell(viewCell), mPvs(NULL) 
    189191{ 
    190192} 
    191193 
    192 BspViewCell *BspLeaf::GetViewCell() const 
     194ViewCell *BspLeaf::GetViewCell() const 
    193195{ 
    194196        return mViewCell; 
    195197} 
    196198 
    197 void BspLeaf::SetViewCell(BspViewCell *viewCell) 
     199void BspLeaf::SetViewCell(ViewCell *viewCell) 
    198200{ 
    199201        mViewCell = viewCell; 
     
    218220        Randomize(); // initialise random generator for heuristics 
    219221 
    220         // the view cell corresponding to unbounded space 
    221         mRootCell = new BspViewCell(); 
     222        mOutOfBoundsCell = GetOrCreateOutOfBoundsCell(); 
    222223 
    223224        //-- termination criteria for autopartition 
     
    443444        DEL_PTR(mRoot); 
    444445 
    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 
     450BspViewCell *BspTree::GetOutOfBoundsCell() 
     451{ 
     452        return mOutOfBoundsCell; 
     453} 
     454 
     455 
     456BspNode *BspTree::GetRoot() const 
     457{ 
     458        return mRoot; 
     459} 
     460 
     461BspViewCell *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 
    454473 
    455474void BspTree::InsertViewCell(ViewCell *viewCell) 
     
    466485} 
    467486 
     487 
    468488void BspTree::InsertPolygons(PolygonContainer *polys) 
    469489{        
     
    477497                                                                 polys,  
    478498                                                                 0,  
    479                                                                  mRootCell,  
     499                                                                 mOutOfBoundsCell,  
    480500                                                                 new BoundedRayContainer(),  
    481501                                                                 0,  
     
    510530                                 
    511531                                // extract view cells associated with the split polygons 
    512                                 ViewCell *frontViewCell = mRootCell; 
    513                                 ViewCell *backViewCell = mRootCell; 
     532                                ViewCell *frontViewCell = GetOrCreateOutOfBoundsCell(); 
     533                                ViewCell *backViewCell = GetOrCreateOutOfBoundsCell(); 
    514534                         
    515535                                BspTraversalData frontData(interior->GetFront(),  
    516536                                                                                   frontPolys,  
    517537                                                                                   tData.mDepth + 1, 
    518                                                                                    mRootCell,    
     538                                                                                   mOutOfBoundsCell,     
    519539                                                                                   tData.mRays, 
    520540                                                                                   tData.mPvs, 
     
    525545                                                                                  backPolys, 
    526546                                                                                  tData.mDepth + 1, 
    527                                                                                   mRootCell,     
     547                                                                                  mOutOfBoundsCell,      
    528548                                                                                  tData.mRays, 
    529549                                                                                  tData.mPvs, 
     
    640660                        } 
    641661                 
    642                         AddMeshToPolygons(mesh, polys, mRootCell); 
     662                        AddMeshToPolygons(mesh, polys, mOutOfBoundsCell); 
    643663                } 
    644664        } 
     
    814834                                                   polys,  
    815835                                                   0,  
    816                                                    mRootCell,  
     836                                                   GetOrCreateOutOfBoundsCell(),  
    817837                                                   rays,  
    818838                                                   ComputePvsSize(*rays),  
     
    881901                 
    882902                //-- add pvs 
    883                 if (viewCell != mRootCell) 
     903                if (viewCell != mOutOfBoundsCell) 
    884904                { 
    885905                        int conSamp = 0, sampCon = 0; 
     
    909929        PolygonContainer coincident; 
    910930         
    911         BspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell,  
     931        BspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, mOutOfBoundsCell,  
    912932                                                                new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); 
    913         BspTraversalData tBackData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell,  
     933        BspTraversalData tBackData(NULL, new PolygonContainer(), tData.mDepth + 1, mOutOfBoundsCell,  
    914934                                                           new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); 
    915935 
     
    18121832} 
    18131833 
    1814  
    1815 BspNode *BspTree::GetRoot() const 
    1816 { 
    1817         return mRoot; 
    1818 } 
    18191834 
    18201835void BspTree::EvaluateLeafStats(const BspTraversalData &data) 
     
    20552070} 
    20562071 
    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 } 
    20692072 
    20702073void BspTree::CollectViewCells(ViewCellContainer &viewCells) const 
     
    26892692                if (ray->mViewCells.size() < 2) 
    26902693                        continue; 
    2691 //TODO viewcellhierarchy 
     2694 
    26922695                iit = ray->mViewCells.begin(); 
    26932696                BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*(iit ++)); 
     
    30233026} 
    30243027 
     3028 
    30253029void BspNodeGeometry::IncludeInBox(AxisAlignedBox3 &box) 
    30263030{ 
    30273031        Polygon3::IncludeInBox(mPolys, box); 
    30283032} 
     3033 
     3034 
     3035bool BspTree::Export(ofstream &stream) 
     3036{ 
     3037        ExportNode(mRoot, stream); 
     3038 
     3039        return true; 
     3040} 
     3041 
     3042 
     3043void 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.