Changeset 1311


Ignore:
Timestamp:
09/01/06 11:19:39 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
6 edited

Legend:

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

    r1297 r1311  
    24272427 
    24282428 
     2429        RegisterOption("Hierarchy.Construction.minDepthForOsp", 
     2430                                        optInt, 
     2431                                        "hierarchy_construction_min_depth_for_osp=", 
     2432                                        "-1"); 
     2433 
     2434 
    24292435        ////////////////////////////////////////////////////////////////////////////////// 
    24302436} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1308 r1311  
    102102                "Hierarchy.Construction.type", mConstructionType); 
    103103 
    104         mMinDepthForObjectSpaceSubdivion = -1; 
    105  
     104        Environment::GetSingleton()->GetIntValue( 
     105                "Hierarchy.Construction.minDepthForOsp", mMinDepthForObjectSpaceSubdivion); 
     106         
    106107        Debug << "******** Hierachy Manager Parameters ***********" << endl; 
    107108        Debug << "max leaves: " << mTermMaxLeaves << endl; 
     
    196197 
    197198void HierarchyManager::Construct(const VssRayContainer &sampleRays, 
    198                                                                 const ObjectContainer &objects, 
    199                                                                 AxisAlignedBox3 *forcedViewSpace) 
    200 { 
    201          
    202         RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    203  
     199                                                                 const ObjectContainer &objects, 
     200                                                                 AxisAlignedBox3 *forcedViewSpace) 
     201{ 
     202         
    204203        mHierarchyStats.Reset(); 
    205204        mHierarchyStats.Start(); 
    206  
    207         // start with view space subdivison: prepare vsp tree for traversal 
     205         
     206        mTotalCost = (float)objects.size(); 
     207        Debug << "setting total cost to " << mTotalCost << endl; 
     208 
     209        const long startTime = GetTime(); 
     210        cout << "Constructing view space / object space tree ... \n"; 
     211         
     212        // process object space candidates 
     213        RunConstruction(sampleRays, objects, forcedViewSpace); 
     214         
     215        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     216        mVspTree->mVspStats.Stop(); 
     217} 
     218 
     219 
     220void HierarchyManager::PrepareViewSpaceSubdivision(const VssRayContainer &sampleRays, 
     221                                                                                                   const ObjectContainer &objects, 
     222                                                                                                   AxisAlignedBox3 *forcedViewSpace) 
     223{ 
     224        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    208225        SubdivisionCandidate *vsc =  
    209226                mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
     227 
    210228        mTQueue.Push(vsc); 
    211  
    212         mTotalCost = (float)objects.size(); 
    213         Debug << "setting total cost to " << mTotalCost << endl; 
    214  
    215         const long startTime = GetTime();        
    216         cout << "Constructing view space / object space tree ... \n"; 
    217          
    218         // process object space candidates 
    219         RunConstruction(); 
    220          
    221         cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    222         mVspTree->mVspStats.Stop(); 
    223229} 
    224230 
     
    313319bool HierarchyManager::StartObjectSpaceSubdivision() const 
    314320{ 
    315         const bool constructAfterViewSpace = (mConstructionType == 1) && mTQueue.Empty(); 
    316  
    317         return  
    318                 NO_OBJ_SUBDIV && 
    319                 ((mMinDepthForObjectSpaceSubdivion < 0/*mVspTree->mVspStats.mMaxDepth*/) || constructAfterViewSpace); 
    320 } 
    321  
    322  
    323 void HierarchyManager::RunConstruction() 
     321        const bool ospDepthReached =  
     322                (mMinDepthForObjectSpaceSubdivion == mVspTree->mVspStats.maxDepth); 
     323        const bool stillNotOsp = (mObjectSpaceSubdivisionType == NO_OBJ_SUBDIV); 
     324         
     325        Debug << "here10 " << mMinDepthForObjectSpaceSubdivion << " " << mVspTree->mVspStats.maxDepth << endl; 
     326     
     327        return stillNotOsp && (mTQueue.Empty() || ospDepthReached); 
     328} 
     329 
     330 
     331void HierarchyManager::RunConstruction(const VssRayContainer &sampleRays, 
     332                                                                           const ObjectContainer &objects, 
     333                                                                           AxisAlignedBox3 *forcedViewSpace) 
    324334{ 
    325335        mHierarchyStats.nodes = 0; 
    326336        mGlobalCostMisses = 0; 
    327  
    328         // use objects for evaluating vsp tree construction 
     337Debug << "here2" << endl; 
     338        // use objects for evaluating vsp tree construction in the first levels 
     339        // of the subdivision 
    329340        const int savedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
    330341        mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 
    331  
    332         //const bool repairQueue = false; 
    333         const bool repairQueue = true; 
    334  
    335         do 
    336         { 
    337                 // use objects for evaluating vsp tree construction until a certain depth 
     342Debug << "here3" << endl; 
     343        // start with view space subdivison: prepare vsp tree for traversal 
     344        PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
     345 
     346        const bool repairQueue = false; 
     347        //const bool repairQueue = true; 
     348 
     349        while (!FinishedConstruction()); 
     350        {Debug << "here7" << endl; 
     351                // we use objects for evaluating vsp tree construction until  
     352                // a certain depth once a certain depth existiert .... 
    338353                if (StartObjectSpaceSubdivision()) 
    339354                { 
     355                        Debug << "here8" << endl; 
    340356                        mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
    341                         //PrepareObjectSpaceSubdivision(); 
     357                        PrepareObjectSpaceSubdivision(sampleRays, objects); 
     358                        Debug << "here9" << endl; 
    342359                } 
    343360 
     
    365382                        // this would be object space splits and other way round 
    366383                        if (repairQueue) RepairQueue(); 
    367                 }        
     384                } 
     385 
    368386                DEL_PTR(mCurrentCandidate); 
    369387        } 
    370         while (!FinishedConstruction()); 
     388         
    371389 
    372390        mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
     
    377395{ 
    378396        return mTQueue.Empty(); 
     397} 
     398 
     399 
     400int HierarchyManager::GetObjectSpaceSubdivisionType() 
     401{ 
     402        if (!ObjectSpaceSubdivisionConstructed()) 
     403                return NO_OBJECT_SUBDIV; 
     404 
     405        return mObjectSpaceSubdivisionType; 
     406} 
     407 
     408 
     409bool HierarchyManager::ObjectSpaceSubdivisionConstructed() 
     410{ 
     411        switch (mObjectSpaceSubdivisionType) 
     412        { 
     413        case KD_BASED_OBJ_SUBDIV: 
     414                return mOspTree && mOspTree->GetRoot(); 
     415        case BV_BASED_OBJ_SUBDIV: 
     416                return mBvHierarchy && mOspTree->GetRoot(); 
     417        default: 
     418        return false; 
     419        } 
    379420} 
    380421 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1308 r1311  
    169169        /** The type of object space subdivison 
    170170        */ 
    171         inline int GetObjectSpaceSubdivisonType() const 
     171        int HierarchyManager::GetObjectSpaceSubdivisionType() const 
    172172        { 
    173173                return mObjectSpaceSubdivisionType; 
    174174        } 
    175          
     175                 
    176176        void SetViewCellsManager(ViewCellsManager *vcm); 
    177177 
     
    207207                const ObjectContainer &objects); 
    208208 
    209         void RunConstruction(); 
     209        void RunConstruction( 
     210                const VssRayContainer &sampleRays, 
     211                const ObjectContainer &objects, 
     212                AxisAlignedBox3 *forcedViewSpace); 
     213 
    210214        bool ApplySubdivisionCandidate(SubdivisionCandidate *sc); 
    211215 
     
    238242        void ExportBvHierarchy(Exporter *exporter, const ObjectContainer &objects) const; 
    239243 
    240  
    241244        void PrepareBvHierarchy( 
    242245                const VssRayContainer &sampleRays, 
     
    250253 
    251254        bool StartObjectSpaceSubdivision() const; 
     255 
     256        void PrepareViewSpaceSubdivision( 
     257                const VssRayContainer &sampleRays, 
     258                const ObjectContainer &objects, 
     259                AxisAlignedBox3 *forcedViewSpace); 
    252260 
    253261 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1297 r1311  
    17621762        } 
    17631763         
    1764         // interior node 
    1765          
    17661764        // interior nodes: pvs is either stored as a scalar or 
    17671765        // has to be reconstructed from the leaves 
    1768  
    17691766        // the stored pvs size is the valid pvs size => just return scalar 
    17701767        if (vc->mPvsSizeValid) 
     
    19591956{ 
    19601957        int pvsSize = 0; 
    1961  
    19621958        Intersectable::NewMail(); 
    19631959 
    19641960        //////////////////////////////////////////////// 
    1965         //  for interiors, pvs can be stored using different methods 
     1961        // for interiors, pvs can be stored using different methods 
    19661962        // 
    19671963 
     
    19691965        { 
    19701966        case PVS_IN_LEAVES: //-- store pvs only in leaves 
    1971                 {                        
    1972                         pvsSize = GetPvsSizeForLeafStorage(vc);                  
    1973                         break; 
    1974                 } 
     1967                pvsSize = GetPvsSizeForLeafStorage(vc);                  
     1968                break; 
    19751969        case COMPRESSED: 
    1976                 { 
    1977                         pvsSize = GetPvsSizeForCompressedStorage(vc); 
    1978                         break; 
    1979                 } 
     1970                pvsSize = GetPvsSizeForCompressedStorage(vc); 
     1971                break; 
    19801972        case PVS_IN_INTERIORS: 
    19811973        default: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1302 r1311  
    362362        startTime = GetTime(); 
    363363 
    364         // -- stats after construction 
     364        //-- stats after construction 
    365365        ResetViewCells(); 
    366366        Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 
     
    13191319{ 
    13201320        mCurrentViewCellsStats.Reset(); 
    1321  
    13221321        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    13231322 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r1281 r1311  
    485485  } 
    486486#endif 
    487   VssTree *vssTree = NULL; 
    488    
     487  VssTree *vssTree = NULL;  
    489488 
    490489  long initialTime = GetTime(); 
     
    499498  else 
    500499  { 
    501          
    502500        while (totalSamples < mInitialSamples) { 
    503501                int passContributingSamples = 0; 
Note: See TracChangeset for help on using the changeset viewer.