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>
73 template <
class INP,
class OUTP>
91 RawConverter(
bool timeislabel =
false,
bool withConstantValue =
false,
93 : _timeIsLabel( timeislabel ), _hasValue( withConstantValue ),
111 template <
class OUTP>
116 : _timeIsLabel( timeislabel ) {}
131 template <
class INP,
class OUTP>
141 template <
class INP,
class OUTP>
157 : _timeIsLabel( timeislabel ) {}
176 : _timeIsLabel( timeislabel ) {}
189 template <
typename INP,
typename OUTP>
197 template <
typename INP,
typename OUTP>
205 template <
typename INP,
typename OUTP>
215 template <
class INP,
class OUTP>
inline 227 for( i=in.begin(); i!=e; ++i )
230 for( ib=i->second.begin(), eb=i->second.end(); ib!=eb; ++ib )
232 itemconv.
convert( ib->second, outval );
233 b[ ib->first ] = outval;
239 template <
class INP,
class OUTP>
inline 244 printToVolume( in, out,
Point3d( 0, 0, 0 ) );
248 template <
class INP,
class OUTP>
inline 249 void RawConverter<aims::BucketMap<INP>,
AimsData<OUTP> >::printToVolume
259 for( it=in.begin(); it!=et; ++it, ++i )
261 for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
263 const Point3d & pos = ib->first;
265 out( pos[0] + offset[0], pos[1] + offset[1],
266 pos[2] + offset[2], i ) );
272 template <
class OUTP>
inline 277 printToVolume( in, out,
Point3d( 0, 0, 0 ) );
283 template <
typename OUTP,
bool MODE>
289 const Point3d & offset,
bool timelabel );
292 template <
typename OUTP>
295 template <
typename INP>
311 for( it=in.begin(); it!=et; ++it, ++i )
313 for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
315 const Point3d & pos = ib->first;
316 out( pos[0] + offset[0], pos[1] + offset[1], pos[2]
325 template <
typename OUTP>
328 template <
typename INP>
340 for( it=in.begin(); it!=et; ++it, ++i )
342 for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
344 const Point3d & pos = ib->first;
346 out( pos[0] + offset[0], pos[1] + offset[1],
347 pos[2] + offset[2], i ) );
353 template <
typename OUTP>
inline 356 const Point3d & offset,
bool timelabel )
359 ( in, out, offset, timelabel );
365 template <
typename OUTP>
inline 366 void RawConverter<aims::BucketMap<Void>,
AimsData<OUTP> >::printToVolume
375 for( it=in.begin(); it!=et; ++it, ++i )
377 for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
379 const Point3d & pos = ib->first;
380 out( pos[0] + offset[0], pos[1] + offset[1],
381 pos[2] + offset[2], i ) = _value;
390 template <
class INP,
class OUTP>
inline 395 unsigned t,
nt = in.
dimT();
401 for( t=0; t<
nt; ++t )
409 val = in( x, y, z, t );
412 itemconv.
convert( val, outval );
413 bck.
insert( std::pair<Point3d, OUTP>
414 (
Point3d( x, y, z ), outval ) );
424 template <
class INP>
inline 429 unsigned t,
nt = in.
dimT();
433 if( nt == 1 && timeIsLabel() )
443 out[ t ].
insert( std::pair<Point3d, Void>
449 for( t=0; t<
nt; ++t )
455 val = in( x, y, z, t );
467 template <
class INP,
class OUTP>
479 template <
class INP,
class OUTP>
485 = ConverterAllocator<aims::BucketMap<INP>,
VolumeRef<OUTP> >::alloc( in );
494 template <
class INP,
class OUTP>
501 Point3d bmin( 0, 0, 0 ), bmax( 0, 0, 0 );
505 for( it=in.begin(); it!=et; ++it )
506 for( ib=it->second.begin(), eb=it->second.end(); ib!=eb; ++ib )
508 const Point3d & pos = ib->first;
521 if( pos[0] < bmin[0] )
523 if( pos[1] < bmin[1] )
525 if( pos[2] < bmin[2] )
527 if( pos[0] > bmax[0] )
529 if( pos[1] > bmax[1] )
531 if( pos[2] > bmax[2] )
536 if( bmin[0] >= 0 && bmin[1] >= 0 && bmin[2] >= 0 )
540 *out(
new VolumeRef<OUTP>( bmax[0] - bmin[0] + 1, bmax[1] - bmin[1] + 1,
541 bmax[2] - bmin[2] + 1, in.size() ) );
542 std::vector<float> vs( 4 );
547 out->
header().setProperty(
"voxel_size", vs );
554 template <
class INP,
class OUTP>
inline 558 std::vector<float> vs(4);
563 out.
header().setProperty(
"voxel_size", vs );
564 printToVolume( in, out,
Point3d( 0, 0, 0 ) );
568 template <
class INP,
class OUTP>
inline 569 void RawConverter<aims::BucketMap<INP>,
VolumeRef<OUTP> >::printToVolume
575 c.printToVolume( in, data, offset );
579 template <
class OUTP>
inline 583 std::vector<float> vs(4);
588 out.
header().setProperty(
"voxel_size", vs );
589 printToVolume( in, out,
Point3d( 0, 0, 0 ) );
593 template <
typename OUTP>
inline 594 void RawConverter<aims::BucketMap<Void>,
VolumeRef<OUTP> >::printToVolume
599 RawConverter<aims::BucketMap<Void>,
AimsData<OUTP> > c( _timeIsLabel );
600 c.printToVolume( in, data, offset );
604 template <
class INP,
class OUTP>
inline 614 template <
class INP>
inline
void convert(const INP &in, OUTP &out) const
RawConverter(bool timeislabel=false, bool withConstantValue=false, OUTP value=0)
RawConverter(bool timeislabel=false)
float sizeY() const
returns the Y resolution in mm
void erase(const Point3d &pos)
Function redefined to omit time.
#define ForEach3d(thing, x, y, z)
float sizeZ() const
returns the Z resolution in mm
float sizeX() const
returns the X resolution in mm
The class for EcatSino data write operation.
void setTimeIsLabel(bool x)
static void printToVolume(const aims::BucketMap< INP > &in, AimsData< OUTP > &out, const Point3d &offset, bool)
static void printToVolume(const aims::BucketMap< INP > &in, AimsData< OUTP > &out, const Point3d &offset, bool timelabel)
An alternate, ordered, representation for buckets (voxels lists).
std::map< Point3d, T, BucketMapLess > Bucket
const PropertySet & header() const
void setTimeIsLabel(bool x)
void fill(const T &value)
void setSizeXYZT(float sizex, float sizey, float sizez, float sizet)
sets X,Y,Z and T resolutions of the data
void setTimeIsLabel(bool x)
void setTimeIsLabel(bool x)
void insert(const Point3d &pos, const T &item)
Function redefined to omit time.
float sizeT() const
returns the T resolution in s
std::map< int, Bucket >::const_iterator const_iterator
void setHeader(const aims::PythonHeader &hdr)
virtual void setProperty(const std::string &, Object)
void setSizeXYZT(float sizex=1.0f, float sizey=1.0f, float sizez=1.0f, float sizet=1.0f)
RawConverter(bool timeislabel=false)
const aims::PythonHeader & header() const
void printToVolume_smart(const aims::BucketMap< Void > &in, AimsData< OUTP > &out, const Point3d &offset, bool timelabel)
RawConverter(bool timeislabel=false)