Changeset 1284


Ignore:
Timestamp:
08/25/06 10:14:56 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
9 edited

Legend:

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

    r1279 r1284  
    574574         
    575575                        const int colorCode = 0; 
    576                         const int maxPvs = 200;//mOspTree.GetStatistics().maxPvs; 
    577  
    578                         exporter->ExportOspTree(*mOspTree, colorCode == 0 ? 0 : maxPvs); 
     576                        const int maxPvs = 0;//mOspTree.GetStatistics().maxPvs; 
     577 
     578                        exporter->ExportOspTree(*mOspTree, 0); 
    579579 
    580580                        delete exporter; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r1233 r1284  
    9595                        return 0; 
    9696                } 
    97         } 
    98                                   
     97        }                         
    9998 
    10099        // compute leaf pvs 
     
    120119                        
    121120                                // add #objects exclusivly in this node 
    122                                 pvs += leaf->mObjects.size(); 
     121                                pvs += (int)leaf->mObjects.size(); 
    123122                        } 
    124123                        else // traverse tree 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1264 r1284  
    104104ViewCell::ViewCell():  
    105105MeshInstance(NULL),  
    106 mPiercingRays(0), 
    107106mArea(-1), 
    108107mVolume(-1), 
     
    118117ViewCell::ViewCell(Mesh *mesh):  
    119118MeshInstance(mesh),  
    120 mPiercingRays(0), 
    121119mArea(-1), 
    122120mVolume(-1), 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1264 r1284  
    191191        bool AddPvsSample(Intersectable *sample, const float pdf, float &contribution); 
    192192   
    193  
    194193        /// Rays piercing this view cell. 
    195         RayContainer mPiercingRays; 
    196  
     194        //RayContainer mPiercingRays; 
    197195 
    198196        /** if this is a view cell correspending to a leaf in a hierarchy. 
     
    294292{ 
    295293        friend class ViewCellsManager; 
     294 
    296295public: 
    297296        ViewCellInterior(); 
     
    300299        ViewCellInterior(Mesh *mesh); 
    301300         
    302  
    303301        /** Sets pointer from parent to child and vice versa. 
    304302        */ 
     
    307305        bool IsLeaf() const; 
    308306 
    309         ViewCellContainer mChildren; 
    310  
    311   void SetCost(const float c) { 
    312         mCost = c; 
    313   } 
    314   float GetCost() const { 
    315         return mCost; 
    316   } 
     307        void SetCost(const float c) { 
     308                mCost = c; 
     309        } 
     310         
     311        float GetCost() const { 
     312                return mCost; 
     313        } 
    317314   
     315  ViewCellContainer mChildren; 
     316 
    318317protected: 
    319318  /** overall cost resulting from the merge */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1278 r1284  
    264264} 
    265265 
    266 void ViewCellsManager::CollectEmptyViewCells() 
    267 { 
    268         mEmptyViewCells.clear(); 
    269         ViewCellContainer leaves; 
    270         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
    271  
    272         ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    273  
    274         cout << "collecting empty view cells" << endl; 
    275          
    276         for (it = leaves.begin(); it != it_end; ++ it) 
    277         { 
    278                 if ((*it)->GetPvs().Empty()) 
    279                 { 
    280                         mEmptyViewCells.push_back(*it); 
    281                 } 
    282         } 
    283         Debug << "empty view cells found: " << (int)mEmptyViewCells.size() << endl; 
    284 } 
    285  
    286266 
    287267bool ViewCellsManager::EqualToSpatialNode(ViewCell *viewCell) const  
    288268{  
    289269        return false; 
    290 } 
    291  
    292  
    293 void ViewCellsManager::TestEmptyViewCells(const ObjectContainer &obj) 
    294 { 
    295         ViewCellContainer::const_iterator it, it_end = mEmptyViewCells.end(); 
    296  
    297         char buf[50]; 
    298         int i = 0; 
    299         for (it = mEmptyViewCells.begin(); it != it_end; ++ it) 
    300         { 
    301                 if (!(*it)->GetPvs().Empty()) 
    302                 { 
    303                         sprintf(buf, "empty-viewcells-%09d.x3d", i/*(*it)->GetId()*/); 
    304                         Exporter *exporter = Exporter::GetExporter(buf); 
    305                          
    306                         if (exporter && i < 20) 
    307                         { 
    308                                 Ray *pray = (*it)->mPiercingRays[0]; 
    309                                 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: "  
    310                                           << (*it)->GetPvs().CountObjectsInPvs() << " " << (int)pray->intersections.size() << endl; 
    311  
    312                                 exporter->ExportRays((*it)->mPiercingRays); 
    313                                                          
    314                                 exporter->SetFilled(); 
    315                                 exporter->SetForcedMaterial(RgbColor(0,0,1)); 
    316  
    317                                 for (int j = 0; j < (int)pray->intersections.size(); ++ j) 
    318                                 { 
    319                                         if (pray->intersections[j].mObject) 
    320                                                 exporter->ExportIntersectable(pray->intersections[j].mObject); 
    321                                 } 
    322  
    323                                 //exporter->SetWireframe(); 
    324                                 exporter->SetForcedMaterial(RgbColor(0,1,0)); 
    325                                 exporter->ExportGeometry(obj); 
    326  
    327                                 exporter->SetFilled(); 
    328  
    329                                 exporter->SetForcedMaterial(RgbColor(1,0,0)); 
    330                                 ExportViewCellGeometry(exporter, *it); 
    331  
    332                                 delete exporter;                 
    333                         } 
    334  
    335                  
    336                         ++ i; 
    337                 } 
    338         } 
    339         Debug << "\nSampled " << i << " new view cells ("  
    340                   << " of " << (int)mEmptyViewCells.size() << ")" << endl << endl; 
    341270} 
    342271 
     
    15821511        vc->GetPvs().Merge(right->GetPvs()); 
    15831512 
    1584         //-- merge ray sets 
    1585         if (0) 
    1586         { 
    1587                 stable_sort(left->mPiercingRays.begin(), left->mPiercingRays.end()); 
    1588                 stable_sort(right->mPiercingRays.begin(), right->mPiercingRays.end()); 
    1589  
    1590                 std::merge(left->mPiercingRays.begin(), left->mPiercingRays.end(), 
    1591                                    right->mPiercingRays.begin(), right->mPiercingRays.end(), 
    1592                                    vc->mPiercingRays.begin()); 
    1593         } 
    1594  
    15951513        // set only links to child (not from child to parent, maybe not wished!!) 
    15961514        vc->mChildren.push_back(left); 
     
    20031921{ 
    20041922        if (ViewCellsTreeConstructed()) 
     1923        { 
    20051924                mViewCellsTree->CreateUniqueViewCellsIds(); 
    2006         else 
     1925        } 
     1926        else // no view cells tree, handle view cells "myself" 
     1927        { 
    20071928                for (int i = 0; i < (int)mViewCells.size(); ++ i) 
     1929                { 
    20081930                        mViewCells[i]->SetId(i); 
     1931                } 
     1932        } 
    20091933} 
    20101934 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1278 r1284  
    671671        bool mShowVisualization; 
    672672 
    673         // HACK in order to detect empty view cells 
    674         void CollectEmptyViewCells(); 
    675         void TestEmptyViewCells(const ObjectContainer &obj); 
    676  
    677         ViewCellContainer mEmptyViewCells; 
    678  
    679673        int mRenderCostEvaluationType; 
    680674 
  • 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        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r1278 r1284  
    118118  void EndVspInterior(); 
    119119 
    120   void StartViewCell(ViewCell *viewCell, AttributeList&  attributes); 
     120  void ParseViewCellPvs(ViewCell *viewCell, AttributeList&  attributes); 
    121121  void EndViewCells(); 
    122122  void EndBoundingBoxes(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1272 r1284  
    134134#endif 
    135135 
    136   cerr<<"HERE!\n"; 
    137136        int returnCode = 0; 
    138137         
Note: See TracChangeset for help on using the changeset viewer.