MCPcopy Create free account
hub / github.com/ImageEngine/cortex / parallelReadAll

Function parallelReadAll

src/IECoreScene/SceneAlgo.cpp:243–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241{
242
243SceneStats parallelReadAll( const SceneInterface *src, int startFrame, int endFrame, float frameRate, unsigned int flags )
244{
245 std::atomic<size_t> locationCount( 0 );
246 ::CopyInfo<std::atomic<size_t> > copyInfos;
247
248 auto locationFn = [&locationCount, &copyInfos]( const SceneInterface *src, SceneInterface *dst, double time, unsigned int flags )
249 {
250 locationCount++;
251 ::CopyInfo<size_t> copyInfo = ::handleLocation( src, nullptr, time, flags );
252
253 copyInfos.polygonCount += copyInfo.polygonCount;
254 copyInfos.tagCount += copyInfo.tagCount;
255 copyInfos.attributeCount += copyInfo.attributeCount;
256 copyInfos.curveCount += copyInfo.curveCount;
257 copyInfos.pointCount += copyInfo.pointCount;
258 };
259
260 for( int f = startFrame; f <= endFrame; ++f )
261 {
262 double time = f / frameRate;
263 tbb::task_group_context taskGroupContext( tbb::task_group_context::isolated );
264 Task<decltype( locationFn )> *task = new( tbb::task::allocate_root( taskGroupContext ) ) Task<decltype( locationFn )>( src, nullptr, locationFn, time, flags );
265 tbb::task::spawn_root_and_wait( *task );
266 }
267
268 SceneStats stats;
269 stats["locations"] = locationCount;
270 stats["polygons"] = copyInfos.polygonCount;
271 stats["curves"] = copyInfos.curveCount;
272 stats["points"] = copyInfos.pointCount;
273 stats["tags"] = copyInfos.tagCount;
274 stats["sets"] = copyInfos.setCount;
275 stats["attributes"] = copyInfos.attributeCount;
276 return stats;
277}
278
279void copy( const SceneInterface *src, SceneInterface *dst, int startFrame, int endFrame, float frameRate, unsigned int flags )
280{

Callers

nothing calls this directly

Calls 1

handleLocationFunction · 0.85

Tested by

no test coverage detected