Changeset 1313


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

Legend:

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

    r1308 r1313  
    451451        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    452452 
    453 #if 1 
     453#if 0 
    454454        const float priority = (float)-splitCandidate.mParentData.mDepth; 
    455455#else    
  • GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h

    r1297 r1313  
    7676        std::vector<T> mBuffer; 
    7777}; 
     78 
    7879 
    7980/*****************************************************************************/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1311 r1313  
    214214         
    215215        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     216        mHierarchyStats.Stop(); 
    216217        mVspTree->mVspStats.Stop(); 
    217218} 
     
    320321{ 
    321322        const bool ospDepthReached =  
    322                 (mMinDepthForObjectSpaceSubdivion == mVspTree->mVspStats.maxDepth); 
     323                (mMinDepthForObjectSpaceSubdivion <= mVspTree->mVspStats.maxDepth); 
    323324        const bool stillNotOsp = (mObjectSpaceSubdivisionType == NO_OBJ_SUBDIV); 
    324          
    325         Debug << "here10 " << mMinDepthForObjectSpaceSubdivion << " " << mVspTree->mVspStats.maxDepth << endl; 
    326325     
    327         return stillNotOsp && (mTQueue.Empty() || ospDepthReached); 
     326        return stillNotOsp && (mTQueue.Empty() || ((mConstructionType == 1) && ospDepthReached)); 
    328327} 
    329328 
     
    335334        mHierarchyStats.nodes = 0; 
    336335        mGlobalCostMisses = 0; 
    337 Debug << "here2" << endl; 
     336 
    338337        // use objects for evaluating vsp tree construction in the first levels 
    339338        // of the subdivision 
    340339        const int savedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
    341340        mObjectSpaceSubdivisionType = NO_OBJ_SUBDIV; 
    342 Debug << "here3" << endl; 
     341 
    343342        // start with view space subdivison: prepare vsp tree for traversal 
    344343        PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
    345344 
    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 .... 
    353                 if (StartObjectSpaceSubdivision()) 
    354                 { 
    355                         Debug << "here8" << endl; 
    356                         mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
    357                         PrepareObjectSpaceSubdivision(sampleRays, objects); 
    358                         Debug << "here9" << endl; 
    359                 } 
    360  
     345        //const bool repairQueue = false; 
     346        const bool repairQueue = true; 
     347cout << "here55 " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
     348        // start object space subdivision immediately? 
     349        if (StartObjectSpaceSubdivision()) 
     350        {cout << "here1155 "; 
     351                mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
     352                PrepareObjectSpaceSubdivision(sampleRays, objects); 
     353        } 
     354 
     355        int i = 0; 
     356        while (!FinishedConstruction()) 
     357        { 
    361358                mCurrentCandidate = NextSubdivisionCandidate();     
    362359                mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 
     
    370367                        ++ mGlobalCostMisses; 
    371368                } 
    372  
     369                 
    373370                //-- subdivide leaf node 
    374371                if (ApplySubdivisionCandidate(mCurrentCandidate)) 
    375372                { 
     373                        cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 
    376374                        mHierarchyStats.nodes += 2; 
    377375 
     
    384382                } 
    385383 
     384                // we use objects for evaluating vsp tree construction until  
     385                // a certain depth once a certain depth existiert .... 
     386                if (StartObjectSpaceSubdivision()) 
     387                { 
     388                        cout << "reseting queue ... "; 
     389                        ResetQueue(); 
     390                        cout << "finished" << endl; 
     391 
     392                        cout << "starting object space subdivision at maximal view space subdivison depth " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
     393                                                 
     394                        mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
     395                        PrepareObjectSpaceSubdivision(sampleRays, objects); 
     396                } 
     397 
    386398                DEL_PTR(mCurrentCandidate); 
    387399        } 
    388400         
    389  
    390401        mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
    391402} 
     
    398409 
    399410 
    400 int HierarchyManager::GetObjectSpaceSubdivisionType() 
    401 { 
    402         if (!ObjectSpaceSubdivisionConstructed()) 
    403                 return NO_OBJECT_SUBDIV; 
    404  
    405         return mObjectSpaceSubdivisionType; 
    406 } 
    407  
    408  
    409 bool HierarchyManager::ObjectSpaceSubdivisionConstructed() 
     411bool HierarchyManager::ObjectSpaceSubdivisionConstructed() const 
    410412{ 
    411413        switch (mObjectSpaceSubdivisionType) 
     
    489491 
    490492        // collect list of "dirty" candidates 
     493        long startTime = GetTime(); 
     494    
    491495        vector<SubdivisionCandidate *> dirtyList; 
    492496        CollectDirtyCandidates(dirtyList); 
    493         Debug << "collected " << (int)dirtyList.size() << " candidates for reevaluation" << endl; 
    494  
     497        cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 
     498         
    495499        //-- reevaluate the dirty list 
    496         vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 
     500        SubdivisionCandidateContainer::const_iterator sit, sit_end = dirtyList.end(); 
    497501         
    498502        for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 
     
    515519                mTQueue.Push(sc); // reinsert 
    516520        } 
     521 
     522        long endTime = GetTime(); 
     523        Real timeDiff = TimeDiff(startTime, endTime); 
     524 
     525        mHierarchyStats.repairTime += timeDiff; 
     526 
     527        cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 
     528} 
     529 
     530 
     531void HierarchyManager::ResetQueue() 
     532{ 
     533        SubdivisionCandidateContainer mCandidateBuffer; 
     534 
     535        // remove from queue 
     536        while (!mTQueue.Empty()) 
     537        { 
     538                SubdivisionCandidate *candidate = NextSubdivisionCandidate(); 
     539                candidate->EvalPriority(); // reevaluate 
     540                cout << "."; 
     541                mCandidateBuffer.push_back(candidate); 
     542        } 
     543 
     544        // put back into queue 
     545        SubdivisionCandidateContainer::const_iterator sit, sit_end = mCandidateBuffer.end(); 
     546    for (sit = mCandidateBuffer.begin(); sit != sit_end; ++ sit) 
     547        {cout << ":"; 
     548                mTQueue.Push(*sit); 
     549        } 
    517550} 
    518551 
     
    567600 
    568601 
    569 void HierarchyManager::PrintObjectSpaceHierarchyStatistics(ofstream &stream) const 
    570 { 
     602void HierarchyManager::PrintHierarchyStatistics(ofstream &stream) const 
     603{ 
     604        stream << mHierarchyStats << endl; 
     605 
     606        stream << "\nview space:" << endl << endl; 
     607        stream << mVspTree->GetStatistics() << endl; 
     608        stream << "\nobject space:" << endl << endl; 
    571609        switch (mObjectSpaceSubdivisionType) 
    572610        { 
    573611        case KD_BASED_OBJ_SUBDIV: 
    574612                { 
    575                         stream << mOspTree->GetStatistics(); 
     613                        stream << mOspTree->GetStatistics() << endl; 
    576614                        break; 
    577615                } 
    578616        case BV_BASED_OBJ_SUBDIV: 
    579617                { 
    580                         stream << mBvHierarchy->GetStatistics(); 
     618                        stream << mBvHierarchy->GetStatistics() << endl; 
    581619                        break; 
    582620                } 
     
    626664 
    627665 
    628 } 
     666void HierarchyStatistics::Print(ostream &app) const 
     667{ 
     668        app << "=========== Hierarchy statistics ===============\n"; 
     669 
     670        app << setprecision(4); 
     671 
     672        app << "#N_CTIME  ( Construction time [s] )\n" << Time() << " \n"; 
     673         
     674        app << "#N_RTIME  ( Repair time [s] )\n" << repairTime * 1e-3f << " \n"; 
     675 
     676        app << "#N_NODES ( Number of nodes )\n" << nodes << "\n"; 
     677 
     678        app << "#N_INTERIORS ( Number of interior nodes )\n" << Interior() << "\n"; 
     679 
     680        app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 
     681 
     682        app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 
     683         
     684        app << "========== END OF Hierarchy statistics ==========\n"; 
     685} 
     686 
     687 
     688} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1311 r1313  
    6868        /// total number of nodes 
    6969        int nodes; 
    70                  
    7170        /// maximal reached depth 
    7271        int maxDepth; 
    73          
    7472        /// accumulated depth 
    7573        int accumDepth; 
     74 
     75        float repairTime; 
    7676 
    7777        // Constructor 
     
    8787        // TODO: computation wrong 
    8888        double AvgDepth() const { return accumDepth / (double)Leaves();} 
    89          
    9089 
    9190        void Reset()  
     
    9493                maxDepth = 0; 
    9594                accumDepth = 0; 
    96         } 
    97  
     95                repairTime = 0; 
     96        } 
    9897 
    9998        void Print(ostream &app) const; 
     
    169168        /** The type of object space subdivison 
    170169        */ 
    171         int HierarchyManager::GetObjectSpaceSubdivisionType() const 
     170        int GetObjectSpaceSubdivisionType() const 
    172171        { 
    173172                return mObjectSpaceSubdivisionType; 
     
    187186                float &contribution) const; 
    188187 
    189         void PrintObjectSpaceHierarchyStatistics(ofstream &stream) const; 
     188        void PrintHierarchyStatistics(ofstream &stream) const; 
    190189 
    191190        VspTree *GetVspTree() { return mVspTree; } 
     
    259258                AxisAlignedBox3 *forcedViewSpace); 
    260259 
     260        bool ObjectSpaceSubdivisionConstructed() const; 
     261 
     262    void ResetQueue(); 
     263 
    261264 
    262265protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h

    r1305 r1313  
    5757}; 
    5858 
     59typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 
     60typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer; 
    5961 
    60 typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue; 
    61  
    62 typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer; 
    6362} 
    6463 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1311 r1313  
    48144814 
    48154815        // print subdivision statistics 
    4816         Debug << mHierarchyManager->GetVspTree()->GetStatistics() << endl; 
    4817         mHierarchyManager->PrintObjectSpaceHierarchyStatistics(Debug); 
     4816        mHierarchyManager->PrintHierarchyStatistics(Debug); 
    48184817 
    48194818        if (0) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1308 r1313  
    749749        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    750750 
    751 #if 1 
     751#if 0 
    752752        const float priority = (float)-splitCandidate.mParentData.mDepth; 
    753753#else 
     
    26772677        if (!obj) return; 
    26782678 
    2679         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2679        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    26802680        { 
    26812681        case HierarchyManager::KD_BASED_OBJ_SUBDIV: 
     
    27462746        int pvs = 0; 
    27472747 
    2748         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2748        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    27492749        { 
    27502750        case HierarchyManager::NO_OBJ_SUBDIV: 
     
    27912791                return 0; 
    27922792 
    2793         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2793        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    27942794        { 
    27952795        case HierarchyManager::NO_OBJ_SUBDIV: 
     
    28442844        int pvs = 0; 
    28452845 
    2846         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2846        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    28472847        { 
    28482848        case HierarchyManager::NO_OBJ_SUBDIV: 
     
    28952895        if (!obj) return; 
    28962896 
    2897         switch (mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2897        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    28982898        { 
    28992899                case HierarchyManager::NO_OBJ_SUBDIV: 
     
    29322932        int pvs = 0; 
    29332933 
    2934         switch(mHierarchyManager->GetObjectSpaceSubdivisonType()) 
     2934        switch(mHierarchyManager->GetObjectSpaceSubdivisionType()) 
    29352935        { 
    29362936        case HierarchyManager::NO_OBJ_SUBDIV: 
Note: See TracChangeset for help on using the changeset viewer.