Changeset 1679


Ignore:
Timestamp:
10/25/06 20:29:41 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh

    r1676 r1679  
    1313#SCENE=vsposp_typical 
    1414#SCENE=soda5_vsposp 
    15 SCENE=soda_vsposp 
    16 #SCENE=vienna_vsposp 
     15#SCENE=soda_vsposp 
     16SCENE=vienna_vsposp 
    1717#SCENE=arena_vsposp 
    1818#SCENE=vsposp_citymodel 
     
    6060 
    6161################################################################################## 
    62 MEMCONST=0.8 
    63  METHOD=gradient-mem-$MEMCONST 
    64  echo "$SCENE $METHOD" 
    65  
    66   $PROGRAM $ENVIRONMENT \ 
    67   -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    68   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
    69   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
    70   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
    71   -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    72   -hierarchy_construction_type=2 \ 
    73   -hierarchy_construction_consider_memory=true \ 
     62MEMCONST=1.0 
     63 METHOD=gradient-mem2-$MEMCONST 
     64 echo "$SCENE $METHOD" 
     65 
     66  $PROGRAM $ENVIRONMENT \ 
     67  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     68  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     69  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     70  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     71  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     72  -hierarchy_construction_type=2 \ 
     73  -hierarchy_construction_consider_memory2=true \ 
    7474 -bvh_construction_render_cost_decrease_weight=0.99 \ 
    7575 -vsp_construction_render_cost_decrease_weight=0.99 \ 
     
    8383################################################################################## 
    8484MEMCONST=0.5 
    85  METHOD=gradient-mem-$MEMCONST 
    86  echo "$SCENE $METHOD" 
    87  
    88   $PROGRAM $ENVIRONMENT \ 
    89   -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    90   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
    91   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
    92   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
    93   -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    94   -hierarchy_construction_type=2 \ 
    95   -hierarchy_construction_consider_memory=true \ 
     85 METHOD=gradient-mem2-$MEMCONST 
     86 echo "$SCENE $METHOD" 
     87 
     88  $PROGRAM $ENVIRONMENT \ 
     89  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     90  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     91  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     92  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     93  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     94  -hierarchy_construction_type=2 \ 
     95  -hierarchy_construction_consider_memory2=true \ 
    9696 -bvh_construction_render_cost_decrease_weight=0.99 \ 
    9797 -vsp_construction_render_cost_decrease_weight=0.99 \ 
     
    104104################################################################################## 
    105105MEMCONST=0.2 
    106  METHOD=gradient-mem-$MEMCONST 
    107  echo "$SCENE $METHOD" 
    108  
    109   $PROGRAM $ENVIRONMENT \ 
    110   -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    111   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
    112   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
    113   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
    114   -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    115   -hierarchy_construction_type=2 \ 
    116   -hierarchy_construction_consider_memory=true \ 
     106 METHOD=gradient-mem2-$MEMCONST 
     107 echo "$SCENE $METHOD" 
     108 
     109  $PROGRAM $ENVIRONMENT \ 
     110  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     111  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     112  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     113  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     114  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     115  -hierarchy_construction_type=2 \ 
     116  -hierarchy_construction_consider_memory2=true \ 
    117117 -bvh_construction_render_cost_decrease_weight=0.99 \ 
    118118 -vsp_construction_render_cost_decrease_weight=0.99 \ 
     
    126126 
    127127############################################################################ 
    128 NODES=1000 
     128NODES=10000 
    129129 
    130130  METHOD=sequential-$NODES 
    131131  echo "$SCENE $METHOD" 
    132132 
    133 # $PROGRAM $ENVIRONMENT \ 
     133 $PROGRAM $ENVIRONMENT \ 
    134134  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    135135  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     
    144144############################################################################ 
    145145 
    146 NODES=10000 
     146NODES=70000 
    147147 
    148148  METHOD=sequential-$NODES 
    149149  echo "$SCENE $METHOD" 
    150150 
    151  #$PROGRAM $ENVIRONMENT \ 
     151 $PROGRAM $ENVIRONMENT \ 
    152152  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    153153  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     
    168168  echo "$SCENE $METHOD" 
    169169 
    170 #  $PROGRAM $ENVIRONMENT \ 
    171 #   -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    172 #   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
    173 #   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
    174 #   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
    175 #   -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    176 #   -hierarchy_construction_type=0 \ 
    177 #   -bvh_term_max_leaves=$NODES 
     170 $PROGRAM $ENVIRONMENT \ 
     171  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     172  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     173  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     174  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     175  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     176  -hierarchy_construction_type=0 \ 
     177  -bvh_term_max_leaves=$NODES 
     178 
     179sh movefiles.sh $LOG_PREFIX-$METHOD 
     180 
     181 
     182############################################################################ 
     183 
     184NODES=100000 
     185 
     186  METHOD=sequential-$NODES 
     187  echo "$SCENE $METHOD" 
     188 
     189  $PROGRAM $ENVIRONMENT \ 
     190   -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     191   -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     192   -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     193   -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     194   -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     195   -hierarchy_construction_type=0 \ 
     196   -bvh_term_max_leaves=$NODES 
     197 
     198sh movefiles.sh $LOG_PREFIX-$METHOD 
     199 
     200 
     201################################################################################## 
     202MEMCONST=1.0 
     203 METHOD=gradient-multi-$MEMCONST 
     204 echo "$SCENE $METHOD" 
     205 
     206  $PROGRAM $ENVIRONMENT \ 
     207  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     208  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     209  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     210  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     211  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     212  -hierarchy_construction_type=2 \ 
     213  -hierarchy_construction_consider_memory2=true \ 
     214 -bvh_construction_render_cost_decrease_weight=0.99 \ 
     215 -vsp_construction_render_cost_decrease_weight=0.99 \ 
     216  -hierarchy_construction_multilevel=true \ 
     217 -hierarchy_construction_levels=4 \ 
     218  -hierarchy_term_memory_const=$MEMCONST \ 
     219  -hierarchy_construction_recompute_split_on_repair=true 
    178220 
    179221sh movefiles.sh $LOG_PREFIX-$METHOD 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1676 r1679  
    4444/***************************************************************/ 
    4545 
    46 BvhNode::BvhNode(): mParent(NULL), mMailbox(0) 
     46BvhNode::BvhNode():  
     47mParent(NULL),  
     48mMailbox(0), 
     49mRenderCostDecr(0),  
     50mMemoryIncr(0), 
     51mPvsEntriesIncr(0), 
     52mTimeStamp(0) 
    4753{ 
    4854} 
    4955 
    5056BvhNode::BvhNode(const AxisAlignedBox3 &bbox): 
    51 mParent(NULL), mBoundingBox(bbox), mMailbox(0) 
     57mParent(NULL),  
     58mBoundingBox(bbox),  
     59mMailbox(0), 
     60mMemoryIncr(0), 
     61mPvsEntriesIncr(0), 
     62mTimeStamp(0) 
    5263{ 
    5364} 
     
    5566 
    5667BvhNode::BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent): 
    57 mBoundingBox(bbox), mParent(parent), mMailbox(0) 
     68mBoundingBox(bbox),  
     69mParent(parent),  
     70mMailbox(0), 
     71mMemoryIncr(0), 
     72mPvsEntriesIncr(0), 
     73mTimeStamp(0) 
    5874{ 
    5975} 
     
    400416        backData.mMaxCostMisses = sc.GetMaxCostMisses(); 
    401417         
     418        // set the time stamp so the order of traversal can be reconstructed 
     419        node->mTimeStamp = mHierarchyManager->mTimeStamp ++; 
     420        cout << "here4 " << node->mTimeStamp << endl; 
     421        node->mRenderCostDecr = sc.GetRenderCostDecrease(); 
     422        node->mPvsEntriesIncr = sc.GetPvsEntriesIncr(); 
     423 
    402424        // assign the objects in sorted order 
    403425        if (mUseGlobalSorting) 
     
    491513        if (computeSplitPlane) 
    492514        { 
    493                 const bool sufficientSamples = splitCandidate.mParentData.mNumRays < mMinRaysForVisibility; 
     515                const bool sufficientSamples = splitCandidate.mParentData.mNumRays > mMinRaysForVisibility; 
    494516 
    495517                const bool useVisibiliyBasedHeuristics =  
    496518                        !mUseSah && 
    497                         !(mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) && 
     519                        (mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) && 
    498520                        sufficientSamples; 
    499521 
     
    12591281                                if (useVisibilityBasedHeuristics) 
    12601282                                { 
     1283                                        //cout << "v"; 
    12611284                                        /////////// 
    12621285                                        //-- heuristics using objects weighted by view cells volume 
    12631286                                        nCostRatio[axis] = 
    1264                                                 EvalLocalCostHeuristics( 
    1265                                                                                                 tData, 
    1266                                                                                                 axis, 
    1267                                                                                                 nFrontObjects[axis], 
    1268                                                                                                 nBackObjects[axis]); 
     1287                                                EvalLocalCostHeuristics(tData, axis, nFrontObjects[axis], nBackObjects[axis]); 
    12691288                                } 
    12701289                                else 
    1271                                 { 
     1290                                {//cout << "e"; 
    12721291                                        ////////////////// 
    12731292                                        //-- view cells not constructed yet     => use surface area heuristic                    
    12741293                                        nCostRatio[axis] = 
    1275                                                 EvalSah( 
    1276                                                                 tData, 
    1277                                                                 axis, 
    1278                                                                 nFrontObjects[axis], 
    1279                                                                 nBackObjects[axis]); 
     1294                                                EvalSah(tData, axis, nFrontObjects[axis], nBackObjects[axis]); 
    12801295                                } 
    12811296                        } 
     
    12841299                                //-- split objects using some simple criteria 
    12851300                                nCostRatio[axis] = 
    1286                                         EvalLocalObjectPartition( 
    1287                                                                                          tData, 
    1288                                                                                          axis, 
    1289                                                                                          nFrontObjects[axis], 
    1290                                                                                          nBackObjects[axis]); 
     1301                                        EvalLocalObjectPartition(tData, axis, nFrontObjects[axis], nBackObjects[axis]); 
    12911302                        } 
    12921303 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1677 r1679  
    198198        { mBoundingBox = boundingBox; } 
    199199 
    200  
    201         float GetMergeCost() {return 0.0f; }; 
     200        /** Cost of mergin this node. 
     201        */ 
     202        float GetMergeCost() {return (float)-mTimeStamp; } 
     203 
     204        int mTimeStamp; 
     205 
     206        int mPvsEntriesIncr; 
     207        float mMemoryIncr; 
     208        float mRenderCostDecr; 
    202209 
    203210        ///////////////////////////////////// 
     
    262269                return s << A.mBoundingBox; 
    263270        } 
    264 virtual void CollectObjects(ObjectContainer &objects); 
     271 
     272        virtual void CollectObjects(ObjectContainer &objects); 
    265273protected: 
    266274 
     
    444452                        if (hm->ConsiderMemory()) 
    445453                        { 
    446                                 //const float rc = mRenderCostDecrease / hm->GetHierarchyStats().mTotalCost; 
    447                                 const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 
     454                                const float rc = mRenderCostDecrease / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 
     455                                //const float mc = mMemoryIncr /  / hm->GetHierarchyStats().mMemory; 
     456                //const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 
     457                                const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries;    
     458                                 
    448459                                //cout << "\np: " << mPriority << " i: " << hm->mInitialRenderCost << " t: " << hm->GetHierarchyStats().mTotalCost << endl; 
    449                                 //const float mc = mMemoryIncr /  / hm->GetHierarchyStats().mMemory; 
    450                                 const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries;    
    451                                 cout << "osp rc: " << rc << " mc: " << mc << endl; 
     460                                //cout << "osp rc: " << rc << " mc: " << mc << endl; 
     461 
    452462                                return hm->GetMemoryConst() * rc - (1.0f - hm->GetMemoryConst()) * mc; 
    453463                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1677 r1679  
    319319                                                                 AxisAlignedBox3 *forcedViewSpace) 
    320320{ 
     321        mTimeStamp = 1; 
     322 
    321323        switch (mConstructionType) 
    322324        { 
     
    422424        // then optimizate view space partition for the current osp 
    423425        // and vice versa until iteration depth is reached. 
    424  
     426bool lastSplitWasOsp = true; 
    425427        while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 
    426428        { 
     
    432434 
    433435                // should view or object space be subdivided further? 
    434                 if (ospPriority >= vspPriority) 
    435                 { 
     436                //if (ospPriority >= vspPriority) 
     437                if (!lastSplitWasOsp) 
     438                { 
     439                        lastSplitWasOsp = true; 
    436440                        cout << "osp" << endl; 
    437441                        // dirtied view space candidates 
     
    456460                else 
    457461                { 
     462                        lastSplitWasOsp = false; 
    458463                        cout << "vsp" << endl; 
    459464                         
     
    912917                const float threshold = oldCandidate ? oldCandidate->GetPriority() : 1e20; 
    913918                SubdivisionCandidate *sc = NextSubdivisionCandidate(splitQueue);  
    914                 //cout << "here2 " << sc->GetPriority() << " " << threshold << endl; 
     919                //cout << "here2 " << sc->GetRenderCostDecrease() << " " << threshold << endl; 
     920                float rc = (float)sc->GetRenderCostDecrease() / (mInitialRenderCost - mHierarchyStats.mTotalCost + 1.0f); 
     921                float mc = (float)sc->GetPvsEntriesIncr() / (float)mHierarchyStats.mPvsEntries;  
     922 
     923                //cout << "dRc: " << sc->GetRenderCostDecrease() << " dMem: " << sc->GetPvsEntriesIncr() << " ratio1 " << rc << " ratio2 " << mc << " const: " << 1.0f - GetMemoryConst() << endl; 
    915924 
    916925                // minimum slope reached 
     
    15051514 
    15061515 
    1507 void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects, const bool removeRayRefs) const 
     1516void HierarchyManager::FinishObjectSpaceSubdivision(const ObjectContainer &objects,  
     1517                                                                                                        const bool removeRayRefs) const 
    15081518{ 
    15091519        switch (mObjectSpaceSubdivisionType) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1677 r1679  
    544544        bool mConsiderMemory2; 
    545545 
     546        int mTimeStamp; 
    546547        friend VspTree; 
    547548        friend OspTree; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1667 r1679  
    238238        /// parent view cell in the view cell hierarchy 
    239239        ViewCellInterior *mParent; 
    240          
    241240        /// the potentially visible objects 
    242241        ObjectPvs mPvs; 
    243          
    244242        /// the volume of this view cell 
    245243        float mVolume; 
    246          
    247244        /// the area of this view cell 
    248245        float mArea; 
    249  
    250246        /// the cost that were paid for merging this view cells from two others. 
    251247        float mMergeCost; 
    252          
    253248        /// if the view cell is valid view space 
    254249        bool mValid; 
    255          
    256250        /// color used for consistent visualization 
    257251        RgbColor mColor; 
    258          
    259252        /// store pvs size, used for evaluation purpose when pvss are stored only in the leaves 
    260253        int mPvsSize; 
    261  
    262254        /** stores number of entries in pvs 
    263255            this variable has the same value as mPvsSize for object pvs,  
     
    265257        */ 
    266258        int mEntriesInPvs; 
    267  
    268259        /** if the pvs size scalar (+ entries into pvs) 
    269260                is up to date and corresponding to the real pvs size 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1676 r1679  
    615615        { 
    616616                //vm->ResetViewCells(); 
    617 //hack 
    618 vm->mViewCells.clear(); 
    619                         ViewCellContainer leaves; 
    620         vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 
    621  
    622         ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    623  
    624         for (it = leaves.begin(); it != it_end; ++ it) 
    625         { 
    626                 vm->mViewCells.push_back(*it); 
    627         } 
     617                //hack 
     618                vm->mViewCells.clear(); 
     619                ViewCellContainer leaves; 
     620                vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 
     621 
     622                ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     623 
     624                for (it = leaves.begin(); it != it_end; ++ it) 
     625                { 
     626                        vm->mViewCells.push_back(*it); 
     627                } 
    628628                vm->mViewCellsFinished = true; 
    629629                vm->mMaxPvsSize = (int)objects->size(); 
     
    856856 
    857857 
     858void ViewCellsManager::ExportStats(const string &fileName) 
     859{ 
     860        mViewCellsTree->ExportStats(fileName); 
     861} 
     862 
     863 
    858864void ViewCellsManager::EvalViewCellPartition() 
    859865{ 
     
    949955                string fileName = string(statsPrefix) + string(str); 
    950956 
    951                 mViewCellsTree->ExportStats(fileName); 
     957                ExportStats(fileName); 
    952958 
    953959                timeDiff = TimeDiff(startTime, GetTime()); 
     
    22852291  //Vector3 center = viewCell->GetBox().Center(); 
    22862292  //  Vector3 center = m->mBox.Center(); 
    2287    
    2288   //  AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 
    2289   //                                      center + Vector3(viewSpaceFilterSize/2)); 
     2293 
     2294        //  AxisAlignedBox3 box(center - Vector3(viewSpaceFilterSize/2), 
     2295        //                                        center + Vector3(viewSpaceFilterSize/2)); 
    22902296        if (!ViewCellsConstructed()) 
    22912297                return; 
    22922298 
    2293         if (viewSpaceFilterSize >= 0.0f) { 
    2294  
    2295   const bool usePrVS = false; 
    2296  
    2297   if (!usePrVS) { 
    2298         AxisAlignedBox3 box = GetViewCellBox(viewCell); 
    2299         box.Enlarge(Vector3(viewSpaceFilterSize/2)); 
    2300          
    2301         ViewCellContainer viewCells; 
    2302         ComputeBoxIntersections(box, viewCells); 
    2303          
    2304   //  cout<<"box="<<box<<endl; 
    2305         ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
    2306          
    2307         int i; 
    2308         for (i=0; it != it_end; ++ it, ++ i) { 
    2309                 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
    2310           pvs.Merge((*it)->GetPvs()); 
    2311         } 
    2312   } else { 
    2313         PrVs prvs; 
    2314         AxisAlignedBox3 box = GetViewCellBox(viewCell); 
    2315  
    2316         //  mViewCellsManager->SetMaxFilterSize(1); 
    2317         GetPrVS(box.Center(), prvs, viewSpaceFilterSize); 
    2318         pvs = prvs.mViewCell->GetPvs(); 
    2319         DeleteLocalMergeTree(prvs.mViewCell); 
    2320   } 
    2321   } else 
    2322         pvs = viewCell->GetPvs(); 
    2323     
    2324   if (spatialFilterSize >=0.0f) 
    2325         ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 
    2326    
     2299        if (viewSpaceFilterSize >= 0.0f) { 
     2300 
     2301                const bool usePrVS = false; 
     2302 
     2303                if (!usePrVS) { 
     2304                        AxisAlignedBox3 box = GetViewCellBox(viewCell); 
     2305                        box.Enlarge(Vector3(viewSpaceFilterSize/2)); 
     2306 
     2307                        ViewCellContainer viewCells; 
     2308                        ComputeBoxIntersections(box, viewCells); 
     2309 
     2310                        //  cout<<"box="<<box<<endl; 
     2311                        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
     2312 
     2313                        int i; 
     2314                        for (i=0; it != it_end; ++ it, ++ i) { 
     2315                                //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
     2316                                pvs.Merge((*it)->GetPvs()); 
     2317                        } 
     2318                } else { 
     2319                        PrVs prvs; 
     2320                        AxisAlignedBox3 box = GetViewCellBox(viewCell); 
     2321 
     2322                        //  mViewCellsManager->SetMaxFilterSize(1); 
     2323                        GetPrVS(box.Center(), prvs, viewSpaceFilterSize); 
     2324                        pvs = prvs.mViewCell->GetPvs(); 
     2325                        DeleteLocalMergeTree(prvs.mViewCell); 
     2326                } 
     2327        } else 
     2328                pvs = viewCell->GetPvs(); 
     2329 
     2330        if (spatialFilterSize >=0.0f) 
     2331                ApplySpatialFilter(kdTree, spatialFilterSize, pvs); 
     2332 
    23272333} 
    23282334 
     
    23392345                return; 
    23402346 
    2341   ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    2342  
    2343   ObjectPvs *newPvs; 
    2344   newPvs = new ObjectPvs[mViewCells.size()]; 
    2345  
    2346   float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 
    2347   float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 
    2348    
    2349   int i; 
    2350   for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
    2351         ApplyFilter(*it, 
    2352                                 kdTree, 
    2353                                 viewSpaceFilterSize, 
    2354                                 spatialFilterSize, 
    2355                                 newPvs[i] 
    2356                                 ); 
    2357   } 
    2358  
    2359   // now replace all pvss 
    2360   for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
    2361              
    2362         ObjectPvs &pvs = (*it)->GetPvs(); 
    2363         pvs.Clear(); 
    2364         pvs = newPvs[i]; 
    2365         newPvs[i].Clear(); 
    2366   } 
    2367    
    2368   delete [] newPvs; 
    2369 } 
    2370  
    2371  
     2347        ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
     2348 
     2349        ObjectPvs *newPvs; 
     2350        newPvs = new ObjectPvs[mViewCells.size()]; 
     2351 
     2352        float viewSpaceFilterSize = Magnitude(mViewSpaceBox.Size())*relViewSpaceFilterSize; 
     2353        float spatialFilterSize = Magnitude(kdTree->GetBox().Size())*relSpatialFilterSize; 
     2354 
     2355        int i; 
     2356        for (i=0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
     2357                ApplyFilter(*it, 
     2358                        kdTree, 
     2359                        viewSpaceFilterSize, 
     2360                        spatialFilterSize, 
     2361                        newPvs[i] 
     2362                        ); 
     2363        } 
     2364 
     2365        // now replace all pvss 
     2366        for (i = 0, it = mViewCells.begin(); it != it_end; ++ it, ++ i) { 
     2367 
     2368                ObjectPvs &pvs = (*it)->GetPvs(); 
     2369                pvs.Clear(); 
     2370                pvs = newPvs[i]; 
     2371                newPvs[i].Clear(); 
     2372        } 
     2373 
     2374        delete [] newPvs; 
     2375} 
    23722376 
    23732377 
     
    23792383                                                                         ) 
    23802384{ 
    2381   // now compute a new Pvs by including also objects intersecting the  
    2382   // extended boxes of visible objects 
    2383   Intersectable::NewMail(); 
    2384    
    2385  ObjectPvsMap::const_iterator oi; 
    2386    
     2385        // now compute a new Pvs by including also objects intersecting the  
     2386        // extended boxes of visible objects 
     2387        Intersectable::NewMail(); 
     2388 
     2389        ObjectPvsMap::const_iterator oi; 
     2390 
    23872391  for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++ oi)  
    23882392  { 
     
    56195623 
    56205624typedef priority_queue<BvhNode *, vector<BvhNode *>,  
    5621                                            myless<vector<BvhNode *>::value_type> > ObjectsQueue; 
    5622  
     5625                                           myless<vector<BvhNode *>::value_type> > BvhQueue; 
     5626 
     5627typedef priority_queue<VspNode *, vector<VspNode *>,  
     5628                                           myless<vector<VspNode *>::value_type> > VspQueue; 
     5629 
     5630static void UpdateStats(ofstream &stats, 
     5631                                                const int splits, 
     5632                                                const float totalRenderCost, 
     5633                                                const int entriesInPvs, 
     5634                                                const float memoryCost, 
     5635                                                const bool vsp) 
     5636{ 
     5637        stats << "#Pass\n" << 0 << endl 
     5638                   << "#Splits\n" << splits << endl  
     5639                   << "#TotalRenderCost\n" << totalRenderCost << endl 
     5640                   << "#TotalEntriesInPvs\n" << entriesInPvs << endl 
     5641                   << "#Memory\n" << memoryCost << endl 
     5642                   << "#Vsp\n" << (vsp ? 1 : 0) << endl 
     5643                   << endl; 
     5644} 
     5645 
     5646/* 
    56235647void VspOspViewCellsManager::ExportStats(const string &mergeStats) 
    56245648{ 
     
    56265650        stats.open(mergeStats.c_str()); 
    56275651 
    5628         ObjectsQueue objectsQueue; 
    5629         ViewCellsQueue viewCellsQueue; 
    5630  
    5631         objectsQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 
    5632         viewCellsQueue.push(mViewCellsTree->GetRoot()); 
    5633          
    5634         int numViewCells = 1; 
     5652        BvhQueue bvhQueue; 
     5653        VspQueue vspQueue; 
     5654        //ViewCellsQueue viewCellsQueue; 
     5655 
     5656        bvhQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 
     5657        vspQueue.push(mHierarchyManager->GetVspTree()->GetRoot()); 
     5658         
     5659        int numSteps = 1; 
    56355660         
    56365661        const AxisAlignedBox3 box = mViewSpaceBox; 
    56375662        const float vol = box.GetVolume(); 
    56385663 
    5639         const int rootPvs = mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 
    5640         const int rootEntries = mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 
    5641  
    5642         cout << "exporting stats ... " << endl; 
    5643          
    5644         float totalRenderCost, avgRenderCost, expectedCost; 
    5645  
    5646         float deviation = 0; 
    5647         int totalPvs = rootPvs; 
    5648         int entriesInPvs = rootEntries; 
    5649  
    5650         totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 
    5651  
     5664        float totalRenderCost = (float)mPreprocessor->mObjects.size();//(float)mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 
     5665        int entriesInPvs = 1;//mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 
     5666 
     5667        cout << "exporting vsposp stats ... " << endl; 
    56525668        const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize(); 
    56535669 
    56545670        ///////////// 
    56555671        //-- first view cell 
    5656  
    5657 /*      mViewCellsTree->UpdateStats(stats,       
    5658                                                                 0,  
    5659                                                                 numViewCells,  
    5660                                                                 0,  
    5661                                                                 totalRenderCost,  
    5662                                                                 rootPvs,  
    5663                                                                 expectedCost,  
    5664                                                                 avgRenderCost,  
    5665                                                                 deviation, 
    5666                                                                 totalPvs,  
    5667                                                                 entriesInPvs, 
    5668                                                                 memoryCost, 
    5669                                                                 0,  
    5670                                                                 mRoot->GetVolume()); 
    5671 */               
     5672        UpdateStats(stats, 2, totalRenderCost, entriesInPvs, memoryCost, true); 
    56725673 
    56735674        //-- go through tree in the order of render cost decrease 
     
    56755676        //-- or the reverse order of subdivision for subdivision-only  
    56765677        //-- view cell hierarchies. 
    5677  
    5678         while (!(objectsQueue.empty() && viewCellsQueue.empty())) 
    5679         { 
    5680                 ViewCell *viewCell = viewCellsQueue.top(); 
    5681                 BvhNode *bvhNode =  objectsQueue.top(); 
    5682  
    5683                 if (viewCell->GetMergeCost() < bvhNode->GetMergeCost()) 
    5684                 { 
    5685                         viewCellsQueue.pop(); 
    5686 /* 
    5687                         if (!vc->IsLeaf())  
     5678        int i = 0; 
     5679        while (!(bvhQueue.empty() && vspQueue.empty())) 
     5680        { 
     5681                const float vspCost = !vspQueue.empty() ? vspQueue.top()->GetMergeCost() : -99999999.0; 
     5682                const float ospCost = !bvhQueue.empty() ? bvhQueue.top()->GetMergeCost() : -99999999.0; 
     5683 
     5684                if (vspCost > ospCost) 
     5685                { 
     5686                        cout << "vsp: " << (int)-vspCost << endl; 
     5687                        cout << "v"; 
     5688                        VspNode *vspNode = vspQueue.top(); 
     5689 
     5690                        if (!vspNode) 
     5691                        { 
     5692                                cerr << "big error!" << endl; 
     5693                                break; 
     5694                        } 
     5695                        vspQueue.pop(); 
     5696 
     5697                        if (!vspNode->IsLeaf())  
    56885698                        {        
    5689                                 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    5690  
    5691                                 const int parentPvs = GetPvsSize(interior); 
    5692                                 const int parentPvsEntries = GetPvsEntries(interior); 
    5693                                 const float parentCost = (float)parentPvs * interior->GetVolume(); 
    5694  
    5695                                 float childCost = 0; 
    5696                                 int childPvs = 0; 
    5697                                 int childPvsEntries = 0; 
    5698  
    5699                                 -- numViewCells; 
    5700  
    5701                                 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
    5702  
    5703                                 for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    5704                                 { 
    5705                                         ViewCell *vc = *it; 
    5706  
    5707                                         const int pvsSize = GetPvsSize(vc); 
    5708                                         const int pvsEntries = GetPvsEntries(vc); 
    5709          
    5710                                         childCost += (float) pvsSize * vc->GetVolume(); 
    5711                                         childPvs += pvsSize; 
    5712                                         childPvsEntries += pvsEntries; 
    5713  
    5714                                         tqueue.push(vc); 
    5715                                         ++ numViewCells; 
    5716                                 } 
    5717  
    5718                                 // update stats for this view cell 
    5719                                 const float costDecr = (parentCost - childCost) / vol; 
    5720  
    5721                                 totalRenderCost -= costDecr; 
    5722                                 totalPvs += childPvs - parentPvs; 
    5723                                 entriesInPvs += childPvsEntries - parentPvsEntries; 
    5724  
    5725                                 expectedCost = totalRenderCost / (float)numViewCells; 
    5726                                 avgRenderCost = (float)totalPvs / (float)numViewCells; 
    5727  
    5728                                 const float memoryCost = (float)entriesInPvs *  
    5729                                         (float)ObjectPvs::GetEntrySize(); 
    5730  
    5731                                 mViewCellsTree->UpdateStats(stats, 
    5732                                                                                         0,  
    5733                                                                                         numViewCells,  
    5734                                                                                         costDecr,  
    5735                                                                                         totalRenderCost, 
    5736                                                                                         parentPvs,  
    5737                                                                                         expectedCost,  
    5738                                                                                         avgRenderCost,  
    5739                                                                                         deviation, 
    5740                                                                                         totalPvs,  
    5741                                                                                         entriesInPvs,  
    5742                                                                                         memoryCost, 
    5743                                                                                         childPvs - parentPvs, 
    5744                                                                                         vc->GetVolume()); 
    5745                                 */ 
     5699                                totalRenderCost -= vspNode->mRenderCostDecr; 
     5700                                entriesInPvs += vspNode->mPvsEntriesIncr;                
     5701 
     5702                                i ++; 
     5703 
     5704                                const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize();         
     5705                                UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, true); 
     5706 
     5707                                VspNode *front = dynamic_cast<VspInterior *>(vspNode)->GetFront(); 
     5708                                VspNode *back= dynamic_cast<VspInterior *>(vspNode)->GetBack(); 
     5709 
     5710                                if (!front->IsLeaf()) 
     5711                                        vspQueue.push(front); 
     5712                                if (!back->IsLeaf()) 
     5713                                        vspQueue.push(back); 
    57465714                        } 
    5747                         else // object space split 
     5715                } 
     5716                else // object space split 
     5717                { 
     5718                        cout << "o"; 
     5719                        BvhNode *bvhNode = bvhQueue.top(); 
     5720                        cout << "bvh: " << (int)-ospCost << endl; 
     5721                        if (!bvhNode) 
    57485722                        { 
     5723                                cerr << "big error!" << endl; 
     5724                                break; 
    57495725                        } 
     5726                        bvhQueue.pop(); 
     5727 
     5728                        if (!bvhNode->IsLeaf())  
     5729                        {        
     5730                                totalRenderCost -= bvhNode->mRenderCostDecr; 
     5731                                entriesInPvs += bvhNode->mPvsEntriesIncr;                
     5732 
     5733                                i ++; 
     5734                                const float memoryCost = (float)entriesInPvs * (float)ObjectPvs::GetEntrySize();         
     5735                                UpdateStats(stats, i, totalRenderCost, entriesInPvs, memoryCost, false); 
     5736                                 
     5737                                BvhNode *front = dynamic_cast<BvhInterior *>(bvhNode)->GetFront(); 
     5738                                BvhNode *back= dynamic_cast<BvhInterior *>(bvhNode)->GetBack(); 
     5739 
     5740                                if (!front->IsLeaf()) 
     5741                                        bvhQueue.push(front); 
     5742                                if (!back->IsLeaf()) 
     5743                                        bvhQueue.push(back); 
     5744                        } 
     5745                } 
     5746                cout << i << endl; 
     5747                         
    57505748        } 
    57515749 
    57525750        stats.close(); 
    57535751} 
    5754  
     5752*/ 
    57555753 
    57565754#if TEST_EVALUATION 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1676 r1679  
    634634        void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 
    635635 
     636        virtual void ExportStats(const string &mergeStats); 
    636637 
    637638   
     
    11321133        void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays); 
    11331134 
    1134         void ExportStats(const string &mergeStats); 
     1135        //void ExportStats(const string &mergeStats); 
    11351136 
    11361137        ///////////////////////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1673 r1679  
    179179 
    180180VspNode::VspNode():  
    181 mParent(NULL), mTreeValid(true), mTimeStamp(0) 
     181mParent(NULL),  
     182mTreeValid(true),  
     183mTimeStamp(0),  
     184mRenderCostDecr(0),  
     185mMemoryIncr(0), 
     186mPvsEntriesIncr(0) 
    182187{} 
    183188 
    184189 
    185190VspNode::VspNode(VspInterior *parent):  
    186 mParent(parent), mTreeValid(true) 
     191mParent(parent),  
     192mTreeValid(true),  
     193mMemoryIncr(0), 
     194mPvsEntriesIncr(0), 
     195mTimeStamp(0) 
    187196{} 
    188197 
     
    334343 
    335344 
    336 VspLeaf::VspLeaf(): mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 
     345VspLeaf::VspLeaf():  
     346mViewCell(NULL), mPvs(NULL), mSubdivisionCandidate(NULL) 
    337347{ 
    338348} 
     
    711721                tBackData.mMaxCostMisses = maxCostMisses; 
    712722                         
     723                newNode->mRenderCostDecr = sc->GetRenderCostDecrease(); 
     724                newNode->mPvsEntriesIncr = sc->GetPvsEntriesIncr(); 
     725 
    713726                mTotalCost -= sc->GetRenderCostDecrease(); 
    714727                mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 
     
    966979 
    967980        // set the time stamp so the order of traversal can be reconstructed 
    968         interior->mTimeStamp = mTimeStamp ++; 
    969          
     981        interior->mTimeStamp = mHierarchyManager->mTimeStamp ++; 
     982        cout << "here6 " << interior->mTimeStamp << endl; 
    970983        return interior; 
    971984} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1677 r1679  
    147147public: 
    148148         
    149         // types of vsp nodes 
     149        /// types of vsp nodes 
    150150        enum {Interior, Leaf}; 
    151151 
     
    165165        */ 
    166166        virtual bool IsRoot() const; 
     167         
    167168        /** Returns parent node. 
    168169        */ 
    169170        VspInterior *GetParent(); 
     171         
    170172        /** Sets parent node. 
    171173        */ 
    172174        void SetParent(VspInterior *parent); 
     175 
    173176        /** Returns true if this node is a sibling of node n. 
    174177        */ 
    175178        bool IsSibling(VspNode *n) const; 
     179         
    176180        /** returns depth of the node. 
    177181        */ 
    178182        int GetDepth() const; 
     183         
    179184        /** returns true if the whole subtree is valid 
    180185        */ 
     
    182187 
    183188        void SetTreeValid(const bool v); 
    184  
     189         
     190        /** Cost of mergin this node. 
     191        */ 
     192        float GetMergeCost() {return (float)-mTimeStamp; } 
     193 
     194        ///////// 
    185195        //-- mailing options 
    186196 
     
    195205        int mTimeStamp; 
    196206 
     207        int mPvsEntriesIncr; 
     208        float mMemoryIncr; 
     209        float mRenderCostDecr; 
     210 
    197211protected: 
    198212 
    199213        /// if this sub tree is a completely valid view space region 
    200214        bool mTreeValid; 
     215         
    201216        /// parent of this node 
    202217        VspInterior *mParent; 
     
    209224{ 
    210225public: 
     226 
    211227        /** Standard contructor taking split plane as argument. 
    212228        */ 
     
    214230 
    215231        ~VspInterior(); 
     232         
    216233        /** @return false since it is an interior node  
    217234        */ 
     
    315332        /// Rays piercing this leaf. 
    316333        VssRayContainer mVssRays; 
     334         
    317335        /// leaf pvs 
    318336        ObjectPvs *mPvs; 
     337 
    319338        /// Probability that the view point lies in this leaf 
    320339        float mProbability; 
     
    324343        /// pointer to a split plane candidate splitting this leaf 
    325344        SubdivisionCandidate *mSubdivisionCandidate; 
     345         
    326346        /// if NULL this does not correspond to feasible viewcell 
    327347        ViewCellLeaf *mViewCell; 
     
    492512                        if (hm->ConsiderMemory()) 
    493513                        { 
    494                                 //const float rc = mRenderCostDecrease / hm->GetHierarchyStats().mTotalCost; 
    495                                 const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 
     514                                const float rc = mRenderCostDecrease / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 
    496515                                //const float mc = mMemoryIncr /  / hm->GetHierarchyStats().mMemory; 
     516                                //const float rc = mPriority / (hm->mInitialRenderCost - hm->GetHierarchyStats().mTotalCost + 1.0f); 
    497517                                const float mc = (float)mPvsEntriesIncr / (float)hm->GetHierarchyStats().mPvsEntries;    
    498                         cout << "vsp rc: " << rc << " mc: " << mc << endl; 
     518                                 
     519                                //cout << "\np: " << mPriority << " i: " << hm->mInitialRenderCost << " t: " << hm->GetHierarchyStats().mTotalCost << endl; 
     520                                //cout << "vsp rc: " << rc << " mc: " << mc << endl; 
     521                                 
    499522                                return hm->GetMemoryConst() * rc - (1.0f - hm->GetMemoryConst()) * mc; 
    500523                        } 
Note: See TracChangeset for help on using the changeset viewer.