aimsdata 6.0.0
Neuroimaging data handling
baseFormats_bucket_d.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34/*
35 * Data reader class
36 */
37#ifndef AIMS_IO_BASEFORMATS_BUCKET_D_H
38#define AIMS_IO_BASEFORMATS_BUCKET_D_H
39
41#include <aims/io/bckR.h>
42#include <aims/io/bckW.h>
43#include <aims/io/bckMapR.h>
44#include <aims/io/bckMapW.h>
45
46
47namespace aims
48{
49
50 template<class T>
51 bool BckFormat<T>::read( const std::string & filename, AimsBucket<T> & obj,
52 const carto::AllocatorContext & /*context*/,
53 carto::Object options )
54 {
55 BckReader<T> r( filename );
56 int frame = -1;
57 options->getProperty( "frame", frame );
58 r.read( obj, frame );
59 return( true );
60 }
61
62 template<class T>
63 bool BckFormat<T>::write( const std::string & filename,
64 const AimsBucket<T> & obj, carto::Object options
65 )
66 {
67 bool ascii = false;
68 try
69 {
70 if( !options.isNull() )
71 {
72 carto::Object aso = options->getProperty( "ascii" );
73 if( !aso.isNull() )
74 ascii = (bool) aso->getScalar();
75 }
76 }
77 catch( ... )
78 {
79 }
80 BckWriter<T> w( filename, ascii );
81 w.write( obj );
82 return( true );
83 }
84
85 // BCK format read as BucketMap
86
87 template<class T>
88 bool BckMapFormat<T>::read( const std::string & filename,
89 BucketMap<T> & obj,
90 const carto::AllocatorContext & /*context*/,
91 carto::Object options )
92 {
93 BckMapReader<T> r( filename );
94 int frame = -1;
95 options->getProperty( "frame", frame );
96 r.read( obj, frame );
97 return( true );
98 }
99
100 template<class T>
101 bool BckMapFormat<T>::write( const std::string & filename,
102 const BucketMap<T> & obj, carto::Object options
103 )
104 {
105 bool ascii = false;
106 try
107 {
108 if( !options.isNull() )
109 {
110 carto::Object aso = options->getProperty( "ascii" );
111 if( !aso.isNull() )
112 ascii = (bool) aso->getScalar();
113 }
114 }
115 catch( ... )
116 {
117 }
118 BckMapWriter<T> w( filename, ascii );
119 w.write( obj );
120 return( true );
121 }
122
123}
124
125
126#endif
The bucket base class to manage packages of points associated to their value during time.
Definition bucket.h:70
virtual bool write(const std::string &filename, const AimsBucket< T > &vol, carto::Object options=carto::none())
virtual bool read(const std::string &filename, AimsBucket< T > &obj, const carto::AllocatorContext &context, carto::Object options)
virtual bool write(const std::string &filename, const BucketMap< T > &vol, carto::Object options=carto::none())
virtual bool read(const std::string &filename, BucketMap< T > &obj, const carto::AllocatorContext &context, carto::Object options)
BucketMap objects can be read / written by BckMapReader / BckMapWriter, these IO classes operate on t...
Definition bckMapR.h:56
void read(BucketMap< T > &thing, int frame=-1)
Definition bckMapR.h:72
BucketMap objects can be read / written by BckMapReader / BckMapWriter, these IO classes operate on t...
Definition bckMapW.h:53
void write(const BucketMap< T > &thing)
Definition bckMapW.h:81
void read(AimsBucket< T > &thing, int frame=-1)
Definition bckR.h:68
void write(const AimsBucket< T > &thing)
Definition bckW.h:67
An alternate, ordered, representation for buckets (voxels lists).
Definition bucketMap.h:99
bool isNull() const
The class for EcatSino data write operation.