Changeset 734


Ignore:
Timestamp:
04/07/06 23:42:54 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj

    r728 r734  
    8383                                AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib QtCore4.lib QtGui4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 
    8484                                AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib"" 
    85                                 GenerateDebugInformation="TRUE" 
     85                                GenerateDebugInformation="FALSE" 
    8686                                LargeAddressAware="2"/> 
    8787                        <Tool 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r728 r734  
    20642064                "false"); 
    20652065 
     2066        RegisterOption("VspBspTree.useDepthFirstSplits", 
     2067                optBool, 
     2068                "vsp_bsp_depth_first_splits=", 
     2069                "false"); 
     2070 
    20662071        RegisterOption("VspBspTree.useRandomAxis", 
    20672072                optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r729 r734  
    532532        // frequency stats are updated 
    533533        const int statsOut = 500; 
    534         Debug << "here3" << endl; Debug.flush(); 
     534         
    535535        // passes are needed for statistics, because we don't want to record 
    536536        // every merge 
     
    546546        int maxMergesPerPass; 
    547547        int numMergedViewCells = 0; 
    548         Debug << "here5" << endl; Debug.flush(); 
     548         
    549549        environment->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", maxMergesPerPass); 
    550550        environment->GetFloatValue("ViewCells.PostProcess.avgCostMaxDeviation", avgCostMaxDeviation); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r729 r734  
    178178  } 
    179179 
     180 static bool SmallerRenderCost(const ViewCell *a, const ViewCell *b)  
     181 { 
     182         return a->GetRenderCost() < b->GetRenderCost(); 
     183 } 
    180184 
    181185        void SetMergeCost(const float mergeCost); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r729 r734  
    9191        environment->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize); 
    9292        environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 
    93         environment->GetIntValue("ViewCells.mRenderCostEvaluationType", mRenderCostEvaluationType); 
     93        environment->GetIntValue("ViewCells.renderCostEvaluationType", mRenderCostEvaluationType); 
    9494 
    9595        char buf[100]; 
     
    129129        environment->GetStringValue("ViewCells.renderCostEvaluationType", buf); 
    130130         
    131         if (strcmp(buf, "box") == 0) 
     131        if (strcmp(buf, "perobject") == 0) 
    132132        { 
    133133                mRenderCostEvaluationType = ViewCellsManager::PER_OBJECT; 
     
    535535} 
    536536 
     537 
    537538void ViewCellsManager::EvalViewCellHistogram(const string filename, const int nViewCells) 
    538539{ 
     
    540541        outstream.open(filename.c_str()); 
    541542 
     543        Debug << "here3" << endl; 
    542544        ViewCellContainer viewCells; 
    543545        mViewCellsTree->CollectBestViewCellSet(mViewCells, nViewCells); 
    544546 
    545547        float maxRenderCost, minRenderCost; 
     548 
    546549        /// find out the range for valid render cost 
    547550        ComputeMinMaxRenderCost(minRenderCost, maxRenderCost, viewCells); 
     551 
     552        // sort by render cost 
     553        sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerRenderCost); 
     554 
     555        minRenderCost = viewCells.front()->GetRenderCost(); 
     556        maxRenderCost = viewCells.back()->GetRenderCost(); 
    548557 
    549558        const int intervals = 10000; 
     
    552561        const int stepSize = (int)((float)range / (float)intervals); 
    553562 
     563        float vol = 0; 
     564        int smallerCost = 0; 
     565 
     566        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end();              
     567 
     568        int i = 0; 
     569 
     570        // note can skip computations for view cells already evaluated and delete them from vector ... 
     571    while (1) 
     572        { 
     573        Debug << "here4" << endl; 
     574                while ((i < (int)viewCells.size()) && (viewCells[i]->GetRenderCost() < currentRenderCost)) 
     575                { 
     576                         
     577        Debug << "here5" << endl; 
     578                        ++ i; 
     579                        ++ smallerCost; 
     580                        vol += viewCells[i]->GetVolume(); 
     581                } 
     582 
     583                currentRenderCost += stepSize; 
     584                 
     585                outstream << "#RenderCost: " << currentRenderCost << endl; 
     586                outstream << "#ViewCells: " << smallerCost << endl;              
     587                outstream << "#Volume: " << vol << endl << endl; 
     588        } 
     589        outstream.close(); 
     590        Debug << "here6" << endl; 
     591} 
     592 
     593/* 
     594void ViewCellsManager::EvalViewCellHistogramForPvs(const string filename, const int nViewCells) 
     595{ 
     596        std::ofstream outstream; 
     597        outstream.open(filename.c_str()); 
     598 
     599        ViewCellContainer viewCells; 
     600        mViewCellsTree->CollectBestViewCellSet(mViewCells, nViewCells); 
     601 
     602        float maxRenderCost, minRenderCost; 
     603        /// find out the range for valid render cost 
     604        ComputeMinMaxRenderCost(minRenderCost, maxRenderCost, viewCells); 
     605 
     606        const int intervals = 10000; 
     607        const float range = maxRenderCost - minRenderCost; 
     608        int currentRenderCost = (int)ceil(minRenderCost); 
     609        const int stepSize = (int)((float)range / (float)intervals); 
     610        float vol = 0; 
     611 
     612        ViewCell::NewMail(); 
     613 
    554614        for (; currentRenderCost < (int)maxRenderCost; currentRenderCost += stepSize) 
    555615        { 
     
    558618                int smallerCost = 0; 
    559619 
    560                 for (it = viewCells.begin(); it != viewCells.end(); ++ it) 
    561                 { 
     620                // note can skip computations for view cells already evaluated and delete them from vector ... 
     621        for (it = viewCells.begin(); it != viewCells.end(); ++ it) 
     622                { 
     623                        if (!vc->Mailed()) 
     624                        { 
     625                                vc->Mail(); 
    562626                        ViewCell *vc = *it; 
    563627 
    564628                        if (EvalRenderCost(vc) < currentRenderCost) 
     629                        { 
    565630                                ++ smallerCost; 
     631                                vol = (*it)->GetVolume(); 
     632                        } 
    566633                } 
    567634                // note: can remove already found view cells 
     
    572639                outstream << "#RenderCost: " << currentRenderCost << endl; 
    573640                outstream << "#ViewCells: " << smallerCost << endl;              
    574         } 
    575  
    576 } 
    577  
     641                outstream << "#Volume: " << vol << endl << endl; 
     642        } 
     643} 
     644*/ 
    578645 
    579646void ViewCellsManager::EvalViewCellPartition(Preprocessor *preprocessor) 
     
    660727        } 
    661728         
    662         string filename = "histogram.log"; 
    663         int nViewCells = 5000; 
    664  
    665         EvalViewCellHistogram(filename, nViewCells); 
    666  
     729#if 0 
     730        // evaluate view cells in a histogram 
     731        vector<int> nViewCells; 
     732        nViewCells.push_back(10000); 
     733        nViewCells.push_back(5000); 
     734        nViewCells.push_back(1000); 
     735        nViewCells.push_back(500); 
     736        nViewCells.push_back(100); 
     737 
     738        vector<int>::const_iterator iit, iit_end = nViewCells.end(); 
     739        char filename[64]; 
     740 
     741        for (iit = nViewCells.begin(); iit != nViewCells.end(); ++ iit) 
     742        { 
     743                Debug << "here2" << endl; 
     744                int n = *iit; 
     745                 
     746                sprintf(filename, "histogram%06d.log", n); 
     747                EvalViewCellHistogram(filename, n); 
     748        } 
     749 
     750#endif 
    667751        // find empty view cells bug 
    668752        if (TEST_EMPTY_VIEW_CELLS) 
     
    687771        int i = 0; 
    688772 
    689         ViewCellContainer::const_iterator it, it_end = neighborhood.end(); 
    690  
    691         for (it = neighborhood.begin(); it != it_end; ++ it, ++ i) 
    692         { 
    693                 const float mc = EvalMergeCost(root, *it); 
     773        ViewCellContainer::const_iterator vit, vit_end = neighborhood.end(); 
     774 
     775        for (vit = neighborhood.begin(); vit != vit_end; ++ vit, ++ i) 
     776        { 
     777                const float mc = EvalMergeCost(root, *vit); 
    694778                 
    695779                if (mc < mergeCost) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r729 r734  
    155155        Debug << "use random axis: " << mUseRandomAxis << endl; 
    156156        Debug << "breath first splits: " << mBreathFirstSplits << endl; 
     157        Debug << "depth first splits: " << mDepthFirstSplits << endl; 
     158 
    157159        Debug << "empty view cells merge: " << mEmptyViewCellsMergeAllowed << endl; 
    158160 
     
    940942void VspBspTree::EvalPriority(VspBspTraversalData &tData) const 
    941943{ 
    942     tData.mPriority = mBreathFirstSplits ?  
    943                 (float)-tData.mDepth : tData.mPvs * tData.mProbability; 
     944        if (mBreathFirstSplits) 
     945                tData.mPriority = (float)-tData.mDepth; 
     946        else if (mDepthFirstSplits) 
     947                tData.mPriority = (float)tData.mDepth; 
     948        else 
     949                tData.mPriority = tData.mPvs * tData.mProbability; 
    944950        //cout << "priority: " << tData.mPriority << endl; 
    945951} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r729 r734  
    811811        /// if we should use breath first priority for the splits 
    812812        bool mBreathFirstSplits; 
    813  
     813        bool mDepthFirstSplits; 
    814814        bool mEmptyViewCellsMergeAllowed; 
    815815 
Note: See TracChangeset for help on using the changeset viewer.