37 #ifndef AIMS_UTILITY_CONVERTER_BUCKET_H 
   38 #define AIMS_UTILITY_CONVERTER_BUCKET_H 
   49   template <
class INP,
class OUTP>
 
   60   template <
class INP,
class OUTP>
 
   75   template <
class INP,
class OUTP>
 
   77     : 
public RawConverter<aims::BucketMap<INP>, rc_ptr<Volume<OUTP> > >
 
   92         ::printToVolume( in, out, offset );
 
  103     RawConverter( 
bool timeislabel = 
false, 
bool withConstantValue = 
false,
 
  105       : _timeIsLabel( timeislabel ), _hasValue( withConstantValue ),
 
  124   template <
class OUTP>
 
  126     : 
public RawConverter<aims::BucketMap<Void>, rc_ptr<Volume<OUTP> > >
 
  140         ::printToVolume( in, out, offset );
 
  147   template <
class INP,
class OUTP>
 
  158   template <
class INP,
class OUTP>
 
  160     : 
public RawConverter<rc_ptr<Volume<INP> >, aims::BucketMap<OUTP> >
 
  175       : _timeIsLabel( timeislabel ) {}
 
  192     : 
public RawConverter<rc_ptr<Volume<INP> >, aims::BucketMap<Void> >
 
  202   template <
typename INP,
typename OUTP>
 
  210   template <
typename INP,
typename OUTP>
 
  218   template <
typename INP,
typename OUTP>
 
  234   template <
class INP,
class OUTP> 
inline 
  246     for( i=in.begin(); i!=e; ++i )
 
  249         for( ib=i->second.begin(), eb=i->second.end(); ib!=eb; ++ib )
 
  251             itemconv.
convert( ib->second, outval );
 
  252             b[ ib->first ] = outval;
 
  258   template <
class INP,
class OUTP> 
inline 
  267     int dx = out->getSizeX(), dy = out->getSizeY(), dz = out->getSizeZ(),
 
  268         dt = out->getSizeT();
 
  272     for( it=in.begin(); it!=et; ++it, ++i )
 
  276       for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
 
  278         const Point3d   pos = ib->first + offset;
 
  279         if( pos[0] >= 0 && pos[1] >= 0 && pos[2] >= 0
 
  280             && pos[0] < dx && pos[1] < dy && pos[2] < dz )
 
  282                             out->at( pos[0], pos[1], pos[2], i ) );
 
  290     template <
typename OUTP, 
bool MODE> 
 
  296                           const Point3d & offset, 
bool timelabel );
 
  299     template <
typename OUTP>
 
  302       template <
typename INP>
 
  317         int dx = out->getSizeX(), dy = out->getSizeY(), dz = out->getSizeZ();
 
  319         for( it=in.begin(); it!=et; ++it, ++i )
 
  321           for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
 
  323             const Point3d       pos = ib->first + offset;
 
  324             if( pos[0] >= 0 && pos[1] >= 0 && pos[2] >= 0
 
  325                 && pos[0] < dx && pos[1] < dy && pos[2] < dz )
 
  326               out->at( pos ) = (OUTP) it->first;
 
  333     template <
typename OUTP>
 
  336       template <
typename INP>
 
  345         int dx = out->getSizeX(), dy = out->getSizeY(), dz = out->getSizeZ(),
 
  346             dt = out->getSizeT();
 
  350         for( it=in.begin(); it!=et; ++it, ++i )
 
  354           for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
 
  356             const Point3d       pos = ib->first + offset;
 
  357             if( pos[0] >= 0 && pos[1] >= 0 && pos[2] >= 0
 
  358                 && pos[0] < dx && pos[1] < dy && pos[2] < dz )
 
  360                                 out->at( pos[0], pos[1], pos[2], i ) );
 
  366     template <
typename OUTP> 
inline 
  369                               const Point3d & offset, 
bool timelabel )
 
  372         ( in, out, offset, timelabel );
 
  378   template <
typename OUTP> 
inline 
  379   void RawConverter<aims::BucketMap<Void>,
 
  389       int dx = out->getSizeX(), dy = out->getSizeY(), dz = out->getSizeZ();
 
  390       for( it=in.begin(); it!=et; ++it, ++i )
 
  392         for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
 
  394           const Point3d     & pos = ib->first + offset;
 
  395           if( pos[0] >= 0 && pos[1] >= 0 && pos[2] >= 0
 
  396               && pos[0] < dx && pos[1] < dy && pos[2] < dz )
 
  397             out->at( pos[0], pos[1], pos[2], i ) = _value;
 
  406   template <
class INP,
class OUTP> 
inline 
  407   void RawConverter<carto::rc_ptr<Volume<INP> >,
 
  411     unsigned            t, 
nt = in->getSizeT();
 
  412     int x, y, z, nx = in->getSizeX(), ny = in->getSizeY(), nz = in->getSizeZ();
 
  415     RawConverter<INP,OUTP>      itemconv;
 
  419     for( t=0; t<
nt; ++t )
 
  423       for( z=0; z<nz; ++z )
 
  424         for( y=0; y<ny; ++y )
 
  425           for( x=0; x<nx; ++x )
 
  429             val = in->at( x, y, z, t );
 
  432               itemconv.convert( val, outval );
 
  433               bck.
insert( std::pair<Point3d, OUTP>
 
  434                           ( 
Point3d( x, y, z ), outval ) );
 
  443   template <
