cartodata 6.0.0
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
38#include <cartobase/object/headered.h>
39
40
41namespace 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 bool stopOnError = true );
79 virtual void copyHeaderFrom( const Object & other,
80 bool stopOnError = true );
81
82 protected:
83
84 std::vector<int> _size;
85
86 };
87
88
89 template < typename T >
90 inline
92 {
93
94 return _size[0];
95
96 }
97
98
99 template < typename T >
100 inline
102 {
103
104 return _size[1];
105
106 }
107
108
109 template < typename T >
110 inline
112 {
113
114 return _size[2];
115
116 }
117
118
119 template < typename T >
120 inline
122 {
123
124 return _size[3];
125
126 }
127
128
129 template < typename T >
130 inline
131 std::vector<int> VolumeProxy< T >::getSize() const
132 {
133
134 return _size;
135
136 }
137
138
139 template < typename T >
140 inline
142 bool stopOnError )
143 {
144 copyHeaderFrom( Object::reference( other), stopOnError );
145 }
146
147
148 // instanciations
149
150 extern template class VolumeProxy<int8_t>;
151 extern template class VolumeProxy<uint8_t>;
152 // ### remove after everything has been moved to intN_t/uintN_t
153#if !defined(__sun__) || !defined(_CHAR_IS_SIGNED)
154 extern template class VolumeProxy<char>;
155#endif
156 extern template class VolumeProxy<int16_t>;
157 extern template class VolumeProxy<uint16_t>;
158 extern template class VolumeProxy<int32_t>;
159 extern template class VolumeProxy<uint32_t>;
160 extern template class VolumeProxy<long>;
161 extern template class VolumeProxy<unsigned long>;
162 extern template class VolumeProxy<float>;
163 extern template class VolumeProxy<double>;
164 extern template class VolumeProxy<cfloat>;
165 extern template class VolumeProxy<cdouble>;
166}
167
168
169#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)
int getSizeY() const
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
virtual void copyHeaderFrom(const PropertySet &other, bool stopOnError=true)
copy properties from other to this, avoiding forbidden properties like size.
int getSizeX() const
Definition volumeproxy.h:91
std::vector< int > getSize() const
get the 4 dimensions in a vector
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
std::vector< int > _size
Definition volumeproxy.h:84
int getSizeZ() const
int getSizeT() const