34 #ifndef AIMS_IO_BASEFORMATS_VOLUME_D_H 
   35 #define AIMS_IO_BASEFORMATS_VOLUME_D_H 
   61                            const carto::AllocatorContext & context, 
 
   65     r.
read( vol, context, options );
 
   90                                const carto::AllocatorContext & context, 
 
   94     r.
read( vol,context, options );
 
  101   template <
typename T>
 
  104                                const carto::AllocatorContext & , 
 
  114     int ascii = 
false, bswap = 
false;
 
  118     std::ifstream is( filename.c_str() );
 
  121       ascii ? 
"ascii" : 
"binar", bswap );
 
  123       ascii ? 
"ascii" : 
"binar", bswap );
 
  127     uint32_t nonZeroElementCount = 0U;
 
  131     itemR1->
read( is, size1 );
 
  132     itemR1->
read( is, size2 );
 
  133     itemR1->
read( is, nonZeroElementCount );
 
  135     std::streampos p = is.tellg(), e;
 
  136     is.seekg( 0, std::ios_base::end );
 
  138     is.seekg( p, std::ios_base::beg );
 
  139     if( nonZeroElementCount > size1 * size2
 
  140         || nonZeroElementCount * 16 != e - p )
 
  142         "Wrong format or corrupted .imas format", filename );
 
  147     for ( k = 0; k < nonZeroElementCount; k++ )
 
  149       itemR1->
read( is, s1 );
 
  150       itemR1->
read( is, s2 );
 
  151       itemR2->
read( is, value );
 
  152       vol->
at( s2, s1 ) = value;
 
  179           ascii = (bool) aso->getScalar();
 
  186     std::ofstream os( filename.c_str() );
 
  189       ascii ? 
"ascii" : 
"binar", 
false );
 
  191       ascii ? 
"ascii" : 
"binar", 
false );
 
  193     unsigned x, y, nx = obj.
dimX(), ny = obj.
dimY();
 
  196     for( y=0; y<ny; ++y )
 
  198       const T* buf = &obj( 0, y );
 
  199       long inc = &obj( 1, y ) - buf;
 
  201       for( x=0; x<nx; ++x, buf+=inc )
 
  208     itemW1->
write( os, count ); 
 
  210     for( y=0; y<ny; ++y )
 
  212       const T* buf = &obj( 0, y );
 
  213       long inc = &obj( 1, y ) - buf;
 
  215       for( x=0; x<nx; ++x, buf+=inc )
 
  218           itemW1->
write( os, y );
 
  219           itemW1->
write( os, x );
 
  220           itemW2->
write( os, *buf );
 
  245                            const carto::AllocatorContext & context,
 
  249     std::vector<std::string> excluded;
 
  254       if( options->getProperty( 
"aims_excluded_formats", excluded ) )
 
  256         std::vector<std::string>::const_iterator i, e = excluded.end();
 
  257         for( i=excluded.begin(); i!=e; ++i )
 
  258           if( *i == 
"SOMAIO_VOLUMES" )
 
  266     std::vector<std::string>::iterator ei;
 
  269     excluded.push_back( 
"SOMAIO_VOLUMES" );
 
  270     options->setProperty( 
"aims_excluded_formats", excluded );
 
  272     carto::Reader<carto::Volume<T> > r( filename );
 
  273     r.setAllocatorContext( context );
 
  274     r.setOptions( options );
 
  285     options = r.options();
 
  286     if( options->getProperty( 
"aims_excluded_formats", excluded ) )
 
  288       ei = std::find( excluded.begin(),
 
  292       if (ei != excluded.end()) {
 
  293         excluded.erase( ei );
 
  294         options->setProperty( 
"aims_excluded_formats", excluded );
 
  297       r.setOptions( options );
 
  306                      const carto::AllocatorContext & context, 
 
  310     std::vector<std::string> excluded;
 
  315       if( options->getProperty( 
"aims_excluded_formats", excluded ) )
 
  317         std::vector<std::string>::const_iterator i, e = excluded.end();
 
  318         for( i=excluded.begin(); i!=e; ++i )
 
  319           if( *i == 
"SOMAIO_VOLUMES" )
 
  324     excluded.push_back( 
"SOMAIO_VOLUMES" );
 
  325     options->setProperty( 
"aims_excluded_formats", excluded );
 
  327     carto::Reader<carto::Volume<T> > r( filename );
 
  328     r.setAllocatorContext( context );
 
  329     r.setOptions( options );
 
  343     std::vector<std::string> excluded;
 
  348       if( options->getProperty( 
"aims_excluded_formats", excluded ) )
 
  350         std::vector<std::string>::const_iterator i, e = excluded.end();
 
  351         for( i=excluded.begin(); i!=e; ++i )
 
  352           if( *i == 
"SOMAIO_VOLUMES" )
 
  357     excluded.push_back( 
"SOMAIO_VOLUMES" );
 
  358     options->setProperty( 
"aims_excluded_formats", excluded );
 
  360     carto::Writer<carto::Volume<T> > w( filename );
 
  361     return w.write( *vol.
volume(), options );
 
void setHeader(aims::Header *hdr)
carto::VolumeRef< T > & volume()
const aims::Header * header() const
Default low-levels readers.
virtual ItemReader< T > * reader(const std::string &openmode="binar", bool bswap=false) const
Default low-levels writers.
virtual ItemWriter< T > * writer(const std::string &openmode="binar", bool bswap=false) const
void read(AimsData< T > &thing, const carto::AllocatorContext &context, carto::Object options)
Low-level "small item" reader, used by higher-level file readers.
virtual void read(std::istream &is, T &item) const
Low-level "small item" writer, used by higher-level file readers.
virtual void write(std::ostream &os, const T &item) const
The template class for SPM read operation.
void read(AimsData< T > &thing, const carto::AllocatorContext &context, carto::Object options)
Read the data with "name" file name from disk.
The template class for SPM write operation.
void write(const AimsData< T > &thing)
Write the data with "name" file name to disk.
virtual bool getProperty(const std::string &, Object &) const
void fill(const T &value)
const T & at(long x, long y=0, long z=0, long t=0) const
The class for EcatSino data write operation.