class INP> 
inline 
  444   void RawConverter<carto::rc_ptr<Volume<INP> >,
 
  448     unsigned            t, 
nt = in->getSizeT();
 
  449     int x, y, z, nx = in->getSizeX(), ny = in->getSizeY(), nz = in->getSizeZ();
 
  454     if( 
nt == 1 && timeIsLabel() )
 
  457       RawConverter<INP,size_t>  rc;
 
  458       for( z=0; z<nz; ++z )
 
  459         for( y=0; y<ny; ++y )
 
  460           for( x=0; x<nx; ++x )
 
  462             val = in->at( x, y, z );
 
  465               rc.convert( val, t );
 
  466               out[ t ].
insert( std::pair<Point3d, Void>
 
  472       for( t=0; t<
nt; ++t )
 
  476         for( z=0; z<nz; ++z )
 
  477           for( y=0; y<ny; ++y )
 
  478             for( x=0; x<nx; ++x )
 
  480               val = in->at( x, y, z, t );
 
  491   template <
class INP,
class OUTP>
 
  505   template <
class INP,
class OUTP>
 
  512     Point3d     bmin( 0, 0, 0 ), bmax( 0, 0, 0 );
 
  516     for( it=in.begin(); it!=et; ++it )
 
  517       for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
 
  519         const Point3d   & pos = ib->first;
 
  532           if( pos[0] < bmin[0] )
 
  534           if( pos[1] < bmin[1] )
 
  536           if( pos[2] < bmin[2] )
 
  538           if( pos[0] > bmax[0] )
 
  540           if( pos[1] > bmax[1] )
 
  542           if( pos[2] > bmax[2] )
 
  547     if( bmin[0] >= 0 && bmin[1] >= 0 && bmin[2] >= 0 )
 
  551       *out( 
new VolumeRef<OUTP>( bmax[0] - bmin[0] + 1, bmax[1] - bmin[1] + 1,
 
  552                                  bmax[2] - bmin[2] + 1, in.size() ) );
 
  553     std::vector<float> vs( 4 );
 
  558     (*out)->header().setProperty( 
"voxel_size", vs );
 
  565   template <
class INP,
class OUTP> 
inline 
  569     std::vector<float> vs(4);
 
  575     printToVolume( in, out, 
Point3d( 0, 0, 0 ) );
 
  579   template <
class OUTP> 
inline 
  583     std::vector<float> vs(4);
 
  589     printToVolume( in, out, 
Point3d( 0, 0, 0 ) );
 
An alternate, ordered, representation for buckets (voxels lists).
float sizeZ() const
returns the Z resolution in mm
void insert(const Point3d &pos, const T &item)
Function redefined to omit time.
void setSizeXYZT(float sizex, float sizey, float sizez, float sizet)
sets X,Y,Z and T resolutions of the data
const aims::PythonHeader & header() const
void erase(const Point3d &pos)
Function redefined to omit time.
std::map< Point3d, T, BucketMapLess > Bucket
float sizeT() const
returns the T resolution in s
float sizeY() const
returns the Y resolution in mm
void setHeader(const aims::PythonHeader &hdr)
float sizeX() const
returns the X resolution in mm
std::map< int, Bucket >::const_iterator const_iterator
std::vector< float > getVoxelSize() const
static VolumeRef< OUTP > * alloc(const aims::BucketMap< INP > &in)
static OUTP * alloc(const INP &in)
RawConverter(bool timeislabel=false)
void convert(const aims::BucketMap< INP > &in, VolumeRef< OUTP > &out) const
void printToVolume(const aims::BucketMap< INP > &in, VolumeRef< OUTP > &out, const Point3d &offset=Point3d(0, 0, 0)) const
writes bucket in an already allocated data
void printToVolume(const aims::BucketMap< INP > &in, rc_ptr< Volume< OUTP > > &out, const Point3d &offset=Point3d(0, 0, 0)) const
writes bucket in an already allocated data
void convert(const aims::BucketMap< Void > &in, VolumeRef< OUTP > &out) const
void printToVolume(const aims::BucketMap< Void > &in, VolumeRef< OUTP > &out, const Point3d &offset=Point3d(0, 0, 0)) const
void printToVolume(const aims::BucketMap< Void > &in, rc_ptr< Volume< OUTP > > &out, const Point3d &offset=Point3d(0, 0, 0)) const
void setTimeIsLabel(bool x)
RawConverter(bool timeislabel=false, bool withConstantValue=false, OUTP value=0)
void convert(const rc_ptr< Volume< INP > > &in, aims::BucketMap< OUTP > &out) const
void setTimeIsLabel(bool x)
RawConverter(bool timeislabel=false)
void convert(const rc_ptr< Volume< INP > > &in, aims::BucketMap< Void > &out) const
void convert(const INP &in, OUTP &out) const
virtual void setProperty(const std::string &, Object)
The class for EcatSino data write operation.
void printToVolume_smart(const aims::BucketMap< Void > &in, carto::rc_ptr< Volume< OUTP > > &out, const Point3d &offset, bool timelabel)
static void printToVolume(const aims::BucketMap< INP > &in, carto::rc_ptr< Volume< OUTP > > &out, const Point3d &offset, bool)
static void printToVolume(const aims::BucketMap< INP > &in, carto::rc_ptr< Volume< OUTP > > &out, const Point3d &offset, bool timelabel)
static void printToVolume(const aims::BucketMap< Void > &in, carto::rc_ptr< Volume< OUTP > > &out, const Point3d &offset, bool timelabel)