11#ifndef PRIMATOLOGIST_UTILITY_IO_H
12#define PRIMATOLOGIST_UTILITY_IO_H
14#include <aims/utility/converter_g.h>
15#include <aims/io/io_g.h>
16#include <aims/io/channelR.h>
17#include <cartodata/volume/volume.h>
24 void write(
const T &
object,
const std::string & fname,
bool doit =
true )
36 void read(
const std::string & fname, T &
object,
bool doit =
true )
49 void readChannel(
const std::string & fname, T &
object, int8_t channel,
bool doit =
true )
53 ChannelReader<T> r( fname );
54 r.read(
object, channel );
58#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
61 void readChannel(
const std::string & fname, carto::VolumeRef<T> &
object, int8_t channel,
bool doit =
true )
65 carto::VolumeRef<T> data(
object );
66 ChannelReader<carto::VolumeRef<T> > r( fname );
67 r.read( data, channel );
68 if(
object.get() != data.get() )
74#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
78 template<
typename IN,
typename OUT>
79 bool convert( Process & p,
const std::string & fname, Finder & f );
107 template<
typename IN,
typename OUT>
108 bool convert( Process & p,
const std::string & fname, Finder & f )
111 std::string fmt = f.format();
112 Reader<carto::VolumeRef<IN> > r( fname );
113 carto::VolumeRef<IN> data;
114 r.read( data, 0, &fmt );
117 cc.
data.reallocate( data.getSizeX(), data.getSizeY(),
118 data.getSizeZ(), data.getSizeT() );
120 cc.
data = carto::VolumeRef<OUT>( data.getSizeX(), data.getSizeY(),
121 data.getSizeZ(), data.getSizeT() );
122 carto::ShallowConverter<carto::VolumeRef<IN>, carto::VolumeRef<OUT> > conv;
123 conv.convert( data, cc.
data );
124 cc.
data.copyHeaderFrom( data.header() );
134 template <
typename T>
135 void readConvert(
const std::string & fname, carto::VolumeRef<T> &
object,
bool doit =
true )
virtual ~VolumeConvertReader()
VolumeConvertReader(carto::VolumeRef< T > &vol)
carto::VolumeRef< T > & data
bool convert(Process &p, const std::string &fname, Finder &f)
void readChannel(const std::string &fname, T &object, int8_t channel, bool doit=true)
Read a given channel A conversion is done between the channel type and the object type if necessaey.
void read(const std::string &fname, T &object, bool doit=true)
Basic read Provided object type must be the same as disk data type.
void write(const T &object, const std::string &fname, bool doit=true)
Basic write.
void readConvert(const std::string &fname, carto::VolumeRef< T > &object, bool doit=true)