| 72 | } |
| 73 | |
| 74 | Imath::Box3f Primitive::bound() const |
| 75 | { |
| 76 | Box3f result; |
| 77 | PrimitiveVariableMap::const_iterator it = variables.find( "P" ); |
| 78 | if( it!=variables.end() ) |
| 79 | { |
| 80 | ConstV3fVectorDataPtr p = runTimeCast<const V3fVectorData>( it->second.data ); |
| 81 | if( p ) |
| 82 | { |
| 83 | const vector<V3f> &pp = p->readable(); |
| 84 | using RangeType = tbb::blocked_range< const V3f* >; |
| 85 | tbb::this_task_arena::isolate( [ & result, & pp ]{ |
| 86 | tbb::task_group_context taskGroupContext( tbb::task_group_context::isolated ); |
| 87 | result = tbb::parallel_reduce( RangeType( pp.data(), pp.data() + pp.size(), 1000 ), Imath::Box3f(), |
| 88 | []( const RangeType& range, const Imath::Box3f& value ) -> Imath::Box3f |
| 89 | { |
| 90 | Imath::Box3f b( value ); |
| 91 | for( const V3f& pos : range ) |
| 92 | { |
| 93 | b.extendBy( pos ); |
| 94 | } |
| 95 | return b; |
| 96 | }, |
| 97 | []( const Imath::Box3f& lhs, const Imath::Box3f& rhs ) -> Imath::Box3f |
| 98 | { |
| 99 | Imath::Box3f b( lhs ); |
| 100 | b.extendBy( rhs ); |
| 101 | return b; |
| 102 | }, |
| 103 | taskGroupContext ); |
| 104 | } ); |
| 105 | } |
| 106 | } |
| 107 | return result; |
| 108 | } |
| 109 | |
| 110 | void Primitive::copyFrom( const Object *other, IECore::Object::CopyContext *context ) |
| 111 | { |