Changeset 1787 for GTP/trunk/Lib


Ignore:
Timestamp:
11/24/06 12:05:28 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

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

    r1786 r1787  
    21592159         
    21602160        if (mApplyInitialPartition) 
    2161         {cout << "here29"<<endl; 
     2161        { 
    21622162                ApplyInitialSubdivision(oSubdivisionCandidate, tQueue);          
    21632163        } 
     
    25172517        tempQueue.Push(firstCandidate); 
    25182518        while (!tempQueue.Empty()) 
    2519         {cout << "here2"<<endl; 
     2519        { 
    25202520                SubdivisionCandidate *candidate = tempQueue.Top(); 
    25212521                tempQueue.Pop(); 
     
    25292529                if (!InitialTerminationCriteriaMet(bsc->mParentData)) 
    25302530                { 
    2531                         cout << "here12"<<endl; 
    25322531                        cout << "here9"<<bsc->mParentData.mNode->mObjects.size()<<endl; 
    25332532                        BvhNode *node = Subdivide(tempQueue, bsc, globalCriteriaMet); 
     
    25552554 
    25562555        ObjectContainer::const_iterator oit, oit_end = objects->end(); 
    2557     cout<<"here104"<<endl; 
    2558         for (oit = objects->begin(); oit != objects->end(); ++ oit) 
    2559         { 
    2560                 //cout << (*oit)->GetBox().SurfaceArea() << " "; 
    2561         } 
     2556    
     2557        /*for (oit = objects->begin(); oit != objects->end(); ++ oit) 
     2558        { 
     2559                cout << (*oit)->GetBox().SurfaceArea() << " "; 
     2560        }*/ 
    25622561 
    25632562        float maxAreaDiff = -1.0f; 
     
    25662565 
    25672566    for (oit = objects->begin(); oit != (objects->end() - 1); ++ oit) 
    2568         {//cout << "h"; 
     2567        { 
    25692568                Intersectable *objS = *oit; 
    25702569                Intersectable *objL = *(oit + 1); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1786 r1787  
    18131813 
    18141814 
    1815 // TODO matt: implement this function for different storing methods 
    1816 void HierarchyManager::GetPvsIncrementally(ViewCell *vc, ObjectPvs &pvs) const 
     1815void HierarchyManager::GetPvsEfficiently(ViewCell *viewCell, ObjectPvs &pvs) const 
    18171816{ 
    18181817        //////////////// 
     
    18211820        // add pvs from leaves 
    18221821        stack<ViewCell *> tstack; 
    1823         tstack.push(vc); 
     1822        tstack.push(viewCell); 
     1823 
     1824        Intersectable::NewMail(); 
    18241825 
    18251826        while (!tstack.empty()) 
    18261827        { 
    1827                 vc = tstack.top(); 
     1828                ViewCell *vc = tstack.top(); 
    18281829                tstack.pop(); 
    18291830         
     
    18311832                if (!vc->GetPvs().Empty()) 
    18321833                { 
    1833                         if (vc->IsLeaf()) cout << " l " << pvs.GetSize(); 
    1834                         else cout << " i " << pvs.GetSize(); 
    1835                         pvs.MergeInPlace(vc->GetPvs()); 
     1834                        ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 
     1835 
     1836                        while (pit.HasMoreEntries()) 
     1837                        {                
     1838                                const ObjectPvsEntry &entry = pit.Next(); 
     1839 
     1840                                Intersectable *object = entry.mObject; 
     1841                                if (!object->Mailed()) 
     1842                                { 
     1843                                        object->Mail(); 
     1844                                        pvs.AddSampleDirty(object, 1.0f); 
     1845                                } 
     1846                        } 
    18361847                } 
    18371848                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
    18381849                { 
    1839                         cout <<" t"; 
    18401850                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
    18411851                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     
    18461856                        }                
    18471857                } 
     1858        } 
     1859} 
     1860 
     1861 
     1862// TODO matt: implement this function for different storing methods 
     1863void HierarchyManager::GetPvsIncrementially(ViewCell *vc, ObjectPvs &pvs) const 
     1864{ 
     1865        //////////////// 
     1866        //-- pvs is not stored with the interiors => reconstruct 
     1867         
     1868        // add pvs from leaves 
     1869        stack<ViewCell *> tstack; 
     1870        tstack.push(vc); 
     1871 
     1872        while (!tstack.empty()) 
     1873        { 
     1874                vc = tstack.top(); 
     1875                tstack.pop(); 
     1876         
     1877                // add newly found pvs to merged pvs: break here even for interior 
     1878                if (!vc->GetPvs().Empty()) 
     1879                { 
     1880                        //if (vc->IsLeaf()) cout << " l " << pvs.GetSize(); 
     1881                        //else cout << " i " << pvs.GetSize(); 
     1882                        pvs.MergeInPlace(vc->GetPvs()); 
     1883                } 
     1884                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
     1885                { 
     1886                        //cout <<" t"; 
     1887                        ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     1888                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     1889 
     1890                        for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     1891                        { 
     1892                                tstack.push(*it); 
     1893                        }                
     1894                } 
    18481895                else cout <<"k"; 
    18491896        } 
     
    18751922                if (!vc->GetPvs().Empty()) 
    18761923                { 
    1877                         /*if (vc->IsLeaf())  
    1878                                 cout << " l " << viewCell->GetPvs().GetSize(); 
    1879                         else cout << " i " << viewCell->GetPvs().GetSize(); 
    1880                         */ 
    1881                                 viewCell->GetPvs().MergeInPlace(vc->GetPvs()); 
     1924                        viewCell->GetPvs().MergeInPlace(vc->GetPvs()); 
    18821925                } 
    18831926                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
     
    19632006        ViewCell::NewMail(); 
    19642007 
    1965         cout << "\n**************viewcells: " << viewCells.size() << endl; 
     2008        //cout << "\nviewcells: " << viewCells.size() << endl; 
    19662009        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    19672010        { 
    19682011                ViewCell *vc = *vit; 
    1969  
    1970                 //cout << "\nhere5: "; 
    19712012                float rc = 0; 
    19722013         
    19732014#if STUPID_METHOD        
    19742015                ObjectPvs pvs; 
    1975                 GetPvsIncrementally(vc, pvs); 
     2016                GetPvsIncrementially(vc, pvs); 
    19762017                vc->SetPvs(pvs); 
     2018                 
    19772019#else 
    1978                 //PullUpPvsIncrementally(vc); 
     2020         
    19792021                ObjectPvs pvs; 
    1980                 GetPvsRecursive(vc, pvs); 
    1981                 vc->SetPvs(pvs); 
     2022                //GetPvsRecursive(vc, pvs); 
     2023                 
     2024                // uses mailing 
     2025                // warning: pvs not sorted!! 
     2026                if (vc->GetPvs().Empty()) 
     2027                { 
     2028                        GetPvsEfficiently(vc, pvs); 
     2029                        vc->SetPvs(pvs); 
     2030                        //cout << "q"; 
     2031                } 
     2032                //else cout << "t"; 
    19822033#endif 
    19832034 
     
    19912042                        const long endT = GetTime(); 
    19922043 
    1993                         cout << "filter computed in " << TimeDiff(startT, endT) * 1e-3f << " secs" << endl; 
     2044                        //cout << "filter computed in " << TimeDiff(startT, endT) * 1e-3f << " secs" << endl; 
    19942045                        ComputePvs(filteredPvs, rc, pvsEntries); 
    19952046                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1786 r1787  
    523523 
    524524        void ComputePvs(const ObjectPvs &pvs, float &rc, int &pvsEntries); 
    525         void GetPvsIncrementally(ViewCell *vc, ObjectPvs &pvs) const; 
     525        void GetPvsIncrementially(ViewCell *vc, ObjectPvs &pvs) const; 
    526526        void PullUpPvsIncrementally(ViewCell *viewCell) const; 
    527527        void GetPvsRecursive(ViewCell *vc, ObjectPvs &pvs) const; 
     528        void GetPvsEfficiently(ViewCell *vc, ObjectPvs &pvs) const; 
     529 
    528530protected: 
    529531 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1786 r1787  
    3232 
    3333// $$JB HACK 
    34 #define USE_KD_PVS 1 
     34#define USE_KD_PVS 0 
    3535#define KD_PVS_AREA (1e-5f) 
    3636 
     
    25912591 
    25922592 
    2593 void ViewCellsManager::MergeViewCellsEfficient(ObjectPvs &pvs, const ViewCellContainer &viewCells) const 
    2594 { 
    2595         LocalMergeTree mergeTree(viewCells); 
    2596         mergeTree.Merge(pvs); 
    2597 } 
     2593void ViewCellsManager::MergeViewCellsRecursivly(ObjectPvs &pvs,  
     2594                                                                                                const ViewCellContainer &viewCells) const 
     2595{ 
     2596        MergeViewCellsRecursivly(pvs, viewCells, 0, (int)viewCells.size() - 1); 
     2597} 
     2598 
     2599 
     2600void ViewCellsManager::MergeViewCellsRecursivly(ObjectPvs &pvs,  
     2601                                                                                                const ViewCellContainer &viewCells,  
     2602                                                                                                const int leftIdx,  
     2603                                                                                                const int rightIdx) const 
     2604{ 
     2605        if (leftIdx == rightIdx) 
     2606        { 
     2607                pvs = viewCells[leftIdx]->GetPvs(); 
     2608        } 
     2609        else 
     2610        { 
     2611                const int midSplit = (leftIdx + rightIdx) / 2; 
     2612         
     2613                ObjectPvs leftPvs, rightPvs; 
     2614                MergeViewCellsRecursivly(leftPvs, viewCells, leftIdx, midSplit); 
     2615                MergeViewCellsRecursivly(rightPvs, viewCells, midSplit, rightIdx); 
     2616 
     2617        ObjectPvs::Merge(pvs, leftPvs, rightPvs); 
     2618        } 
     2619} 
     2620 
    25982621 
    25992622#if 1 
     
    26052628                                                           ) 
    26062629{ 
     2630        cout<<"y"; 
    26072631  PvsFilterStatistics stats; 
    26082632 
     
    26292653  float samples = (float)basePvs.GetSamples(); 
    26302654   
    2631   Debug<<"f #s="<<samples<<"pvs size = "<<basePvs.GetSize(); 
     2655  Debug<<"f #s="<<samples<<"  pvs size = "<<basePvs.GetSize(); 
    26322656  //  cout<<"Filter size = "<<filterSize<<endl; 
    26332657  //  cout<<"vbox = "<<vbox<<endl; 
     
    27542778                                                           ObjectPvs &pvs 
    27552779                                                           ) 
    2756 {cout << "x"; 
    2757   PvsFilterStatistics stats; 
    2758  
    2759   AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 
    2760   Vector3 center = vbox.Center(); 
    2761   // copy the PVS 
    2762   ObjectPvs basePvs = viewCell->GetPvs(); 
    2763   Intersectable::NewMail(); 
    2764  
    2765   ObjectPvsIterator pit = basePvs.GetIterator(); 
     2780{ 
     2781        cout << "x"; 
     2782        PvsFilterStatistics stats; 
     2783 
     2784        AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 
     2785        Vector3 center = vbox.Center(); 
     2786        // copy the PVS 
     2787        ObjectPvs basePvs;// = viewCell->GetPvs(); 
     2788        Intersectable::NewMail(); 
     2789 
     2790        ObjectPvsIterator pit = viewCell->GetPvs().GetIterator(); 
    27662791 
    27672792#if !USE_KD_PVS 
    2768   // first mark all object from this pvs 
    2769   while (pit.HasMoreEntries()) {                 
    2770         ObjectPvsEntry entry = pit.Next(); 
    2771          
    2772         Intersectable *object = entry.mObject; 
    2773         object->Mail(); 
    2774   } 
     2793        // first mark all object from this pvs 
     2794        while (pit.HasMoreEntries())  
     2795        {                
     2796                ObjectPvsEntry entry = pit.Next(); 
     2797 
     2798                Intersectable *object = entry.mObject; 
     2799                object->Mail(); 
     2800        } 
    27752801#endif 
    27762802 
    2777   int pvsSize = 0; 
    2778   int nPvsSize = 0; 
    2779   float samples = (float)basePvs.GetSamples(); 
    2780    
    2781   Debug<<"f #s="<<samples<<"pvs size = "<<basePvs.GetSize(); 
    2782   //  cout<<"Filter size = "<<filterSize<<endl; 
    2783   //  cout<<"vbox = "<<vbox<<endl; 
    2784   //  cout<<"center = "<<center<<endl; 
    2785  
    2786  
    2787    // Minimal number of local samples to take into account 
    2788    // the local sampling density. 
    2789    // The size of the filter is a minimum of the conservative 
    2790    // local sampling density estimate (#rays intersecting teh viewcell and 
    2791    // the object) 
    2792    // and gobal estimate for the view cell 
    2793    // (total #rays intersecting the viewcell) 
     2803        int pvsSize = 0; 
     2804        int nPvsSize = 0; 
     2805        float samples = (float)viewCell->GetPvs().GetSamples(); 
     2806 
     2807        Debug<<"f #s="<<samples<<"pvs size = "<<viewCell->GetPvs().GetSize(); 
     2808        //  cout<<"Filter size = "<<filterSize<<endl; 
     2809        //  cout<<"vbox = "<<vbox<<endl; 
     2810        //  cout<<"center = "<<center<<endl; 
     2811 
     2812 
     2813        // Minimal number of local samples to take into account 
     2814        // the local sampling density. 
     2815        // The size of the filter is a minimum of the conservative 
     2816        // local sampling density estimate (#rays intersecting teh viewcell and 
     2817        // the object) 
     2818        // and gobal estimate for the view cell 
     2819        // (total #rays intersecting the viewcell) 
    27942820#define MIN_LOCAL_SAMPLES 5 
    27952821 
    2796   float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
    2797    
    2798   // now compute the filter box around the current viewCell 
    2799    
    2800   if (useViewSpaceFilter) { 
    2801         //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
    2802         float radius = viewCellRadius/100.0f; 
    2803         vbox.Enlarge(radius); 
    2804         cout<<"vbox = "<<vbox<<endl; 
    2805         ViewCellContainer viewCells; 
    2806         ComputeBoxIntersections(vbox, viewCells); 
    2807         ObjectPvs pvs; 
    2808         MergeViewCellsEfficient(pvs, viewCells); 
    2809         basePvs = pvs; 
    2810                  
    2811         // update samples and globalC 
    2812         samples = (float)pvs.GetSamples(); 
    2813         //      cout<<"neighboring viewcells = "<<i-1<<endl; 
    2814         //      cout<<"Samples' = "<<samples<<endl; 
    2815   } 
    2816  
    2817   // Minimal number of samples so that filtering takes place 
     2822        float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
     2823 
     2824        // now compute the filter box around the current viewCell 
     2825 
     2826        if (useViewSpaceFilter)  
     2827        { 
     2828                //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
     2829                float radius = viewCellRadius/100.0f; 
     2830                vbox.Enlarge(radius); 
     2831                cout<<"vbox = "<<vbox<<endl; 
     2832                ViewCellContainer viewCells; 
     2833                ComputeBoxIntersections(vbox, viewCells); 
     2834                 
     2835                MergeViewCellsEfficient(basePvs, viewCells); 
     2836                cout << "basepvs size " << basePvs.GetSize() << endl; 
     2837                // update samples and globalC 
     2838                samples = (float)pvs.GetSamples(); 
     2839                //      cout<<"neighboring viewcells = "<<i-1<<endl; 
     2840                //      cout<<"Samples' = "<<samples<<endl; 
     2841        } 
     2842        else 
     2843        { 
     2844                basePvs = viewCell->GetPvs(); 
     2845        } 
     2846 
     2847        // Minimal number of samples so that filtering takes place 
    28182848#define MIN_SAMPLES  100 
    2819   if (samples > MIN_SAMPLES) { 
    2820         float globalC = 2.0f*filterSize/sqrt(samples); 
    2821          
     2849        if (samples > MIN_SAMPLES)  
     2850        { 
     2851                float globalC = 2.0f*filterSize/sqrt(samples); 
     2852 
     2853                pit = basePvs.GetIterator(); 
     2854 
     2855                ObjectContainer objects; 
     2856 
     2857                while (pit.HasMoreEntries()) 
     2858                {                
     2859                        ObjectPvsEntry entry = pit.Next(); 
     2860 
     2861                        Intersectable *object = entry.mObject; 
     2862                        // compute filter size based on the distance and the numebr of samples 
     2863                        AxisAlignedBox3 box = object->GetBox(); 
     2864 
     2865                        float distance = Distance(center, box.Center()); 
     2866                        float globalRadius = distance*globalC; 
     2867 
     2868                        int objectSamples = (int)entry.mData.mSumPdf; 
     2869                        float localRadius = MAX_FLOAT; 
     2870 
     2871                        if (objectSamples > MIN_LOCAL_SAMPLES) 
     2872                        { 
     2873                                localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
     2874                                                                sqrt((float)objectSamples); 
     2875                        } 
     2876 
     2877                        //      cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
     2878 
     2879                        // now compute the filter size 
     2880                        float radius; 
     2881 
     2882                        if (localRadius < globalRadius)  
     2883                        { 
     2884                                radius = localRadius; 
     2885                                stats.mLocalFilterCount++; 
     2886                        }  
     2887                        else  
     2888                        { 
     2889                                radius = globalRadius; 
     2890                                stats.mGlobalFilterCount++; 
     2891                        } 
     2892 
     2893                        stats.mAvgFilterRadius += radius; 
     2894 
     2895                        // cout<<"box = "<<box<<endl; 
     2896                        //      cout<<"distance = "<<distance<<endl; 
     2897                        //      cout<<"radiues = "<<radius<<endl; 
     2898 
     2899                        box.Enlarge(Vector3(radius)); 
     2900                        objects.clear(); 
     2901 
     2902                        // $$ warning collect objects takes only unmailed ones! 
     2903                        CollectObjects(box, objects); 
     2904 
     2905                        //      cout<<"collected objects="<<objects.size()<<endl; 
     2906                        ObjectContainer::const_iterator noi = objects.begin(); 
     2907                        for (; noi != objects.end(); ++ noi)  
     2908                        { 
     2909                                Intersectable *o = *noi; 
     2910                                // $$ JB warning: pdfs are not correct at this point!      
     2911                                pvs.AddSampleDirty(o, Limits::Small); 
     2912                        } 
     2913                } 
     2914 
     2915                stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
     2916        } 
     2917 
     2918        Debug<<" nPvs size = "<<pvs.GetSize()<<endl; 
     2919 
     2920#if !USE_KD_PVS 
     2921        // copy the base pvs to the new pvs 
    28222922        pit = basePvs.GetIterator(); 
    2823          
    2824         ObjectContainer objects; 
    2825          
    2826         while (pit.HasMoreEntries()) 
    2827           {              
     2923        while (pit.HasMoreEntries())  
     2924        {                
    28282925                ObjectPvsEntry entry = pit.Next(); 
    2829                  
    2830                 Intersectable *object = entry.mObject; 
    2831                 // compute filter size based on the distance and the numebr of samples 
    2832                 AxisAlignedBox3 box = object->GetBox(); 
    2833                  
    2834                 float distance = Distance(center, box.Center()); 
    2835                 float globalRadius = distance*globalC; 
    2836                  
    2837                 int objectSamples = (int)entry.mData.mSumPdf; 
    2838                 float localRadius = MAX_FLOAT; 
    2839                 if (objectSamples > MIN_LOCAL_SAMPLES) 
    2840                   localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
    2841                         sqrt((float)objectSamples); 
    2842                  
    2843                 //      cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
    2844                  
    2845                 // now compute the filter size 
    2846                 float radius; 
    2847  
    2848                 if (localRadius < globalRadius) { 
    2849                   radius = localRadius; 
    2850                   stats.mLocalFilterCount++; 
    2851                 } else { 
    2852                   radius = globalRadius; 
    2853                   stats.mGlobalFilterCount++; 
    2854                 } 
    2855  
    2856                 stats.mAvgFilterRadius += radius; 
    2857                  
    2858                 // cout<<"box = "<<box<<endl; 
    2859                 //      cout<<"distance = "<<distance<<endl; 
    2860                 //      cout<<"radiues = "<<radius<<endl; 
    2861                  
    2862                 box.Enlarge(Vector3(radius)); 
    2863                  
    2864                 objects.clear(); 
    2865                 // $$ warning collect objects takes only unmailed ones! 
    2866                 CollectObjects(box, objects); 
    2867                 //      cout<<"collected objects="<<objects.size()<<endl; 
    2868                 ObjectContainer::const_iterator noi = objects.begin(); 
    2869                 for (; noi != objects.end(); ++ noi) { 
    2870                   Intersectable *o = *noi; 
    2871                   // $$ JB warning: pdfs are not correct at this point!    
    2872                   pvs.AddSampleDirty(o, Limits::Small); 
    2873                 } 
    2874           } 
    2875         stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 
    2876   } 
    2877    
    2878   Debug<<" nPvs size = "<<pvs.GetSize()<<endl; 
    2879  
    2880 #if !USE_KD_PVS 
    2881   // copy the base pvs to the new pvs 
    2882   pit = basePvs.GetIterator(); 
    2883   while (pit.HasMoreEntries()) {                 
    2884         ObjectPvsEntry entry = pit.Next(); 
    2885         pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
    2886   } 
     2926                pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
     2927        } 
    28872928#endif 
    2888   viewCell->SetFilteredPvsSize(pvs.GetSize()); 
    2889    
    2890   Intersectable::NewMail(); 
    2891   return stats; 
     2929        viewCell->SetFilteredPvsSize(pvs.GetSize()); 
     2930 
     2931        Intersectable::NewMail(); 
     2932         
     2933        return stats; 
    28922934} 
    28932935#endif 
    28942936 
    2895    
     2937 
    28962938 
    28972939void ViewCellsManager::ExportColor(Exporter *exporter,  
     
    62276269 
    62286270#if 0 
    6229                         //////////////////////////// 
     6271                        ////////////// 
    62306272                        // filtered stats 
    62316273                        sprintf(suffix, "-%09d-eval-filter.log", castSamples); 
     
    62426284                        cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    62436285                        cout << "*************************************" << endl; 
    6244  
    6245                         Debug << "statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 
     6286                        Debug << "filtered statistics computed in " << timeDiff * 1e-3 << " secs" << endl; 
    62466287#endif 
    62476288 
     
    62606301                                } 
    62616302 
    6262                                 cout << "debug entries: " << pvsSize << ", memcost: " << (float)pvsSize * ObjectPvs::GetEntrySize() << endl; 
     6303                                cout << "debug entries: " << pvsSize << ", memcost: "  
     6304                                         << (float)pvsSize * ObjectPvs::GetEntrySize() << endl; 
    62636305                        } 
    62646306                } 
     
    62716313 
    62726314 
    6273 LocalMergeTree::LocalMergeTree(const ViewCellContainer &viewCells): 
    6274 mViewCells(viewCells) 
    6275 { 
    6276         mRoot = Subdivide(0, (int)mViewCells.size()); 
    6277 } 
    6278  
    6279  
    6280 void LocalMergeTree::Merge(ObjectPvs &mergedPvs) 
    6281 { 
    6282         Merge(mRoot, mergedPvs); 
    6283 } 
    6284  
    6285  
    6286 void LocalMergeTree::Merge(LocalMergeNode *node, ObjectPvs &mergedPvs) 
    6287 { 
    6288         //////////////// 
    6289         //-- pvs is not stored with the interiors => reconstruct 
    6290         if (node->IsLeaf()) 
    6291         { 
    6292                 LocalMergeLeaf *leaf = dynamic_cast<LocalMergeLeaf *>(node); 
    6293         mergedPvs = leaf->mViewCell->GetPvs(); 
    6294         } 
    6295         else 
    6296         { 
    6297                 LocalMergeInterior *interior = dynamic_cast<LocalMergeInterior *>(node); 
    6298  
    6299                 ObjectPvs leftPvs, rightPvs; 
    6300  
    6301                 Merge(interior->mLeft, leftPvs); 
    6302                 Merge(interior->mRight, rightPvs); 
    6303  
    6304                 ObjectPvs::Merge(mergedPvs, leftPvs, rightPvs); 
    6305         }        
    6306 } 
    6307  
    6308  
    6309 LocalMergeNode *LocalMergeTree::Subdivide(const int leftIdx, const int rightIdx) 
    6310 { 
    6311         if (leftIdx == rightIdx) 
    6312         { 
    6313                 return new LocalMergeLeaf(mViewCells[leftIdx]); 
    6314         } 
    6315  
    6316         LocalMergeInterior *interior = new LocalMergeInterior(); 
    6317  
    6318         const int midSplit = (leftIdx + rightIdx) / 2; 
    6319  
    6320         interior->mLeft = Subdivide(leftIdx, midSplit); 
    6321         interior->mRight = Subdivide(midSplit,  rightIdx); 
    6322  
    6323         return interior; 
    6324 } 
    6325  
    6326  
    6327  
    6328 } 
     6315 
     6316} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1786 r1787  
    7575 
    7676 
    77 class LocalMergeLeaf: public LocalMergeNode 
    78 { 
    79 public: 
    80         LocalMergeLeaf(ViewCell *vc): mViewCell(vc) {}; 
    81         virtual ~LocalMergeLeaf() {}; 
    82         virtual bool IsLeaf() const { return true; } 
    83  
    84         ViewCell *mViewCell; 
    85 }; 
    86  
    87  
    88 class LocalMergeInterior: public LocalMergeNode 
    89 { 
    90 public: 
    91          
    92         virtual ~LocalMergeInterior() {DEL_PTR(mLeft); DEL_PTR(mRight);} 
    93         virtual bool IsLeaf() const { return false; } 
    94  
    95         LocalMergeNode *mLeft; 
    96         LocalMergeNode *mRight; 
    97 }; 
    98  
    99  
    100 class LocalMergeTree 
    101 { 
    102 public: 
    103  
    104         LocalMergeTree(const ViewCellContainer &viewCells); 
    105          
    106         void Merge(ObjectPvs &mergedPvs); 
    107  
    108 protected: 
    109  
    110         void Merge(LocalMergeNode *node, ObjectPvs &mergedPvs); 
    111         LocalMergeNode *Subdivide(const int leftIdx, const int rightIdx); 
    112  
    113         LocalMergeNode *mRoot; 
    114         const ViewCellContainer &mViewCells; 
    115 }; 
    116  
    117  
    11877/**     Manages different higher order operations on the view cells. 
    11978*/ 
     
    505464        /** Efficiently merges the view cells in the container. 
    506465        */ 
    507         void MergeViewCellsEfficient(ObjectPvs &pvs, const ViewCellContainer &viewCells) const; 
     466        void MergeViewCellsRecursivly(ObjectPvs &pvs,  
     467                                                                  const ViewCellContainer &viewCells) const; 
    508468 
    509469 
     
    606566 
    607567protected: 
     568 
     569        void MergeViewCellsRecursivly(ObjectPvs &pvs,  
     570                                                                  const ViewCellContainer &viewCells,  
     571                                                                  const int leftIdx,  
     572                                                                  const int rightIdx) const; 
    608573 
    609574        /** Intersects box with the tree and returns the number of intersected boxes. 
Note: See TracChangeset for help on using the changeset viewer.