38 #ifndef AIMS_IO_GENESISR_H
39 #define AIMS_IO_GENESISR_H
61 void read(
AimsData<T> & thing,
const carto::AllocatorContext & context,
69 inline GenesisReader<T> &
79 const carto::AllocatorContext & context,
87 catch( std::exception & e )
96 ( std::string(
"data type / reader type mismatch : file is " )
99 int frame = -1, border = 0;
100 options->getProperty(
"frame", frame );
101 options->getProperty(
"border", border );
106 if( frame >= hdr->
dimT() )
109 throw std::domain_error(
"frame higher than file dimT" );
121 carto::AllocatorContext
122 ac( context.accessMode(),
124 (
new carto::FileDataSource( _name, 0, carto::DataSource::Read ) ),
125 false, context.useFactor() );
139 std::string::size_type pos = _name.rfind( s );
141 if( pos == std::string::npos )
144 dirname = _name.substr( 0, pos );
147 std::set<std::string> names = dir.
files();
148 std::set<std::string>::iterator in, en = names.end();
150 int z, t, ss = 0, es = 0;
151 std::vector<bool> reads( data.
dimT() * data.
dimZ() );
154 for( in=names.begin(); in!=en; ++in )
156 name = dirname + s + *in;
164 std::ifstream is( name.c_str(),
165 std::ios::in | std::ios::binary );
168 is.unsetf( std::ios::skipws );
175 "compressed data", name );
181 if( (z >= 0) && (z < data.
dimZ()) )
183 if( reads[ t*data.
dimZ() + z ] )
185 std::cerr <<
"warning: slice z=" << z <<
", t=" << t
186 <<
" already read" << std::endl;
190 std::cerr <<
"........reading slice z=" << z <<
", t=" << t << std::endl;
191 reads[ t*data.
dimZ() + z ] =
true;
195 for(
int y=0; y<data.
dimY(); ++y )
196 ir->
read( is, &data(0,y,z,t), data.
dimX() );
202 catch( std::exception & )
204 std::cout << name <<
" not part of genesis volume\n";
209 for( t=0; t<data.
dimT(); ++t )
210 for( z=0; z<data.
dimZ(); ++z )
211 if( !reads[ t*data.
dimZ() + z ] )
212 std::cerr <<
"warning: missing slice " << z <<
", t=" << t
void setSizeY(float sizey)
void setSizeT(float sizet)
void setHeader(aims::Header *hdr)
void setSizeZ(float sizez)
void setSizeX(float sizex)
Default low-levels readers.
virtual ItemReader< T > * reader(const std::string &openmode="binar", bool bswap=false) const
void read(AimsData< T > &thing, const carto::AllocatorContext &context, carto::Object options)
GenesisReader(const std::string &name)
Low-level "small item" reader, used by higher-level file readers.
virtual void read(std::istream &is, T &item) const
std::set< std::string > files() const
virtual bool getProperty(const std::string &, Object &) const
static void launchErrnoExcept(const std::string &filename="")
The class for EcatSino data write operation.
GenesisReader< T > & operator>>(GenesisReader< T > &reader, AimsData< T > &thing)