34 #ifndef CARTODATA_VOLUME_VOLUMEPROXY_D_H
35 #define CARTODATA_VOLUME_VOLUMEPROXY_D_H
45 template <
typename T >
64 template <
typename T >
69 if(
_size.size() < 4 )
82 template <
typename T >
89 if(
header().hasProperty(
"volume_dimension" ) )
91 if(
header().hasProperty(
"sizeX" ) )
93 if(
header().hasProperty(
"sizeY" ) )
95 if(
header().hasProperty(
"sizeZ" ) )
97 if(
header().hasProperty(
"sizeT" ) )
109 template <
typename T >
115 template <
typename T >
126 if( header().hasProperty(
"sizeX" ) )
127 header().changeBuiltinProperty(
"sizeX", _size[0] );
128 if( header().hasProperty(
"sizeY" ) )
129 header().changeBuiltinProperty(
"sizeY", _size[1] );
130 if( header().hasProperty(
"sizeZ" ) )
131 header().changeBuiltinProperty(
"sizeZ", _size[2] );
132 if( header().hasProperty(
"sizeT" ) )
133 header().changeBuiltinProperty(
"sizeT", _size[3] );
140 template <
typename T >
144 size_t i, n = _size.size();
145 std::vector<float> voxelsize( n, 1. );
149 vso = header().getProperty(
"voxel_size" );
150 if( vso->size() < n )
155 voxelsize[i] = float( vso->getArrayItem(i)->getScalar() );
157 catch( std::exception & )
161 catch( std::exception & )
170 template <
typename T>
173 std::vector<float> vs( 4 );
182 template <
typename T>
185 header().setProperty(
"voxel_size", vs );
189 template <
typename T >
195 std::set<std::string> forbidden;
196 forbidden.insert(
"sizeX" );
197 forbidden.insert(
"sizeY" );
198 forbidden.insert(
"sizeZ" );
199 forbidden.insert(
"sizeT" );
200 forbidden.insert(
"volume_dimension" );
204 Object it = other->objectIterator();
205 while( it->isValid() )
207 if( forbidden.find( it->key() ) == forbidden.end() )
void setProperty(const std::string &, const T &)
virtual bool removeProperty(const std::string &key)
void addBuiltinProperty(const std::string &, T &)
VolumeProxy is the base class for volumes.
VolumeProxy(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1)
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
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
virtual void copyHeaderFrom(const PropertySet &other)
copy properties from other to this, avoiding forbidden properties like size.