cartodata  5.1.2
volumeproxy.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 #ifndef CARTODATA_VOLUME_VOLUMEPROXY_H
35 #define CARTODATA_VOLUME_VOLUMEPROXY_H
36 
37 
39 
40 
41 namespace carto
42 {
43 
44 
48  template < typename T >
49  class VolumeProxy : public Headered
50  {
51 
52  public:
53 
54  explicit VolumeProxy( int sizeX = 1, int sizeY = 1, int sizeZ = 1,
55  int sizeT = 1 );
56  explicit VolumeProxy( const std::vector<int> & size );
57  VolumeProxy( const VolumeProxy< T >& other );
58  virtual ~VolumeProxy();
59 
60  int getSizeX() const;
61  int getSizeY() const;
62  int getSizeZ() const;
63  int getSizeT() const;
65  std::vector<int> getSize() const;
68  std::vector<float> getVoxelSize() const;
69  void setVoxelSize( float vx, float vy = 1., float vz = 1., float vt = 1. );
70  void setVoxelSize( const std::vector<float> & vs );
71 
73 
77  virtual void copyHeaderFrom( const PropertySet & other );
78  virtual void copyHeaderFrom( const Object & other );
79 
80  protected:
81 
82  std::vector<int> _size;
83 
84  };
85 
86 
87  template < typename T >
88  inline
90  {
91 
92  return _size[0];
93 
94  }
95 
96 
97  template < typename T >
98  inline
100  {
101 
102  return _size[1];
103 
104  }
105 
106 
107  template < typename T >
108  inline
110  {
111 
112  return _size[2];
113 
114  }
115 
116 
117  template < typename T >
118  inline
120  {
121 
122  return _size[3];
123 
124  }
125 
126 
127  template < typename T >
128  inline
129  std::vector<int> VolumeProxy< T >::getSize() const
130  {
131 
132  return _size;
133 
134  }
135 
136 
137  template < typename T >
138  inline
140  {
141  copyHeaderFrom( Object::reference( other ) );
142  }
143 
144 
145  // instanciations
146 
147  extern template class VolumeProxy<int8_t>;
148  extern template class VolumeProxy<uint8_t>;
149  // ### remove after everything has been moved to intN_t/uintN_t
150 #if !defined(__sun__) || !defined(_CHAR_IS_SIGNED)
151  extern template class VolumeProxy<char>;
152 #endif
153  extern template class VolumeProxy<int16_t>;
154  extern template class VolumeProxy<uint16_t>;
155  extern template class VolumeProxy<int32_t>;
156  extern template class VolumeProxy<uint32_t>;
157  extern template class VolumeProxy<long>;
158  extern template class VolumeProxy<unsigned long>;
159  extern template class VolumeProxy<float>;
160  extern template class VolumeProxy<double>;
161  extern template class VolumeProxy<cfloat>;
162  extern template class VolumeProxy<cdouble>;
163 }
164 
165 
166 #endif
Object reference(Object &value)
VolumeProxy is the base class for volumes.
Definition: volumeproxy.h:50
VolumeProxy(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1)
Definition: volumeproxy_d.h:46
int getSizeY() const
Definition: volumeproxy.h:99
VolumeProxy< T > & operator=(const VolumeProxy< T > &other)
std::vector< float > getVoxelSize() const
get the voxel size from the header, with 4 values defaulting to 1.mm if not present
int getSizeX() const
Definition: volumeproxy.h:89
std::vector< int > getSize() const
get the 4 dimensions in a vector
Definition: volumeproxy.h:129
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
std::vector< int > _size
Definition: volumeproxy.h:82
virtual ~VolumeProxy()
int getSizeZ() const
Definition: volumeproxy.h:109
int getSizeT() const
Definition: volumeproxy.h:119
virtual void copyHeaderFrom(const PropertySet &other)
copy properties from other to this, avoiding forbidden properties like size.
Definition: volumeproxy.h:139