Changeset 2206 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 03/07/07 18:35:10 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r2199 r2206 237 237 mRoot(NULL), 238 238 mTimeStamp(1), 239 mIsInitialSubdivision(false) 239 mIsInitialSubdivision(false), 240 mCachedObjects(NULL) 240 241 { 241 242 ReadEnvironment(); … … 1940 1941 1941 1942 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 1947 void BvHierarchy::ReleaseViewCells(const ObjectContainer &objects) 1948 { 1949 1949 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1950 1950 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 1960 void BvHierarchy::AssociateViewCellsWithObjects(const ObjectContainer &objects)// const 1961 { 1962 ObjectContainer::const_iterator oit, oit_end = objects.end(); 1963 1952 1964 const bool useMailBoxing = true; 1953 1965 1954 int numRays = 0;1955 // loop through all object and collect view cell pvs of this node1966 mCachedObjects = new ObjectContainer(); 1967 1956 1968 for (oit = objects.begin(); oit != oit_end; ++ oit) 1957 1969 { 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 } 1990 1978 } 1991 1979 } … … 1996 1984 if (!obj->GetOrCreateViewCells()->empty()) 1997 1985 { 1998 cerr << "AssociateViewCellsWithObject: view cells cache not working" << endl; 1986 cerr << "AssociateViewCellsWithObject: view cells cache error" << endl; 1987 exit(0); 1999 1988 } 2000 1989 … … 2025 2014 if (obj->GetOrCreateViewCells()->empty()) 2026 2015 { 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; 2028 2017 return CountViewCellsFromRays(obj); 2029 2018 } … … 2188 2177 } 2189 2178 2179 2180 int 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 2219 int 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 2190 2251 #else 2252 2253 int 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 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 } 2292 2191 2293 2192 2294 int BvHierarchy::CountViewCells(Intersectable *obj) //const … … 2274 2376 #endif 2275 2377 2276 2277 int BvHierarchy::CountViewCells(const ObjectContainer &objects)// const2278 {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 node2285 for (oit = objects.begin(); oit != oit_end; ++ oit)2286 {2287 nViewCells += CountViewCells(*oit);2288 }2289 2290 return nViewCells;2291 }2292 2378 2293 2379
Note: See TracChangeset
for help on using the changeset viewer.