34 #ifndef CARTODATA_VOLUME_VOLUMEUTIL_D_H 35 #define CARTODATA_VOLUME_VOLUMEUTIL_D_H 59 T internal_max(
const T x,
const T y )
60 {
return std::max<T>( x, y ); }
64 T internal_min(
const T x,
const T y )
65 {
return std::min<T>( x, y ); }
72 template <
typename T>
template <
class UnaryFunction>
87 op = &o->
at( 0, y, z, t );
88 rp = &res->
at( 0, y, z, t );
147 template <
typename T>
template <
class BinaryFunction>
186 bool x1, y1, z1, x2, y2, z2;
188 for( t=0; t<nt2; ++t )
207 for( z=0; z<nz2; ++z )
219 for( y=0; y<ny2; ++y )
231 o1p = &o1->
at( 0, y, z, t );
235 o2p = &o2->
at( 0, y, z, t );
238 rp = &res->
at( 0, y, z, t );
251 *rp++ = f( *o1p++, *o2p++ );
266 *rp++ = f( internal::_neutral<T>(), *o2p++ );
269 *rp++ = f( *o1p++, internal::_neutral<T>() );
271 *rp++ = f( internal::_neutral<T>(),
272 internal::_neutral<T>() );
280 template <
typename T>
template <
class UnaryFunction>
286 for( t=0; t<nt; ++t )
287 for( z=0; z<nz; ++z )
288 for( y=0; y<ny; ++y )
290 op = &o->
at( 0, y, z, t );
291 for( x=0; x<nx; ++x, ++op )
297 template <
typename T>
template <
class BinaryFunction>
314 for( t=0; t<nt; ++t )
315 for( z=0; z<nz; ++z )
316 for( y=0; y<ny; ++y )
318 o1p = &o1->
at( 0, y, z, t );
319 o2p = &o2->
at( 0, y, z, t );
320 for( x=0; x<nx; ++x, ++o1p )
321 *o1p = f( *o1p, *o2p++ );
326 template <
typename T>
template <
class BinaryFunction>
335 for( t=0; t<nt; ++t )
336 for( z=0; z<nz; ++z )
337 for( y=0; y<ny; ++y )
339 op = &o.
at( 0, y, z, t );
340 for( x=0; x<nx; ++x )
341 res = f( *op++, res );
347 template <
typename T>
354 template <
typename T>
358 internal_max<T>, o, min_limit<T>() );
377 std::plus<VoxelRGB> >,
384 std::plus<VoxelRGB> >,
394 std::minus<VoxelRGB> >,
398 std::minus<VoxelRGB> >,
402 std::minus<VoxelRGB> >,
420 std::plus<VoxelRGBA> >,
424 std::plus<VoxelRGBA> >,
428 std::plus<VoxelRGBA> >,
440 std::minus<VoxelRGBA> >,
444 std::minus<VoxelRGBA> >,
448 std::minus<VoxelRGBA> >,
uint32_t _neutral< uint32_t >()
float _neutral< float >()
const T & at(long x, long y=0, long z=0, long t=0) const
static VolumeRef< T > apply(UnaryFunction f, const VolumeRef< T > &o)
applies a unary function to each voxel of a volume
double _neutral< double >()
int32_t _neutral< int32_t >()
int8_t _neutral< int8_t >()
T max(const Volume< T > &vol)
Returns the maximum value of the volume.
Convenient handle for a Volume - this is normally the entry point for all volumes handling...
uint8_t _neutral< uint8_t >()
T min(const Volume< T > &vol)
Returns the minimum value of the volume.
const T & at(long x, long y=0, long z=0, long t=0) const
const PropertySet & header() const
uint16_t _neutral< uint16_t >()
int16_t _neutral< int16_t >()
static T accumulate(BinaryFunction f, const VolumeRef< T > &o2, T initial)
Apply a binary function to each voxel of the volume, with a "current" value as second argument...
static void selfApply(UnaryFunction f, VolumeRef< T > &o)
same as apply() except that the input volume is used to store the result