Changeset 710 for GTP/trunk/Lib/Vis


Ignore:
Timestamp:
03/20/06 00:11:27 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
8 edited

Legend:

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

    r708 r710  
    560560                mMergeQueue.pop(); 
    561561         
    562                 // both view cells equal 
     562                // both view cells equal because of previous merges 
    563563                // NOTE: do I really still need this? probably cannot happen!! 
    564564                if (mc.mLeftViewCell == mc.mRightViewCell) 
     
    579579                        totalRenderCost += renderCostIncr; 
    580580                        mDeviation += mc.GetDeviationIncr(); 
    581                          
    582                          
    583                         // merge the view cells of leaf1 and leaf2 
     581 
     582                                                 
     583                        //-- merge the view cells of leaf1 and leaf2 
    584584                        int pvsDiff; 
    585585                        ViewCellInterior *mergedVc =  
    586586                                MergeViewCells(mc.mLeftViewCell, mc.mRightViewCell, pvsDiff); 
    587  
     587                         
    588588 
    589589                        // total render cost and deviation has changed 
     
    641641                 
    642642                ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 
     643         
     644                ViewCellContainer::const_iterator it, it_end = root->mChildren.end(); 
     645 
     646                for (it = root->mChildren.begin(); it != it_end; ++ it) 
     647                        (*it)->SetParent(root); 
     648         
    643649                root->SetMergeCost(totalRenderCost); 
    644650                // $$JB keep this 0 temporarilly 
     
    647653                mRoot = root; 
    648654        } 
    649         else if ((int)activeViewCells.size() == 1) 
     655        // normal case 
     656        else if (!activeViewCells.empty()) 
    650657        { 
    651658                Debug << "setting root of the merge history" << endl; 
    652659                mRoot = activeViewCells[0]; 
     660                Debug << "rootvc volume: " << mRoot->GetVolume() << endl; 
    653661        } 
    654662         
     
    742750 
    743751                // all merged view cells have been found 
    744                 if (i >= viewCells.size())  
     752                if (i >= (int)viewCells.size())  
    745753                        break; 
    746754 
    747                 // already merged view cell, put it to end of vector 
     755                // already merged this view cell, put it to end of vector 
    748756                if (viewCells[i]->GetParent()) 
    749757                        swap(viewCells[i], viewCells.back()); 
    750758                 
    751                 viewCells[i ++]->Mail(); 
     759                // mail view cell as it has not been merged 
     760                viewCells[i]->Mail(); 
     761 
     762                // increase loop counter 
     763                ++ i; 
    752764        } 
    753765 
     
    847859        if (!vc) return NULL; 
    848860 
     861        l->SetParent(vc); 
     862        r->SetParent(vc); 
     863 
    849864        // set new size of view cell 
    850865        if (mUseAreaForPvs) 
     866        { 
    851867                vc->SetArea(l->GetArea() + l->GetArea()); 
     868        } 
    852869        else 
    853870        { 
    854871                vc->SetVolume(r->GetVolume() + l->GetVolume()); 
    855872        } 
     873 
     874         
    856875        // important so other merge candidates sharing this view cell 
    857876        // are notified that the merge cost must be updated!! 
     
    957976        return shuffledViewCells; 
    958977} 
    959  
    960  
    961978 
    962979 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r704 r710  
    159159    mFront = f; 
    160160} 
     161 
    161162 
    162163/****************************************************************/ 
     
    588589} 
    589590 
     591 
    590592int BspTree::AddMeshToPolygons(Mesh *mesh,  
    591593                                                           PolygonContainer &polys,  
    592594                                                           MeshInstance *parent) 
    593595{ 
    594         FaceContainer::const_iterator fi; 
     596        FaceContainer::const_iterator fi, fi_end = mesh->mFaces.end(); 
    595597         
    596598        // copy the face data to polygons 
    597         for (fi = mesh->mFaces.begin(); fi != mesh->mFaces.end(); ++ fi) 
     599        for (fi = mesh->mFaces.begin(); fi != fi_end; ++ fi) 
    598600        { 
    599601                Polygon3 *poly = new Polygon3((*fi), mesh); 
     
    28392841{ 
    28402842        mPolys.reserve(rhs.mPolys.size()); 
    2841          
     2843        mPlanes.reserve(rhs.mPolys.size()); 
     2844 
     2845 
    28422846        PolygonContainer::const_iterator it, it_end = rhs.mPolys.end(); 
    28432847 
    28442848        int i = 0; 
    28452849 
    2846         for (it = rhs.mPolys.begin(); it != it_end; ++ it) 
     2850        for (it = rhs.mPolys.begin(); it != it_end; ++ it, ++i) 
    28472851        { 
    28482852                Polygon3 *poly = *it; 
    2849                 Add(new Polygon3(*poly), rhs.mPlanes[i ++]); 
     2853                Add(new Polygon3(*poly), rhs.mPlanes[i]); 
     2854        } 
     2855} 
     2856 
     2857 
     2858BspNodeGeometry& BspNodeGeometry::operator=(const BspNodeGeometry& g)  
     2859{ 
     2860    if (this == &g)  
     2861                return *this; 
     2862  
     2863        CLEAR_CONTAINER(mPolys); 
     2864 
     2865        mPolys.reserve(g.mPolys.size()); 
     2866        mPlanes.reserve(g.mPolys.size()); 
     2867 
     2868        PolygonContainer::const_iterator it, it_end = g.mPolys.end(); 
     2869 
     2870        int i = 0; 
     2871 
     2872        for (it = g.mPolys.begin(); it != it_end; ++ it, ++ i) 
     2873        { 
     2874                Polygon3 *poly = *it; 
     2875                Add(new Polygon3(*poly), g.mPlanes[i]); 
     2876        } 
     2877 
     2878        return *this; 
     2879} 
     2880 
     2881 
     2882BspNodeGeometry::BspNodeGeometry(const PolygonContainer &polys) 
     2883{ 
     2884        mPolys = polys; 
     2885        mPlanes.reserve(polys.size()); 
     2886         
     2887        PolygonContainer::const_iterator it, it_end = polys.end(); 
     2888 
     2889        for (it = polys.begin(); it != it_end; ++ it) 
     2890        { 
     2891                Polygon3 *poly = *it; 
     2892                mPlanes.push_back(poly->GetSupportingPlane()); 
    28502893        } 
    28512894} 
     
    29222965 
    29232966 
    2924 int BspNodeGeometry::Side(const Plane3 &plane) const 
     2967int BspNodeGeometry::Side(const Plane3 &plane, const float eps) const 
    29252968{ 
    29262969        PolygonContainer::const_iterator it, it_end = mPolys.end(); 
     
    29312974        for (it = mPolys.begin(); it != it_end; ++ it) 
    29322975        { 
    2933         const int side = (*it)->Side(plane, 0.0f); 
     2976        const int side = (*it)->Side(plane, eps); 
    29342977 
    29352978                if (side == -1) 
     
    30423085                                                                        const float epsilon) const 
    30433086{        
     3087#if 0 
     3088        // trivial cases 
     3089        const int cf = Side(splitPlane, epsilon); 
     3090 
     3091        if (cf == -1) 
     3092        { 
     3093                back = *this; 
     3094                return false; 
     3095        } 
     3096        else if (cf == 1) 
     3097        { 
     3098                front = *this; 
     3099                return false; 
     3100        } 
     3101#endif 
     3102 
    30443103        // get cross section of new polygon 
    30453104        Polygon3 *planePoly = box.CrossSection(splitPlane); 
    3046         //Vector3 ndummy = planePoly->GetSupportingPlane().mNormal; 
     3105         
    30473106        // split polygon with all other polygons 
    30483107        planePoly = SplitPolygon(planePoly, epsilon); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r697 r710  
    3030        {};   
    3131 
    32         // copy constructor copying the polygon array 
     32        /** copy constructor copying the polygon array. 
     33                The polygons are deeply copied. 
     34        */ 
    3335        BspNodeGeometry(const BspNodeGeometry &rhs); 
    34  
    35         //BspNodeGeometry(const PolygonContainer &polys); 
     36        /** This operator uses a deep copy to copy the polygons. 
     37        */ 
     38        BspNodeGeometry& operator=(const BspNodeGeometry& p); 
     39 
     40        /** Builds node geometry using this polygons.  
     41                @NOTE The polygons are NOT duplicated, only 
     42                a shallow copy is used. 
     43        */       
     44    BspNodeGeometry(const PolygonContainer &polys); 
    3645 
    3746        ~BspNodeGeometry(); 
     
    6776                -1 if geometry in back of plane 
    6877        */ 
    69         int Side(const Plane3 &plane) const; 
     78        int Side(const Plane3 &plane, const float eps = 0.0f) const; 
    7079 
    7180        /** Splits the polygon and returns the part of the polygon inside of the node geometry. 
     
    97106        const PolygonContainer &GetPolys(); 
    98107 
     108    /** Adds polygon and plane equation to this geometry. 
     109        */ 
    99110        void Add(Polygon3 *p, const Plane3 &plane); 
    100111 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r708 r710  
    1616#include "RssPreprocessor.h" 
    1717 
    18 #define SAMPLE_AFTER_SUBDIVISION 1 
     18#define SAMPLE_AFTER_SUBDIVISION 0 
    1919#define TEST_EMPTY_VIEW_CELLS 0 
    2020 
     
    6262        environment->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); 
    6363         
    64         bool emptyViewCells = false; 
    65         environment->GetBoolValue("ViewCells.pruneEmptyViewCells", emptyViewCells); 
    66         mMinPvsSize = emptyViewCells ? 1 : 0; 
     64        environment->GetBoolValue("ViewCells.pruneEmptyViewCells", mPruneEmptyViewCells); 
     65 
     66        // HACK 
     67        if (0) 
     68                mMinPvsSize = mPruneEmptyViewCells ? 1 : 0; 
     69        else 
     70                mMinPvsSize = 0; 
    6771 
    6872        environment->GetBoolValue("ViewCells.processOnlyValidViewCells", mOnlyValidViewCells); 
     
    8589        environment->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize); 
    8690        environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 
    87 //mSampleEmptyViewCells = true; 
     91 
    8892        char buf[100]; 
    8993        environment->GetStringValue("ViewCells.samplingType", buf); 
     
    112116 
    113117 
     118 
    114119        Debug << "***********View Cells options ****************" << endl; 
    115120        Debug << "color code: " << mColorCode << endl; 
     
    119124        Debug << "max pvs ratio: " << mMaxPvsRatio << endl; 
    120125         
    121         Debug << "prune empty view cells: " << emptyViewCells << endl; 
     126        Debug << "prune empty view cells: " << mPruneEmptyViewCells << endl; 
    122127         
    123128        Debug << "process only valid view cells: " << mOnlyValidViewCells << endl; 
     
    137142        Debug << "show visualization: " << mShowVisualization << endl; 
    138143        Debug << "filter width: " << mFilterWidth << endl; 
    139  
     144        Debug << "sample after subdivision: " << SAMPLE_AFTER_SUBDIVISION << endl; 
    140145        Debug << endl; 
    141146} 
     
    427432 
    428433        // needed to fix empty view cells 
    429     SetValidity(0, 99999999999); 
     434    //SetValidity(0, 99999999999); 
    430435 
    431436        if (mEvaluateViewCells) 
     
    618623{ 
    619624 
    620   if ((vc->GetPvs().GetSize() > maxPvsSize) || 
    621           (vc->GetPvs().GetSize() < minPvsSize)) 
    622         { 
    623           return false; 
    624         } 
    625  
    626   return true; 
    627 } 
    628  
     625        if ((vc->GetPvs().GetSize() > maxPvsSize) || 
     626                (vc->GetPvs().GetSize() < minPvsSize)) 
     627        { 
     628                return false; 
     629        } 
     630 
     631        return true; 
     632} 
     633 
     634 
     635bool ViewCellsManager::EqualToSpatialNode(ViewCell *viewCell) const  
     636{  
     637        return false; 
     638} 
     639 
     640int ViewCellsManager::ComputeBoxIntersections(const AxisAlignedBox3 &box,  
     641                                                                                          ViewCellContainer &viewCells) const 
     642{ 
     643        return 0; 
     644}; 
    629645 
    630646AxisAlignedBox3 ViewCellsManager::GetFilterBBox(const Vector3 &viewPoint,  
     
    944960        // generate parent view cell 
    945961        ViewCellInterior *vc = new ViewCellInterior();//GenerateViewCell(); 
    946          
     962 
    947963        vc->GetPvs() = left->GetPvs(); 
    948  
    949964        // merge pvs 
    950965        vc->GetPvs().Merge(right->GetPvs()); 
     
    961976        } 
    962977 
    963         vc->SetupChildLink(left); 
    964         vc->SetupChildLink(right); 
    965          
     978        // set only links to child (not from child to parent, maybe not wished!!) 
     979        vc->mChildren.push_back(left); 
     980        vc->mChildren.push_back(right); 
     981 
    966982        return vc; 
    967983} 
     
    978994                // merge pvs 
    979995                vc->GetPvs().Merge((*it)->GetPvs()); 
    980  
    981                 vc->SetupChildLink(*it); 
     996                vc->mChildren.push_back(*it); 
     997                //vc->SetupChildLink(*it); 
    982998        } 
    983999 
     
    29022918                                                                                                 const VssRayContainer &rays) 
    29032919{ 
     2920        mMaxPvsSize = (int)(mMaxPvsRatio * (float)objects.size()); 
     2921 
    29042922        // if view cells were already constructed 
    29052923        if (ViewCellsConstructed()) 
     
    29232941        Debug << "saved rays: " << (int)savedRays.size() << endl; 
    29242942 
    2925         mMaxPvsSize = (int)(mMaxPvsRatio * (float)objects.size()); 
    29262943 
    29272944        //TODO: remove 
     
    29682985                                                                                        const ObjectContainer &objects) 
    29692986{ 
    2970         //-- post processing of bsp view cells 
    29712987    int vcSize = 0; 
    29722988        int pvsSize = 0; 
    29732989 
    29742990        //-- merge view cells 
    2975          
    29762991        cout << "starting merge using " << mPostProcessSamples << " samples ... " << endl; 
    29772992        long startTime = GetTime(); 
     
    29812996        { 
    29822997                // TODO: should be done BEFORE the ray casting 
     2998                // compute tree by merging the nodes based on cost heuristics 
    29832999                mViewCellsTree->ConstructMergeTree(rays, objects); 
    29843000        } 
    29853001        else 
    29863002        { 
    2987                 mViewCellsTree->SetRoot(ConstructSpatialMergeTree(mVspBspTree->GetRoot())); 
     3003                // compute tree by merging the nodes of the spatial hierarchy 
     3004                ViewCell *root = ConstructSpatialMergeTree(mVspBspTree->GetRoot()); 
     3005                mViewCellsTree->SetRoot(root); 
    29883006        } 
    29893007 
     
    31623180        } 
    31633181 
    3164  
    31653182        // check if new view cells turned invalid 
    3166         Debug << "setting validity, min: " << mMinPvsSize << " max: " << mMaxPvsSize << endl; 
    3167         cout << "setting validity, min: " << mMinPvsSize << " max: " << mMaxPvsSize << endl; 
    3168         SetValidity(mMinPvsSize, mMaxPvsSize);  
     3183        int minPvs, maxPvs; 
     3184 
     3185        if (0) 
     3186        { 
     3187                minPvs = mMinPvsSize; 
     3188                maxPvs = mMaxPvsSize; 
     3189        } 
     3190        else 
     3191        { 
     3192                minPvs = mPruneEmptyViewCells ? 1 : 0; 
     3193                maxPvs = mMaxPvsSize; 
     3194        } 
     3195        Debug << "setting validity, min: " << minPvs << " max: " << maxPvs << endl; 
     3196        cout << "setting validity, min: " << minPvs << " max: " << maxPvs << endl; 
     3197         
     3198        SetValidity(minPvs, maxPvs);  
     3199 
    31693200        // update valid view space according to valid view cells 
    31703201        if (0) 
     
    31903221        MergeViewCells(postProcessRays, objects); 
    31913222         
    3192  
    31933223        // only for testing 
    31943224        TestSubdivision(); 
     
    37493779                        mVspBspTree->ConstructGeometry(leaf, geom); 
    37503780 
    3751                         const int cf = Polygon3::ClassifyPlane(geom.GetPolys(), *clipPlane, 0.00000001f); 
    3752  
    3753                         if (cf == Polygon3::BACK_SIDE) 
     3781                        const float eps = 0.00000001f; 
     3782                        const int cf = geom.Side(*clipPlane, eps); 
     3783 
     3784                        if (cf == -1) 
    37543785                        { 
    37553786                                exporter->ExportPolygons(geom.GetPolys()); 
    37563787                        } 
    3757                         else if (cf == Polygon3::SPLIT) 
     3788                        else if (cf == 0) 
    37583789                        { 
    37593790                                geom.SplitGeometry(front, 
     
    37613792                                                                   *clipPlane, 
    37623793                                                                   mViewSpaceBox,  
    3763                                                                    0.00000001f); 
     3794                                                                   eps); 
    37643795         
    37653796                                //Debug << "geo size: " << geom.Size() << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r706 r710  
    348348                                                         int maxPvsSize) const; 
    349349 
    350   /** sets validy of all viewcells */ 
     350        /** sets validy of all viewcells  
     351        */ 
    351352        virtual void SetValidity( 
    352353                                                         int minPvsSize,  
     
    355356 
    356357        /** set valid viewcells in the range of pvs. sorts the viewcells 
    357           according to the pvs and then pickups those in the ranges */ 
    358  
    359      
    360         void SetValidityPercentage(const float minValid,        const float maxValid); 
     358          according to the pvs and then pickups those in the ranges  
     359          */ 
     360        void SetValidityPercentage(const float minValid, const float maxValid); 
    361361 
    362362    int CountValidViewcells() const; 
     
    413413        /** Returns true if this (logical) view cell is equal to a spatial node. 
    414414        */ 
    415         virtual bool EqualToSpatialNode(ViewCell *viewCell) const { return false;} 
     415        virtual bool EqualToSpatialNode(ViewCell *viewCell) const; 
    416416 
    417417        /** Sets current view cells set to active, i.e., the sampling is done in this view cell set. 
     
    433433                @returns number of view cells found 
    434434        */ 
    435         virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const {return 0;}; 
     435        virtual int ComputeBoxIntersections(const AxisAlignedBox3 &box,  
     436                                                                                ViewCellContainer &viewCells) const; 
    436437 
    437438        virtual void TestFilter(const ObjectContainer &objects) {}; 
     
    511512        ViewCellsTree *mViewCellsTree; 
    512513 
    513         //bool mSampleEmptyViewCells; 
     514        bool mPruneEmptyViewCells; 
    514515 
    515516        /// maximum number of samples taken for construction of the view cells 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r708 r710  
    464464 
    465465        // first node is kd node, i.e. an axis aligned box 
    466         if (0) 
     466        if (1) 
    467467        tData.mIsKdNode = true; 
    468468        else 
     
    731731                                ++ mBspStats.polySplits; 
    732732 
    733                         tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && splitAxis < 3); 
     733                        tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3)); 
    734734 
    735735                        // how often was max cost ratio missed in this branch? 
     
    852852                        ++ mBspStats.polySplits; 
    853853 
    854                 tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && splitAxis < 3); 
     854                tFrontData.mIsKdNode = tBackData.mIsKdNode = (tData.mIsKdNode && (splitAxis < 3)); 
    855855                 
    856856                // how often was max cost ratio missed in this branch? 
     
    901901                BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 
    902902                BspViewCell *viewCell = new BspViewCell(); 
    903                  
    904                 leaf->SetViewCell(viewCell); 
    905          
     903 
     904        leaf->SetViewCell(viewCell); 
     905                 
    906906                //-- update pvs 
    907907                int conSamp = 0; 
     
    11321132 
    11331133 
    1134 void VspBspTree::SortSplitCandidates(const RayInfoContainer &rays, const int axis) 
     1134void VspBspTree::SortSplitCandidates(const RayInfoContainer &rays,  
     1135                                                                         const int axis,  
     1136                                                                         float minBand,  
     1137                                                                         float maxBand) 
    11351138{ 
    11361139        mSplitCandidates->clear(); 
     
    11471150        mSplitCandidates->reserve(requestedSize); 
    11481151 
     1152        float pos; 
     1153 
     1154        // float values => don't compare with exact values 
     1155        if (0) 
     1156        { 
     1157                minBand += Limits::Small; 
     1158                maxBand -= Limits::Small; 
     1159        } 
     1160 
    11491161        // insert all queries 
    11501162        for (RayInfoContainer::const_iterator ri = rays.begin(); ri < rays.end(); ++ ri) 
    11511163        { 
    11521164                const bool positive = (*ri).mRay->HasPosDir(axis); 
    1153                 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 
    1154                                                                                                   (*ri).ExtrapOrigin(axis), (*ri).mRay)); 
    1155  
    1156                 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin, 
    1157                                                                                                   (*ri).ExtrapTermination(axis), (*ri).mRay)); 
     1165                                 
     1166                pos = (*ri).ExtrapOrigin(axis); 
     1167                // clamp to min / max band 
     1168                if (0) ClipValue(pos, minBand, maxBand); 
     1169                 
     1170                mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,  
     1171                        pos, (*ri).mRay)); 
     1172 
     1173                pos = (*ri).ExtrapTermination(axis); 
     1174                // clamp to min / max band 
     1175                if (0) ClipValue(pos, minBand, maxBand); 
     1176 
     1177                mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,  
     1178                        pos, (*ri).mRay)); 
    11581179        } 
    11591180 
     
    11651186                                                                                  const AxisAlignedBox3 &box, 
    11661187                                                                                  const int pvsSize, 
    1167                                                                                   const int &axis, 
     1188                                                                                  const int axis, 
    11681189                                          float &position) 
    11691190{ 
    1170         SortSplitCandidates(rays, axis); 
     1191        const float minBox = box.Min(axis); 
     1192        const float maxBox = box.Max(axis); 
     1193        const float sizeBox = maxBox - minBox; 
     1194 
     1195        const float minBand = minBox + 0.1f * sizeBox; 
     1196        const float maxBand = minBox + 0.9f * sizeBox; 
     1197 
     1198        SortSplitCandidates(rays, axis, minBand, maxBand); 
    11711199 
    11721200        // go through the lists, count the number of objects left and right 
     
    11791207        int pvsFront = pvsr; 
    11801208 
    1181         float minBox = box.Min(axis); 
    1182         float maxBox = box.Max(axis); 
    1183         float sizeBox = maxBox - minBox; 
    1184  
    1185         float minBand = minBox + 0.1f * (maxBox - minBox); 
    1186         float maxBand = minBox + 0.9f * (maxBox - minBox); 
    1187  
    11881209        float sum = (float)pvsSize * sizeBox; 
    11891210        float minSum = 1e20f; 
     1211 
     1212        // if no border can be found, take mid split 
     1213        position = minBox + 0.5f * sizeBox; 
    11901214 
    11911215        Intersectable::NewMail(); 
     
    12731297 
    12741298                // Note: sufficient to compare size of bounding boxes of front and back side? 
    1275                 if ((*ci).value > minBand && (*ci).value < maxBand) 
     1299                if (((*ci).value >= minBand) && ((*ci).value <= maxBand)) 
    12761300                { 
    12771301                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
     
    12841308                                minSum = sum; 
    12851309                                position = (*ci).value; 
    1286  
     1310                                 
    12871311                                pvsBack = pvsl; 
    12881312                                pvsFront = pvsr; 
     
    12901314                } 
    12911315        } 
     1316         
     1317        //Debug << "pos: " << position << " sizebox: " << sizeBox << " pvs: " << pvsSize << endl; 
    12921318 
    12931319        // -- compute cost 
    1294  
    12951320        const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
    12961321        const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
     
    13241349                                                                                 float &pFront, 
    13251350                                                                                 float &pBack, 
    1326                                                                                  const bool useKdSplit) 
     1351                                                                                 const bool isKdNode) 
    13271352{ 
    13281353        float nPosition[3]; 
     
    13441369        // create bounding box of node geometry 
    13451370        AxisAlignedBox3 box; 
    1346         box.Initialize(); 
    1347          
     1371                 
    13481372        //TODO: for kd split geometry already is box => only take minmax vertices 
    13491373        if (1) 
    13501374        { 
    1351                 PolygonContainer::const_iterator it, it_end = tData.mGeometry->GetPolys().end(); 
    1352  
    1353                 for(it = tData.mGeometry->GetPolys().begin(); it < it_end; ++ it) 
    1354                         box.Include(*(*it)); 
     1375                tData.mGeometry->GetBoundingBox(box); 
    13551376        } 
    13561377        else 
    13571378        { 
     1379                box.Initialize(); 
    13581380                RayInfoContainer::const_iterator ri, ri_end = tData.mRays->end(); 
    13591381 
     
    13831405                        if (!mUseCostHeuristics) 
    13841406                        { 
    1385                                 nFrontGeom[axis] = new BspNodeGeometry(); 
    1386                                 nBackGeom[axis] = new BspNodeGeometry(); 
    1387  
    13881407                                nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 
    13891408                                Vector3 normal(0,0,0); normal[axis] = 1.0f; 
    13901409 
    13911410                                // allows faster split because we have axis aligned kd tree boxes 
    1392                                 if (0 && useKdSplit) 
     1411                                if (0 && isKdNode) 
    13931412                                { 
    13941413                                        nCostRatio[axis] = EvalAxisAlignedSplitCost(tData, 
     
    14011420                                        Vector3 pos; 
    14021421                                         
     1422                                        // create back geometry from box 
    14031423                                        pos = box.Max(); pos[axis] = nPosition[axis]; 
    14041424                                        AxisAlignedBox3 bBox(box.Min(), pos); 
    1405                                         // TODO 
    1406 #if 0 
    1407                                                 bBox.ExtractPolys(nBackGeom[axis]->GetPolys()); 
    1408 #endif                                   
     1425                                        PolygonContainer fPolys; 
     1426                                        bBox.ExtractPolys(fPolys); 
     1427 
     1428                                        nBackGeom[axis] = new BspNodeGeometry(fPolys); 
     1429         
     1430                                        // create front geometry from box 
    14091431                                        pos = box.Min(); pos[axis] = nPosition[axis]; 
    14101432                                        AxisAlignedBox3 fBox(pos, box.Max()); 
    1411                                         // TODO 
    1412 #if 0 
    1413                                                 fBox.ExtractPolys(nFrontGeom[axis]->GetPolys()); 
    1414 #endif 
     1433 
     1434                                        PolygonContainer bPolys; 
     1435                                        fBox.ExtractPolys(bPolys); 
     1436                                        nFrontGeom[axis] = new BspNodeGeometry(bPolys); 
    14151437                                } 
    14161438                                else 
    14171439                                { 
     1440                                        nFrontGeom[axis] = new BspNodeGeometry(); 
     1441                                        nBackGeom[axis] = new BspNodeGeometry(); 
     1442 
    14181443                                        nCostRatio[axis] =  
    14191444                                                EvalSplitPlaneCost(Plane3(normal, nPosition[axis]),  
     
    19782003 
    19792004        const int pvsSize = data.mPvs; 
    1980  
     2005//cout << "here433" << endl; 
    19812006        RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); 
    19822007 
     
    28322857 
    28332858 
    2834 int VspBspTree::FindApproximateNeighbors(BspNode *n, vector<BspLeaf *> &neighbors, 
     2859int VspBspTree::FindApproximateNeighbors(BspNode *n,  
     2860                                                                                 vector<BspLeaf *> &neighbors, 
    28352861                                                                                 const bool onlyUnmailed) const 
    28362862{ 
     
    29002926                                nodeStack.push(bspNodePair(interior->GetBack(), bGeom)); 
    29012927                                DEL_PTR(fGeom); 
    2902                         } 
     2928                                } 
    29032929                        else 
    29042930                        { 
     
    34423468                 
    34433469                vector<BspLeaf *> neighbors; 
     3470                 
     3471                // appoximate neighbor search has slightl relaxed constraints 
    34443472                if (1) 
    34453473                        FindNeighbors(leaf, neighbors, true); 
    34463474                else 
    34473475                        FindApproximateNeighbors(leaf, neighbors, true); 
     3476 
    34483477                vector<BspLeaf *>::const_iterator nit, nit_end = neighbors.end(); 
    34493478 
     
    34583487                                // in the tree? 
    34593488                                if (mEmptyViewCellsMergeAllowed || 
    3460                                         !leaf->GetViewCell()->GetPvs().Empty() || !(*nit)->GetViewCell()->GetPvs().Empty() || 
     3489                                        !leaf->GetViewCell()->GetPvs().Empty() ||  
     3490                                        !(*nit)->GetViewCell()->GetPvs().Empty() || 
    34613491                    leaf->IsSibling(*nit)) 
    34623492                                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r697 r710  
    535535                @param splitCandidates returns sorted list of split candidates 
    536536        */ 
    537         void SortSplitCandidates(const RayInfoContainer &rays, const int axis); 
     537        void SortSplitCandidates(const RayInfoContainer &rays,  
     538                                                         const int axis,  
     539                                                         float minBand,  
     540                                                         float maxBand); 
    538541 
    539542        /** Computes best cost for axis aligned planes. 
     
    542545                                                                  const AxisAlignedBox3 &box, 
    543546                                                                  const int pvsSize, 
    544                                                                   const int &axis, 
     547                                                                  const int axis, 
    545548                                                                  float &position); 
    546549 
Note: See TracChangeset for help on using the changeset viewer.