37 #ifndef AIMS_IO_FDFR_H
38 #define AIMS_IO_FDFR_H
53 template<
class T >
class FdfReader;
74 void readFrame(
AimsData< T >& thing,
const std::string & file,
80 template<
class T >
inline
89 template<
class T >
inline
91 const carto::AllocatorContext & context,
95 options->getProperty(
"border", borderWidth );
98 std::unique_ptr<aims::FdfHeader> hdr
102 int rank = (int)hdr->getProperty(
"rank" )->getScalar();
105 int bits_allocated = (int)hdr->getProperty(
"bits_allocated" )->getScalar();
106 if ( ( bits_allocated / 8 ) > (int)
sizeof( T ) )
112 std::vector<std::string> files;
115 files = hdr->inputFilenames();
122 carto::AllocatorContext
123 cont( context.accessMode(),
125 (
new carto::FileDataSource
126 ( _name, 0, carto::DataSource::Read ) ),
false,
127 context.useFactor() );
129 AimsData< T > data( hdr->dimX(), hdr->dimY(), hdr->dimZ(), hdr->dimT(),
131 data.
setSizeXYZT( hdr->sizeX(), hdr->sizeY(), hdr->sizeZ(), hdr->sizeT() );
134 for(
uint slice=0; slice < files.size(); slice++ ) {
144 template<
class T >
inline
146 const std::string & filename,
uint slice,
149 std::vector< int > dims;
151 int bits_allocated = (int)hdr->
getProperty(
"bits_allocated" )->getScalar();
152 int byte_swapping = (int)hdr->
getProperty(
"byte_swapping" )->getScalar();
153 int rank = (int)hdr->
getProperty(
"rank" )->getScalar();
162 uint pixels_number = 1;
164 for(
int dim = 0; dim < rank; dim++ )
166 pixels_number *= dims[ dim ];
169 std::ifstream inFile(filename.c_str(), std::ios::in | std::ios::binary);
178 int zstart = 0, zend = thing.
dimZ();
179 inFile.seekg (0, std::ios::end);
180 long int fileSize = inFile.tellg();
181 size_t dataPosition = fileSize - (pixels_number * ( bits_allocated / 8 ) );
182 inFile.seekg( dataPosition );
184 DefaultItemReader<T> itemr;
186 = itemr.reader(
"binar",
189 if ((rank == 2) && (dims.size() > 2) && (dims[2] > 1)) {
194 for(
int t=0; t < thing.
dimT(); ++t )
195 for(
int z=zstart; z < zend; ++z ) {
196 for(
int y=0; y < thing.
dimY(); ++y )
198 ir->read( inFile, &thing(0, y, z, t), thing.
dimX() );
199 if( !inFile || inFile.eof() ) {
205 bool success = !inFile.bad();
const carto::AllocatorContext & allocator() const
void setHeader(aims::Header *hdr)
void setSizeXYZT(float sizex=1.0f, float sizey=1.0f, float sizez=1.0f, float sizet=1.0f)
FdfReader(const std::string &name)
void read(AimsData< T > &, const carto::AllocatorContext &context, carto::Object options)
static std::string dirname(const std::string &)
static std::string fileStat(const std::string &)
static std::string basename(const std::string &)
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)