Changeset 1557


Ignore:
Timestamp:
10/03/06 10:10:01 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
8 edited

Legend:

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

    r1548 r1557  
    608608                                                                                                   const ObjectContainer &objects) 
    609609{ 
    610         switch (mObjectSpaceSubdivisionType) 
    611         { 
    612         case BV_BASED_OBJ_SUBDIV: 
    613         Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 
    614                 cout << "\nresetting bv hierarchy" << endl; 
    615                 mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 
    616610#if 0    
    617611                DEL_PTR(mBvHierarchy); 
     
    620614 
    621615                PrepareObjectSpaceSubdivision(sampleRays, objects); 
    622 #else 
    623                 mBvHierarchy->Reset(sampleRays, objects); 
     616                return; 
    624617#endif 
    625                 break; 
     618 
     619        if (!ObjectSpaceSubdivisionConstructed()) 
     620        { 
     621                return PrepareObjectSpaceSubdivision(sampleRays, objects); 
     622        } 
     623 
     624        switch (mObjectSpaceSubdivisionType) 
     625        { 
     626        case BV_BASED_OBJ_SUBDIV: 
     627                cout << "\nreseting bv hierarchy" << endl; 
     628        Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 
     629         
     630                mHierarchyStats.nodes -= mBvHierarchy->mBvhStats.nodes; 
     631                mTQueue.Push(mBvHierarchy->Reset(sampleRays, objects)); 
     632                mTotalCost = mBvHierarchy->mTotalCost; 
     633                break; 
     634 
    626635        case KD_BASED_OBJ_SUBDIV: 
    627636                // TODO 
     
    630639                break; 
    631640        } 
     641} 
     642 
     643 
     644void HierarchyManager::ResetViewSpaceSubdivision(const VssRayContainer &sampleRays,  
     645                                                                                                 const ObjectContainer &objects) 
     646{ 
     647        DEL_PTR(mBvHierarchy); 
     648        mBvHierarchy = new BvHierarchy(); 
     649        mBvHierarchy->mHierarchyManager = this; 
     650 
     651        PrepareViewSpaceSubdivision(sampleRays, objects); 
     652        return; 
    632653} 
    633654 
     
    639660        mHierarchyStats.Reset(); 
    640661        mHierarchyStats.Start(); 
    641  
    642662        mHierarchyStats.nodes = 2; 
    643663         
    644  
    645664        mTotalCost = (float)objects.size(); 
    646665        Debug << "setting total cost to " << mTotalCost << endl; 
     
    655674        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
    656675        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
    657  
    658         // start with object space subdivision 
    659         PrepareObjectSpaceSubdivision(sampleRays, objects); 
    660          
    661         // process object space candidates 
    662         RunConstruction(false); 
    663  
    664         mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
    665  
    666         const int limit = 2; 
    667         for (int i = 0; i < limit; ++ i) 
    668         { 
    669         // again run object space subdivision on the view cells 
     676         
     677        const int limit = 4; 
     678        int i = 0; 
     679 
     680        // render cost optimization 
     681        // start with object space partiton 
     682        // then optimizate view space partition for the current osp 
     683        // and vice versa until iteration depth is reached. 
     684        while (1) 
     685        { 
     686        // first run object space subdivision 
    670687                ResetObjectSpaceSubdivision(sampleRays, objects); 
    671          
     688 
    672689                // process object space candidates 
    673690                RunConstruction(false); 
    674691 
    675                  ///////////////// 
    676                 // now do view space subdivison using the current object space partition 
    677 //              ResetViewSpaceSubdivision(sampleRays, objects); 
    678          
     692                if ((++ i) >= limit) 
     693                        break; 
     694 
     695                ///////////////// 
     696                // do view space subdivison with respect to the object space partition 
     697                ResetViewSpaceSubdivision(sampleRays, objects); 
     698 
    679699                // process view space candidates 
    680700                RunConstruction(false); 
    681          
    682                 cout << "íteration " << i << " of " << limit << " finished" << endl; 
     701                mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     702                 
     703                if ((++ i) >= limit) 
     704                        break; 
     705 
     706                cout << "iteration " << i << " of " << limit << " finished" << endl; 
    683707        } 
    684708         
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1551 r1557  
    315315                const ObjectContainer &objects); 
    316316 
     317        void HierarchyManager::ResetViewSpaceSubdivision( 
     318                const VssRayContainer &rays,  
     319                const ObjectContainer &objects); 
     320 
    317321protected: 
    318322 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1553 r1557  
    174174{ 
    175175        Randomize(); // initialise random generator for heuristics 
    176         mOutOfBoundsCell = new BspViewCell(); 
    177         mOutOfBoundsCell->SetId(-1); 
     176        mOutOfBoundsCell = GetOrCreateOutOfBoundsCell(); 
     177 
    178178        ///////// 
    179179        //-- termination criteria for autopartition 
     
    277277 
    278278 
     279BspViewCell *BspTree::GetOrCreateOutOfBoundsCell() 
     280{ 
     281        if (!mOutOfBoundsCell) 
     282        { 
     283                mOutOfBoundsCell = new BspViewCell(); 
     284                mOutOfBoundsCell->SetId(OUT_OF_BOUNDS_ID); 
     285                mOutOfBoundsCell->SetValid(false); 
     286        } 
     287 
     288        return mOutOfBoundsCell; 
     289} 
     290 
    279291int BspTree::SplitPolygons(const Plane3 &plane, 
    280292                                                   PolygonContainer &polys,  
     
    420432        if (mOutOfBoundsCellPartOfTree) 
    421433        { 
    422                 cout << "here223 " << mOutOfBoundsCell << endl; 
    423434                // out of bounds cell not part of tree => 
    424435                // delete manually 
    425436                DEL_PTR(mOutOfBoundsCell); 
    426         }else cout << "here991 " << endl; 
     437        } 
    427438} 
    428439 
     
    9991010                        // add predefined view cell to leaf 
    10001011                        viewCell = dynamic_cast<BspViewCell *>(tData.mViewCell); 
    1001                  
    1002                         /// out of bounds cell can be handled as any other cell 
     1012 
     1013                        // from now on out of bounds cell can be handled as any other cell, 
     1014                        // responsibility for deleting has been shifted 
    10031015                        if (viewCell == mOutOfBoundsCell) 
     1016                        { 
    10041017                                mOutOfBoundsCellPartOfTree = true; 
     1018                        } 
    10051019                } 
    10061020 
     
    23642378 
    23652379 
    2366  
    23672380void BspTree::ConstructGeometry(ViewCell *vc,  
    23682381                                                                BspNodeGeometry &vcGeom) const 
     
    23792392        for (it = leaves.begin(); it != it_end; ++ it) 
    23802393        { 
     2394                // per definition out of bounds cell has zero volume 
     2395                if ((*it) == mOutOfBoundsCell) 
     2396                        continue; 
     2397 
    23812398                BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*it); 
    23822399                vector<BspLeaf *>::const_iterator bit, bit_end = bspVc->mLeaves.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1551 r1557  
    8989        Vector3 CenterOfMass() const; 
    9090 
     91        /** Returns true if this geometry is well shaped. 
     92        */ 
    9193        bool Valid() const; 
    92  
    9394         
    9495        friend ostream &operator<<(ostream &s, const BspNodeGeometry &a) 
     
    101102        } 
    102103 
     104        /** Number of polygons. 
     105        */ 
    103106        int Size() const; 
     107        /** Returns the polygons in a container. 
     108        */ 
    104109        const PolygonContainer &GetPolys(); 
    105110 
     
    679684        */ 
    680685        void SetViewCellsTree(ViewCellsTree *vct); 
    681                  
     686         
     687        /** Returns view cell representing the empty view space. 
     688        */ 
     689        BspViewCell *GetOrCreateOutOfBoundsCell(); 
     690 
    682691protected: 
    683692 
     
    10711080 
    10721081        bool mOutOfBoundsCellPartOfTree; 
     1082 
     1083 
    10731084private: 
    10741085         
     
    10931104        static void GenerateUniqueIdsForPvs(); 
    10941105 
     1106        /////////// 
    10951107        //-- unique ids for PVS criterium 
     1108 
    10961109        static int sFrontId;  
    10971110        static int sBackId; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1551 r1557  
    19651965                for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
    19661966                { 
    1967                         if ((*vit)->GetId() != -1)  
     1967                        if ((*vit)->GetId() != OUT_OF_BOUNDS_ID)  
     1968                        { 
    19681969                                mViewCells[i]->SetId(i ++); 
     1970                        } 
    19691971                } 
    19701972        } 
     
    29882990                                                                                                 const AxisAlignedPlane *clipPlane 
    29892991                                                                                                 ) const 
    2990 {cout << "here55543 " << vc->GetId() << endl; 
     2992{ 
    29912993        // out of bounds cell 
    2992         if (vc->GetId() == -1) 
    2993                 return; 
     2994        //if (vc->GetId() == OUT_OF_BOUNDS_ID) return; 
    29942995 
    29952996        // export mesh if available 
     
    45004501{ 
    45014502        // out of bounds cell 
    4502         if (vc->GetId() == -1) 
    4503                 return; 
    4504  
     4503        //if (vc->GetId() == OUT_OF_BOUNDS_ID)  return; 
    45054504        if (clipPlane) 
    45064505        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1551 r1557  
    5454  float mRenderBudget; 
    5555 
    56   /// some characteristic values could be here 
    57    
     56  // some characteristic values could be stored as well 
    5857}; 
    59  
    6058 
    6159/**     Manages different higher order operations on the view cells. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1551 r1557  
    7575        if (randomize) Randomize(); // initialise random generator for heuristics 
    7676 
     77        ////////////////// 
    7778        //-- termination criteria for autopartition 
     79 
    7880        Environment::GetSingleton()->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 
    7981        Environment::GetSingleton()->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 
     
    8688        Environment::GetSingleton()->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 
    8789 
    88         //-- max cost ratio for early tree termination 
     90        //////////////////////// 
     91        //-- cost ratios for early tree termination 
    8992        Environment::GetSingleton()->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    90  
    9193        Environment::GetSingleton()->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
    9294        Environment::GetSingleton()->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    9395 
     96        /////////// 
    9497        //-- factors for bsp tree split plane heuristics 
     98 
    9599        Environment::GetSingleton()->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 
    96100        Environment::GetSingleton()->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 
    97101 
    98  
     102        ////////// 
    99103        //-- partition criteria 
     104 
    100105        Environment::GetSingleton()->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 
    101106        Environment::GetSingleton()->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 
     
    108113        Environment::GetSingleton()->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    109114         
     115        ////////////////////// 
    110116        //-- termination criteria for axis aligned split 
    111117        Environment::GetSingleton()->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",  
     
    114120                                                         mTermMinRaysForAxisAligned); 
    115121 
    116         //Environment::GetSingleton()->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 
    117122        Environment::GetSingleton()->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 
    118123 
     
    136141        Environment::GetSingleton()->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisIfMaxCostViolated); 
    137142 
     143        ///////// 
    138144        //-- debug output 
    139145 
     
    148154        Debug << "max view cells: " << mMaxViewCells << endl; 
    149155        Debug << "max polygon candidates: " << mMaxPolyCandidates << endl; 
    150         //Debug << "max plane candidates: " << mMaxRayCandidates << endl; 
    151156        Debug << "randomize: " << randomize << endl; 
    152157 
     
    195200        } 
    196201 
     202        Debug << endl; 
    197203 
    198204        mLocalSubdivisionCandidates = new vector<SortableEntry>; 
    199  
    200         Debug << endl; 
    201205} 
    202206 
     
    213217        { 
    214218                mOutOfBoundsCell = new BspViewCell(); 
    215                 mOutOfBoundsCell->SetId(-1); 
     219                mOutOfBoundsCell->SetId(OUT_OF_BOUNDS_ID); 
    216220                mOutOfBoundsCell->SetValid(false); 
    217221        } 
     
    30033007        for (it = leaves.begin(); it != it_end; ++ it) 
    30043008        { 
     3009                if ((*it) == mOutOfBoundsCell) 
     3010                        continue; 
     3011                 
    30053012                BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*it); 
    30063013                vector<BspLeaf *>::const_iterator bit, bit_end = bspVc->mLeaves.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/common.h

    r1287 r1557  
    511511#endif 
    512512 
    513 #endif 
    514  
    515  
    516  
    517  
    518  
    519  
    520  
    521  
    522  
    523  
     513/** view cell id belonging to empty view space. 
     514*/ 
     515#define OUT_OF_BOUNDS_ID -1 
     516 
     517#endif 
     518 
     519 
     520 
     521 
     522 
     523 
     524 
     525 
     526 
     527 
Note: See TracChangeset for help on using the changeset viewer.