Changeset 590


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

implemented some code for merge history loading

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r588 r590  
    9898        useViewcells true 
    9999        updateSubdivision true 
    100         loadInitialSamples false 
     100        loadIfnitialSamples false 
    101101        storeInitialSamples false 
    102102} 
     
    212212                useRaysForMerge false 
    213213                refine false 
    214                 compress false 
     214                compress true 
    215215        } 
    216216 
     
    287287                epsilon 0.005 
    288288                randomize false 
    289                 renderCostWeight 0.5 
     289                renderCostWeight 1.0 
    290290        } 
    291291 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r589 r590  
    107107mValid(true), 
    108108mParent(NULL), 
    109 mTimeStamp(0) 
     109mTimeStamp(0), 
     110mIsActive(false) 
    110111{ 
    111112} 
     
    118119mValid(true), 
    119120mParent(NULL), 
    120 mTimeStamp(0) 
     121mTimeStamp(0), 
     122mIsActive(false) 
    121123{ 
    122124} 
     
    13101312                if (vc->IsLeaf() || ((viewCells.size() + tqueue.size()) >= numViewCells)) 
    13111313                { 
     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;  
    13121318                        viewCells.push_back(vc); 
    13131319                } 
     
    15021508int ViewCellsTree::GetNumPvsEntries(ViewCell *vc) const 
    15031509{ 
    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(); 
    15051514 
    15061515        if (!vc->IsLeaf()) 
     
    15231532{ 
    15241533        return mIsCompressed; 
     1534} 
     1535 
     1536 
     1537ViewCell *ViewCellsTree::GetActiveViewCell(ViewCell *vc) const 
     1538{ 
     1539        while (vc->GetParent() && !vc->mIsActive) 
     1540        { 
     1541                vc = vc->GetParent(); 
     1542        } 
     1543 
     1544        return vc; 
    15251545} 
    15261546 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r586 r590  
    190190        static int sReservedMailboxes; 
    191191         
     192        bool mIsActive; 
    192193 
    193194protected: 
     195 
    194196 
    195197        /// the potentially visible objects 
     
    322324        bool IsCompressed() const; 
    323325 
     326        ViewCell *GetActiveViewCell(ViewCell *vc) const; 
     327 
    324328protected: 
    325329 
  • 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} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r587 r590  
    2020class ViewCellsStatistics; 
    2121class ViewCellsManager; 
    22  
    23  
     22class ViewCellsTree; 
    2423 
    2524class BspNodeGeometry 
     
    322321public: 
    323322        BspLeaf(); 
    324         BspLeaf(BspViewCell *viewCell); 
     323        BspLeaf(ViewCell *viewCell); 
    325324        BspLeaf(BspInterior *parent); 
    326         BspLeaf(BspInterior *parent, BspViewCell *viewCell); 
     325        BspLeaf(BspInterior *parent, ViewCell *viewCell); 
    327326 
    328327        ~BspLeaf(); 
     
    334333        /** Returns pointer of view cell. 
    335334        */ 
    336         BspViewCell *GetViewCell() const; 
     335        ViewCell *GetViewCell() const; 
    337336 
    338337        /** Sets pointer to view cell. 
    339338        */ 
    340         void SetViewCell(BspViewCell *viewCell); 
     339        void SetViewCell(ViewCell *viewCell); 
    341340 
    342341        /// Rays piercing this leaf. 
     
    352351         
    353352        /// if NULL this does not correspond to feasible viewcell 
    354         BspViewCell *mViewCell; 
     353        ViewCell *mViewCell; 
    355354}; 
    356355 
     
    500499        BspNode *GetRoot() const; 
    501500 
    502         /** Exports Bsp tree to file. 
    503         */ 
    504         bool Export(const string filename); 
     501         
     502        //bool Export(const string filename); 
    505503 
    506504        /** Collects the leaf view cells of the tree 
     
    558556        BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 
    559557 
    560         /** Returns view cell corresponding to unbounded space. 
    561         */ 
    562         BspViewCell *GetRootCell() const; 
    563558 
    564559        /** Returns epsilon of this tree. 
     
    571566        int CollectMergeCandidates(const VssRayContainer &rays, 
    572567                                                   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         
    573581protected: 
    574582 
     
    593601        }; 
    594602 
     603        void ExportNode(BspNode *node, ofstream &stream); 
     604 
    595605        /** Evaluates tree stats in the BSP tree leafs. 
    596606        */ 
     
    850860 
    851861 
    852  
     862        /** Returns view cell corresponding to  
     863                the invalid view space. If it does not exist, it is created. 
     864        */ 
     865        BspViewCell *GetOrCreateOutOfBoundsCell(); 
    853866 
    854867        /// Pointer to the root of the tree. 
     
    877890 
    878891        /// view cell corresponding to unbounded space 
    879         BspViewCell *mRootCell; 
     892        BspViewCell *mOutOfBoundsCell; 
    880893 
    881894        /// if view cells should be generated or the given view cells should be used. 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r587 r590  
    686686{ 
    687687        mViewCells.clear(); 
     688         
    688689        CollectViewCells(); 
    689  
     690         
    690691        mViewCellsStats.Reset(); 
    691692        EvaluateViewCellsStats(); 
     693 
    692694        // has to be recomputed 
    693695        mTotalAreaValid = false; 
     
    699701        return mMaxPvsSize; 
    700702} 
     703 
    701704 
    702705void 
     
    921924        environment->GetIntValue("BspTree.Construction.samples", mInitialSamples); 
    922925        mBspTree->SetViewCellsManager(this); 
     926        mBspTree->mViewCellsTree = mViewCellsTree; 
    923927} 
    924928 
     
    10241028        if (!ViewCellsTreeConstructed()) 
    10251029        { 
     1030                 
    10261031                mBspTree->CollectViewCells(mViewCells); 
    10271032        } 
    10281033        else  
    10291034        { 
     1035                 
    10301036                // we can use the view cells tree hierarchy to get the right set 
    10311037                mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 
     
    10691075        } 
    10701076 
     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 
    10711087        //-- post processing of bsp view cells 
    10721088    int vcSize = 0; 
     
    10981114                                m.mDiffuseColor = RgbColor(0, 1, 0); 
    10991115                                exporter->SetForcedMaterial(m); 
     1116                         
    11001117                                exporter->SetWireframe(); 
    11011118 
     
    11321149        FinalizeViewCells(true); 
    11331150         
    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(); 
    11361154 
    11371155        // write view cells to disc 
     
    11861204                        else 
    11871205                                exporter->SetFilled(); 
     1206 
    11881207                        ExportViewCellsForViz(exporter); 
    11891208 
     
    14861505 
    14871506 
    1488 /**********************************************************************/ 
    1489 /*                   KdViewCellsManager implementation               */ 
    1490 /**********************************************************************/ 
     1507 
     1508bool 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 
     1551void 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/************************************************************************/ 
    14911573 
    14921574 
     
    21772259        environment->GetIntValue("VspBspTree.Construction.samples", mInitialSamples); 
    21782260        mVspBspTree->SetViewCellsManager(this); 
     2261        mVspBspTree->mViewCellsTree = mViewCellsTree; 
    21792262} 
    21802263 
     
    21992282        if (!ViewCellsTreeConstructed()) 
    22002283        { 
    2201                 mVspBspTree->CollectViewCells(mViewCells, true); 
     2284                mVspBspTree->CollectViewCells(mViewCells, false); 
    22022285        } 
    22032286        else  
     
    25682651        FinalizeViewCells(true); 
    25692652 
    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 
    25722657 
    25732658        // write view cells to disc 
     
    29663051 
    29673052void VspBspViewCellsManager::ExportViewCellGeometry(Exporter *exporter, 
    2968                                                                                           ViewCell *vc) const 
     3053                                                                                                        ViewCell *vc) const 
    29693054{ 
    29703055        if (vc->GetMesh()) 
    29713056        { 
    29723057                exporter->ExportMesh(vc->GetMesh()); 
     3058         
    29733059                return; 
    29743060        } 
     
    30233109                delete vc->GetMesh(); 
    30243110 
     3111         
    30253112        BspNodeGeometry geom; 
     3113 
     3114        mVspBspTree->ConstructGeometry(vc, geom); 
    30263115         
    3027         mVspBspTree->ConstructGeometry(vc, geom); 
    3028  
    30293116        Mesh *mesh = new Mesh(); 
    30303117        geom.AddToMesh(*mesh); 
     
    30433130        if (parser.ParseFile(filename, &vm, objects)) 
    30443131        { 
    3045                 vm->PrepareLoadedViewCells(); 
     3132                //vm->PrepareLoadedViewCells(); 
    30463133                vm->ResetViewCells(); 
    30473134 
     
    30523139 
    30533140                Debug << (int)vm->mViewCells.size() << " view cells loaded" << endl; 
    3054  
    3055                 //vm->ExportViewCells("test.xml"); 
    30563141        } 
    30573142        else 
     
    30783163 
    30793164        // for output we need unique ids for each view cell 
    3080         //CreateUniqueViewCellIds(); 
     3165        CreateUniqueViewCellIds(); 
     3166 
    30813167 
    30823168        stream.open(filename.c_str()); 
     
    31013187 
    31023188        //-- load the hierarchy 
    3103         stream << "<BspTree>" << endl; 
     3189        stream << "<Hierarchy>" << endl; 
    31043190        mVspBspTree->Export(stream); 
    3105         stream << endl << "</BspTree>" << endl; 
     3191        stream << endl << "</Hierarchy>" << endl; 
    31063192 
    31073193        stream << "</Visibility_Solution>" << endl; 
     
    31513237{ 
    31523238        // TODO: do I still need this here? 
     3239        if (0) 
    31533240        mVspBspTree->RepairViewCellsLeafLists(); 
    31543241} 
     
    31763263 
    31773264 
     3265void VspBspViewCellsManager::AddCurrentViewCellsToHierarchy() 
     3266{ 
     3267        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     3268        for (it = mViewCells.begin(); it != it_end; ++ it) 
     3269        { 
     3270        } 
     3271} 
    31783272 
    31793273////////////////////////////////// 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r587 r590  
    514514        void Finalize(ViewCell *viewCell, const bool createMesh); 
    515515 
     516        bool ExportViewCells(const string filename); 
     517 
    516518protected: 
     519 
     520        /** HACK 
     521        */ 
     522        void AddCurrentViewCellsToHierarchy(); 
    517523 
    518524        void CollectViewCells(); 
     
    719725protected: 
    720726 
     727        /** HACK 
     728        */ 
     729        void AddCurrentViewCellsToHierarchy(); 
     730 
    721731        /** Merges the view cells. 
    722732        */ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.cpp

    r580 r590  
    2828#include "VspBspTree.h" 
    2929#include "ViewCellBsp.h" 
     30#include "VspKdTree.h" 
    3031#include "ViewCellsManager.h" 
    3132 
     
    9899{ 
    99100        // go one up in the tree 
    100         if (mCurrentNode->GetParent()) 
     101        if (mCurrentBspNode->GetParent()) 
    101102        {       cout << "]"; 
    102                 mCurrentNode = mCurrentNode->GetParent(); 
     103                mCurrentBspNode = mCurrentBspNode->GetParent(); 
    103104        } 
    104105} 
     
    213214        vector<int> objIndices; 
    214215   
    215         ViewCell *viewCell = mViewCellsManager->GenerateViewCell(); 
     216//hack!! 
     217         
     218        ViewCell *viewCell = new ViewCellInterior();//mViewCellsManager->GenerateViewCell(); 
     219        viewCell->mIsActive = true; 
     220 
    216221        mViewCells.push_back(viewCell); 
    217  
     222         
    218223        for (int i = 0; i < len; ++ i)  
    219224        { 
     
    316321{ 
    317322        BspLeaf * leaf =  
    318                 new BspLeaf(dynamic_cast<BspInterior *>(mCurrentNode), NULL); 
    319  
    320         if (mCurrentNode) // replace front or (if not NULL) back child 
    321         { 
    322                 dynamic_cast<BspInterior *>(mCurrentNode)->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); 
    323328        } 
    324329        else 
     
    353358        } 
    354359 
     360         
    355361        if (viewCellId >= 0) // valid view cell 
    356362        { 
    357363                // TODO: get view cell with specified id 
    358                 BspViewCell dummyVc; 
     364                ViewCellInterior dummyVc; 
    359365                dummyVc.SetId(viewCellId); 
    360366 
     
    362368                        lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 
    363369                         
    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); 
    365375 
    366376                if (viewCell->GetId() == viewCellId) 
    367377                { 
    368                         leaf->SetViewCell(viewCell); 
     378                        leaf->SetViewCell(l); 
     379                        l->mLeaf = leaf; 
    369380                } 
    370381                else 
     
    405416        BspInterior* interior = new BspInterior(plane); 
    406417         
    407         if (mCurrentNode) // replace NULL child of parent with current node 
    408         { 
    409                 BspInterior *current = dynamic_cast<BspInterior *>(mCurrentNode); 
     418        if (mCurrentBspNode) // replace NULL child of parent with current node 
     419        { 
     420                BspInterior *current = dynamic_cast<BspInterior *>(mCurrentBspNode); 
    410421 
    411422                current->ReplaceChildLink(NULL, interior); 
     
    424435        } 
    425436 
    426         mCurrentNode = interior; 
     437        mCurrentBspNode = interior; 
    427438} 
    428439 
     
    436447 
    437448                mBspTree = new BspTree(); 
    438                 mCurrentNode = mBspTree->GetRoot(); 
     449                mBspTree->mBox = mViewSpaceBox; 
     450                mCurrentBspNode = mBspTree->GetRoot(); 
    439451 
    440452                mViewCellsManager = new BspViewCellsManager(mBspTree); 
     
    445457 
    446458                mVspBspTree = new VspBspTree(); 
    447                 mCurrentNode = mVspBspTree->GetRoot(); 
     459                mCurrentBspNode = mVspBspTree->GetRoot(); 
    448460 
    449461                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
    450462 
     463                mVspBspTree->mBox = mViewSpaceBox; 
    451464                Debug << "creating vsp bsp view cells manager" << endl; 
    452465        } 
    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        } 
    459472        else 
    460473        { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParserXerces.h

    r577 r590  
    1414 
    1515class VspBspTree; 
     16class VspKdTree; 
    1617class BspTree; 
    1718class ViewCellsManager; 
     
    6465 
    6566  VspBspTree *mVspBspTree; 
     67  VspKdTree *mVspKdTree; 
    6668  BspTree *mBspTree; 
    6769   
    68   BspNode *mCurrentNode; 
     70  BspNode *mCurrentBspNode; 
    6971  ViewCellContainer mViewCells; 
    7072  ViewCellsManager *mViewCellsManager; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r589 r590  
    1717#include "ViewCellsManager.h" 
    1818#include "Beam.h" 
     19 
    1920 
    2021//-- static members 
     
    17411742void VspBspTree::CollapseViewCells() 
    17421743{ 
     1744// TODO 
     1745#if VC_HISTORY 
    17431746        stack<BspNode *> nodeStack; 
    17441747 
     
    17621765         
    17631766                                ViewCellContainer leaves; 
    1764                                 mViewCellsManager->GetViewCellsTree()->CollectLeaves(viewCell, leaves); 
     1767                                mViewCellsTree->CollectLeaves(viewCell, leaves); 
    17651768 
    17661769                                ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     
    17881791 
    17891792        Debug << "invalid leaves: " << mBspStats.invalidLeaves << endl; 
     1793#endif 
    17901794} 
    17911795 
     
    18551859                        if (!onlyValid || node->TreeValid()) 
    18561860                        { 
    1857                                 ViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 
    1858                          
     1861                                ViewCell *viewCell =  
     1862                                        mViewCellsTree->GetActiveViewCell(dynamic_cast<BspLeaf *>(node)->GetViewCell()); 
     1863                                                 
    18591864                                if (!onlyUnmailed || !viewCell->Mailed())  
    18601865                                { 
     
    18721877                } 
    18731878        } 
     1879 
    18741880} 
    18751881 
     
    20582064{ 
    20592065        ViewCellContainer leaves; 
    2060         mViewCellsManager->GetViewCellsTree()->CollectLeaves(vc, leaves); 
     2066         
     2067        mViewCellsTree->CollectLeaves(vc, leaves); 
    20612068 
    20622069        ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     
    20652072        { 
    20662073                BspLeaf *l = dynamic_cast<BspViewCell *>(*it)->mLeaf; 
     2074                 
    20672075                ConstructGeometry(l, vcGeom); 
    20682076        } 
     
    24332441                        BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
    24342442 
    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(); 
    24392448                                ++ hits; 
    24402449                        } 
     
    24972506BspNode *VspBspTree::CollapseTree(BspNode *node, int &collapsed) 
    24982507{ 
     2508// TODO 
     2509#if VC_HISTORY 
    24992510        if (node->IsLeaf()) 
    25002511                return node; 
     
    25302541                } 
    25312542        } 
    2532  
     2543#endif 
    25332544        return node; 
    25342545} 
     
    25512562void VspBspTree::RepairViewCellsLeafLists() 
    25522563{ 
     2564// TODO 
     2565#if VC_HISTORY 
    25532566        // list not valid anymore => clear 
    25542567        stack<BspNode *> nodeStack; 
     
    25672580 
    25682581                        BspViewCell *viewCell = leaf->GetViewCell(); 
    2569         // TODO 
    2570 #if VC_HISTORY 
     2582 
    25712583                        if (!viewCell->Mailed()) 
    25722584                        { 
     
    25762588         
    25772589                        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        } 
    25782600// TODO 
    25792601#endif 
    2580                 } 
    2581                 else 
    2582                 { 
    2583                         BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    2584  
    2585                         nodeStack.push(interior->GetFront()); 
    2586                         nodeStack.push(interior->GetBack()); 
    2587                 } 
    2588         } 
    25892602} 
    25902603 
     
    29292942        { 
    29302943                BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
    2931                          
     2944                ViewCell *viewCell = mViewCellsTree->GetActiveViewCell(leaf->GetViewCell()); 
     2945 
    29322946                int id = -1; 
    2933                 if (leaf->GetViewCell() != mOutOfBoundsCell) 
    2934                         id = leaf->GetViewCell()->GetId(); 
     2947                if (viewCell != mOutOfBoundsCell) 
     2948                        id = viewCell->GetId(); 
    29352949 
    29362950                stream << "<Leaf viewCellId=\"" << id << "\" />" << endl; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r587 r590  
    2323class MergeCandidate; 
    2424class Beam; 
     25class ViewCellsTree; 
    2526 
    2627struct BspRay; 
     
    298299        void CollapseViewCells(); 
    299300 
     301        ViewCellsTree *mViewCellsTree; 
    300302protected: 
    301303 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r589 r590  
    535535  AxisAlignedBox3 vbox = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 
    536536 
     537  mSceneGraph->CollectObjects(&mObjects); 
     538 
    537539  //-- load view cells from file if requested 
    538540  if (!mLoadViewCells) 
     
    546548          mViewCellsManager->PrintStatistics(Debug); 
    547549  } 
    548          
    549  
     550  else 
     551  { 
     552          
     553          VssRayContainer dummies; 
     554          mViewCellsManager->Visualize(mObjects, dummies); 
     555          mViewCellsManager->ExportViewCells("test.xml"); 
     556  } 
    550557  VssTree *vssTree = NULL; 
    551558 
    552   mSceneGraph->CollectObjects(&mObjects); 
     559   
    553560 
    554561  long initialTime = GetTime(); 
Note: See TracChangeset for help on using the changeset viewer.