Ignore:
Timestamp:
03/07/07 18:35:10 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2199 r2206  
    237237mRoot(NULL), 
    238238mTimeStamp(1), 
    239 mIsInitialSubdivision(false) 
     239mIsInitialSubdivision(false), 
     240mCachedObjects(NULL) 
    240241{ 
    241242        ReadEnvironment(); 
     
    19401941 
    19411942 
    1942 int BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
    1943                                                                   ViewCellContainer &viewCells, 
    1944                                                                   const bool setCounter, 
    1945                                                                   const bool onlyUnmailedRays)// const 
    1946 { 
    1947         ViewCell::NewMail(); 
    1948  
     1943 
     1944#if STORE_VIEWCELLS_WITH_BVH 
     1945 
     1946 
     1947void BvHierarchy::ReleaseViewCells(const ObjectContainer &objects) 
     1948{ 
    19491949        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    19501950 
    1951         // use mailing to avoid dublicates 
     1951        for (oit = objects.begin(); oit != oit_end; ++ oit) 
     1952        { 
     1953                (*oit)->DelViewCells(); 
     1954        } 
     1955 
     1956        DEL_PTR(mCachedObjects); 
     1957} 
     1958 
     1959 
     1960void BvHierarchy::AssociateViewCellsWithObjects(const ObjectContainer &objects)// const 
     1961{ 
     1962        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     1963 
    19521964        const bool useMailBoxing = true; 
    19531965 
    1954         int numRays = 0; 
    1955         // loop through all object and collect view cell pvs of this node 
     1966        mCachedObjects = new ObjectContainer(); 
     1967         
    19561968        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    19571969        { 
    1958                 // use mailing to avoid duplicates 
    1959                 numRays += CollectViewCells(*oit, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 
    1960         } 
    1961  
    1962         return numRays; 
    1963 } 
    1964  
    1965  
    1966 #if STORE_VIEWCELLS_WITH_BVH 
    1967  
    1968  
    1969 void BvHierarchy::ReleaseViewCells(const ObjectContainer &objects) 
    1970 { 
    1971         ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    1972  
    1973         for (oit = objects.begin(); oit != oit_end; ++ oit) 
    1974         { 
    1975                 (*oit)->DelViewCells(); 
    1976         } 
    1977 } 
    1978  
    1979  
    1980 void BvHierarchy::AssociateViewCellsWithObjects(const ObjectContainer &objects) const 
    1981 { 
    1982         ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    1983  
    1984         const bool useMailBoxing = true; 
    1985         for (oit = objects.begin(); oit != oit_end; ++ oit) 
    1986         { 
    1987                 ViewCell::NewMail(); 
    1988                 // use mailing to avoid duplicates 
    1989                 AssociateViewCellsWithObject(*oit, useMailBoxing); 
     1970                if (!(*oit)->GetOrCreateRays()->empty()) 
     1971                { 
     1972                        ViewCell::NewMail(); 
     1973                        // use mailing to avoid duplicates 
     1974                        AssociateViewCellsWithObject(*oit, useMailBoxing); 
     1975                         
     1976                        mCachedObjects->push_back(*oit); 
     1977                } 
    19901978        } 
    19911979} 
     
    19961984        if (!obj->GetOrCreateViewCells()->empty()) 
    19971985        { 
    1998                 cerr << "AssociateViewCellsWithObject: view cells cache not working" << endl; 
     1986                cerr << "AssociateViewCellsWithObject: view cells cache error" << endl; 
     1987                exit(0); 
    19991988        } 
    20001989 
     
    20252014        if (obj->GetOrCreateViewCells()->empty()) 
    20262015        { 
    2027                 //cerr << "h";//CountViewCells: view cells empty, view cells cache not working" << endl; 
     2016                cerr << "h";//CountViewCells: view cells empty, view cells cache not working" << endl; 
    20282017                return CountViewCellsFromRays(obj); 
    20292018        } 
     
    21882177} 
    21892178 
     2179 
     2180int BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
     2181                                                                  ViewCellContainer &viewCells, 
     2182                                                                  const bool setCounter, 
     2183                                                                  const bool onlyUnmailedRays)// const 
     2184{ 
     2185        ViewCell::NewMail(); 
     2186 
     2187        // use mailing to avoid dublicates 
     2188        const bool useMailBoxing = true; 
     2189 
     2190        int numRays = 0; 
     2191 
     2192        if (mCachedObjects) 
     2193        { 
     2194                ObjectContainer::const_iterator oit, oit_end = mCachedObjects->end(); 
     2195 
     2196                // loop through all object and collect view cell pvs of this node 
     2197                for (oit = mCachedObjects->begin(); oit != oit_end; ++ oit) 
     2198                { 
     2199                        // use mailing to avoid duplicates 
     2200                        numRays += CollectViewCells(*oit, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 
     2201                } 
     2202        } 
     2203        else 
     2204        { 
     2205                ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     2206 
     2207                // loop through all object and collect view cell pvs of this node 
     2208                for (oit = objects.begin(); oit != oit_end; ++ oit) 
     2209                { 
     2210                        // use mailing to avoid duplicates 
     2211                        numRays += CollectViewCellsFromRays(*oit, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 
     2212                } 
     2213        } 
     2214 
     2215        return numRays; 
     2216} 
     2217 
     2218 
     2219int BvHierarchy::CountViewCells(const ObjectContainer &objects)// const 
     2220{ 
     2221        int nViewCells = 0; 
     2222 
     2223        ViewCell::NewMail(); 
     2224         
     2225        if (mCachedObjects) 
     2226        { 
     2227                ObjectContainer::const_iterator oit, oit_end = mCachedObjects->end(); 
     2228 
     2229                // loop through all object and collect view cell pvs of this node 
     2230                for (oit = mCachedObjects->begin(); oit != oit_end; ++ oit) 
     2231                { 
     2232                        // use mailing to avoid duplicates 
     2233                        nViewCells += CountViewCells(*oit); 
     2234                } 
     2235        } 
     2236        else 
     2237        { 
     2238                ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     2239 
     2240                // loop through all object and collect view cell pvs of this node 
     2241                for (oit = objects.begin(); oit != oit_end; ++ oit) 
     2242                { 
     2243                        nViewCells += CountViewCellsFromRays(*oit); 
     2244                } 
     2245        } 
     2246 
     2247        return nViewCells; 
     2248} 
     2249 
     2250 
    21902251#else 
     2252 
     2253int BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
     2254                                                                  ViewCellContainer &viewCells, 
     2255                                                                  const bool setCounter, 
     2256                                                                  const bool onlyUnmailedRays)// const 
     2257{ 
     2258        ViewCell::NewMail(); 
     2259 
     2260        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     2261 
     2262        // use mailing to avoid dublicates 
     2263        const bool useMailBoxing = true; 
     2264 
     2265        int numRays = 0; 
     2266        // loop through all object and collect view cell pvs of this node 
     2267        for (oit = objects.begin(); oit != oit_end; ++ oit) 
     2268        { 
     2269                // use mailing to avoid duplicates 
     2270                numRays += CollectViewCells(*oit, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 
     2271        } 
     2272 
     2273        return numRays; 
     2274} 
     2275 
     2276 
     2277int BvHierarchy::CountViewCells(const ObjectContainer &objects)// const 
     2278{ 
     2279        int nViewCells = 0; 
     2280 
     2281        ViewCell::NewMail(); 
     2282        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     2283 
     2284        // loop through all object and collect view cell pvs of this node 
     2285        for (oit = objects.begin(); oit != oit_end; ++ oit) 
     2286        { 
     2287                nViewCells += CountViewCells(*oit); 
     2288        } 
     2289 
     2290        return nViewCells; 
     2291} 
     2292 
    21912293 
    21922294int BvHierarchy::CountViewCells(Intersectable *obj) //const 
     
    22742376#endif 
    22752377 
    2276  
    2277 int BvHierarchy::CountViewCells(const ObjectContainer &objects)// const 
    2278 { 
    2279         int nViewCells = 0; 
    2280  
    2281         ViewCell::NewMail(); 
    2282         ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    2283  
    2284         // loop through all object and collect view cell pvs of this node 
    2285         for (oit = objects.begin(); oit != oit_end; ++ oit) 
    2286         { 
    2287                 nViewCells += CountViewCells(*oit); 
    2288         } 
    2289  
    2290         return nViewCells; 
    2291 } 
    22922378 
    22932379 
Note: See TracChangeset for help on using the changeset viewer.