Ignore:
Timestamp:
08/25/06 10:14:56 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r1278 r1284  
    311311                                                                                                                          AttributeList& attributes) 
    312312{ 
    313         //if (!mViewCellsManager)return; 
    314  
    315313        //-- use cell type according to the chosen method 
    316  
    317314        switch (mObjectSpaceHierarchyType) 
    318315        { 
     
    336333        if (element == "Interior")  
    337334        { 
    338                 Debug << "["; 
     335                cout << "["; 
    339336                StartViewCellInterior(attributes); 
    340337        } 
     
    342339        if (element == "Leaf")  
    343340        { 
    344                 Debug << "l"; 
     341                cout << "l"; 
    345342                StartViewCellLeaf(attributes); 
    346343        } 
     
    390387        if (element == "BoundingBox") 
    391388        { 
    392                 Debug << "b"; 
     389                cout << "b"; 
    393390                StartBoundingBox(attributes); 
    394391        } 
     
    415412 
    416413 
    417 void ViewCellsParseHandlers::StartViewCell(ViewCell *viewCell,  
    418                                                                                    AttributeList&  attributes) 
     414void ViewCellsParseHandlers::ParseViewCellPvs(ViewCell *viewCell,  
     415                                                                                          AttributeList&  attributes) 
    419416{ 
    420417        int len = attributes.getLength(); 
     
    468465                                else 
    469466                                { 
    470                                         Debug << "error: object with id " << objId << " does not exist" << endl; 
     467                                        cout << "error: object with id " << objId << " does not exist" << endl; 
    471468                                } 
    472469                        } 
     
    524521                        if (strcmp(ptr, "bsp") == 0) 
    525522                        { 
    526                                 cout << "view space hierarchy: Bsp" << endl; 
     523                                cout << "\nview space hierarchy: Bsp" << endl; 
    527524                                mViewSpaceHierarchyType = BSP; 
    528525                        } 
    529526                        else if (strcmp(ptr, "vsp") == 0) 
    530527                        { 
    531                                 Debug << "view space hierarchy: Vsp" << endl; 
     528                                cout << "\nview space hierarchy: Vsp" << endl; 
    532529                                mViewSpaceHierarchyType = VSP; 
    533530                        } 
     
    557554 
    558555        Vector3 bmin, bmax; 
    559  
     556cout << "here3" << endl; 
    560557        for (int i = 0; i < len; ++ i)  
    561558        { 
     
    569566                        if (strcmp(ptr, "osp") == 0) 
    570567                        { 
    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); 
    573571                        } 
    574572                        else if (strcmp(ptr, "bvh") == 0) 
    575573                        { 
    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); 
    578577                        } 
    579578                } 
     
    650649                } 
    651650        } 
    652  
    653651         
    654652        if (viewCellId >= 0) // valid view cell found 
     
    665663                if (viewCell->GetId() == viewCellId) 
    666664                { 
     665                        // create new view cell for bsp nodes 
    667666                        leaf->SetViewCell(viewCell); 
    668667                        viewCell->mLeaf = leaf; 
     
    670669                else 
    671670                { 
    672                         Debug << "error: view cell does not exist" << endl; 
     671                        cout << "error: view cell does not exist" << endl; 
    673672                } 
    674673        } 
     
    724723void ViewCellsParseHandlers::StartViewCellLeaf(AttributeList& attributes) 
    725724{ 
    726         BspViewCell *viewCell = new BspViewCell(); 
     725        ViewCellLeaf *viewCell = new ViewCellLeaf(); 
    727726 
    728727        if (mCurrentViewCell) // replace front or (if not NULL) back child 
    729728        { 
    730                 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 
     729                ViewCellInterior *interior =  
     730                        dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 
    731731                interior->SetupChildLink(viewCell); 
    732732        } 
     
    736736        } 
    737737 
    738         StartViewCell(viewCell, attributes); 
     738        ParseViewCellPvs(viewCell, attributes); 
    739739 
    740740        // collect leaves 
     
    746746{ 
    747747        ViewCellInterior* interior = new ViewCellInterior(); 
    748          
     748        cout << "here7"<<endl; 
    749749        if (mCurrentViewCell) // replace NULL child of parent with current node 
    750750        { 
     
    760760        mCurrentViewCell = interior; 
    761761 
    762         StartViewCell(interior, attributes); 
     762        ParseViewCellPvs(interior, attributes); 
    763763} 
    764764 
     
    766766void ViewCellsParseHandlers::CreateViewSpaceHierarchy() 
    767767{ 
     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        } 
     774Debug << endl; 
    768775        if (mViewSpaceHierarchyType == BSP) 
    769776        { 
     
    774781                // set view space box 
    775782                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 
    776809        } 
    777810        else if (mViewSpaceHierarchyType == VSP)  
     
    784817                mVspTree->mBoundingBox = mViewSpaceBox; 
    785818 
    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 
    787845                if (mHierarchyManager) 
    788846                { 
     
    791849                } 
    792850        } 
    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; 
    794858        cout << "\nview space box: " << mViewSpaceBox << endl; 
    795859} 
     
    879943                dummyVc.SetId(viewCellId); 
    880944 
     945                cout << "\nsearching view cell with id " << viewCellId << endl; 
     946 
    881947                ViewCellContainer::iterator vit = 
    882948                        lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 
    883949                         
     950                if (vit == mViewCells.end()) 
     951                        cout << "error: view cell " << viewCellId << " not found" << endl; 
     952 
    884953                VspViewCell *viewCell = dynamic_cast<VspViewCell *>(*vit); 
    885954         
     
    891960                else 
    892961                { 
    893                         Debug << "error: view cell does not exist" << endl; 
     962                        cout << "error: view cell does not exist" << endl; 
    894963                } 
    895964        } 
     
    917986                if (attrName == "plane")  
    918987                { 
    919                         sscanf(ptr, "%d %f", 
    920                                    &plane.mAxis, &plane.mPosition); 
     988                        sscanf(ptr, "%d %f", &plane.mAxis, &plane.mPosition); 
    921989                } 
    922990        } 
Note: See TracChangeset for help on using the changeset viewer.