34 #ifndef AIMS_DATA_CARTODATAVOLUME_H 35 #define AIMS_DATA_CARTODATAVOLUME_H 72 const_iterator
begin()
const;
74 const_iterator
end()
const;
77 AimsData(
int dimx = 1,
int dimy = 1,
int dimz = 1,
int dimt = 1,
79 AimsData(
int dimx,
int dimy,
int dimz,
int dimt,
80 int borderw,
const carto::AllocatorContext & al );
98 const carto::AllocatorContext &
allocator()
const;
111 void setSizeXYZT(
float sizex = 1.0f,
float sizey = 1.0f,
112 float sizez = 1.0f,
float sizet = 1.0f );
119 reference
operator () ( size_type x = 0, size_type y = 0,
120 size_type z = 0, size_type t = 0 );
121 const_reference
operator () ( size_type x = 0, size_type y = 0,
122 size_type z = 0, size_type t = 0 )
const;
138 T
minIndex(
int* x,
int* y,
int* z,
int* t )
const;
139 T
maxIndex(
int* x,
int* y,
int* z,
int* t )
const;
154 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES 172 template <
typename T>
180 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES 221 if( !vol->refVolume().isNull() )
222 if (vol->refVolume()->allocatorContext().isAllocated()) {
225 const std::vector<int> vborders = vol->getBorders();
229 std::vector<int>::const_iterator vbordersend = (vborders.size() > 6
230 ? vborders.begin() + 6
232 if(vborders.begin() != vbordersend) {
233 std::vector<int>::const_iterator minit = std::min_element(vborders.begin(),
235 return (minit == vbordersend ? 0 : *minit);
244 template <
typename T>
251 template <
typename T>
262 return &*_volume->begin();
270 return &*_volume->begin();
280 return &_volume->at( _volume->getSizeX() - 1, _volume->getSizeY() - 1,
281 _volume->getSizeZ() - 1, _volume->getSizeT() - 1 ) + 1;
291 return &_volume->at( _volume->getSizeX() - 1, _volume->getSizeY() - 1,
292 _volume->getSizeZ() - 1, _volume->getSizeT() - 1 ) + 1;
300 return _volume->begin() == _volume->end();
308 _oLine = &_volume->at( 0, 1 ) - &_volume->at( 0 );
310 _oSlice = &_volume->at( 0, 0, 1 ) - &_volume->at( 0 );
312 _oVolume = &_volume->at( 0, 0, 0, 1 ) - &_volume->at( 0 );
314 - &_volume->at( 0, 0,
dimZ() );
322 _volume( new
carto::Volume<T>( dimx + borderw * 2, dimy + borderw * 2,
323 dimz + borderw * 2, dimt ) ),
336 template <
typename T >
339 int borderw,
const carto::AllocatorContext & al )
341 _volume( new
carto::Volume<T>( dimx + borderw * 2, dimy + borderw * 2,
342 dimz + borderw * 2, dimt, al ) ),
355 template <
typename T >
360 _volume( other._volume ),
368 template <
typename T >
372 borderw ), _volume( new
carto::Volume<T>( other.
dimX() + borderw * 2,
373 other.
dimY() + borderw * 2, other.
dimZ() + borderw * 2, other.
dimT() ) ),
376 _volume->copyHeaderFrom( other.
volume()->header() );
386 for ( t = 0; t < tm; t++ )
387 for ( z = 0; z < zm; z++ )
388 for ( y = 0; y < ym; y++ )
389 for ( x = 0; x < xm; x++ )
390 (*
this)( x, y, z, t ) = other( x, y, z, t );
397 template <
typename T >
405 template <
typename T >
421 template <
typename T >
425 if( _volume.
get() == vol.get() )
428 _setBorder( vol->getSizeX(), vol->getSizeY(), vol->getSizeZ(),
439 template <
typename T >
443 if ( &other ==
this )
449 _volume = other._volume;
457 template <
typename T >
464 for ( t = 0; t < tm; t++ )
466 for ( z = 0; z < zm; z++ )
468 for ( y = 0; y < ym; y++ )
470 for ( x = 0; x < xm; x++ )
502 return _volume->getSizeX();
510 return _volume->getSizeY();
518 return _volume->getSizeZ();
526 return _volume->getSizeT();
530 template <
typename T >
542 if( !vs.
isNull() && vs->size() >= 1 )
543 return (
float) vs->getArrayItem( 0 )->getScalar();
552 template <
typename T >
564 if( !vs.
isNull() && vs->size() >= 2 )
565 return (
float) vs->getArrayItem( 1 )->getScalar();
574 template <
typename T >
586 if( !vs.
isNull() && vs->size() >= 3 )
587 return (
float) vs->getArrayItem( 2 )->getScalar();
596 template <
typename T >
608 if( !vs.
isNull() && vs->size() >= 4 )
609 return (
float) vs->getArrayItem( 3 )->getScalar();
618 template <
typename T >
631 if( vs->size() >= 1 )
636 std::vector<float> vs( 4, 1. );
644 template <
typename T >
653 std::vector<float> vs( 4, 1. );
659 if( vso->size() >= 2 )
666 if( vso->size() >= 1 )
667 vs[0] = vso->getArrayItem(0)->getScalar();
680 template <
typename T >
689 std::vector<float> vs( 4, 1. );
695 if( vso->size() >= 3 )
704 for( i=0, it=vso->objectIterator();
705 it->isValid() && i<3; ++i, it->next() )
706 vs[i] = it->currentValue()->getScalar();
719 template <
typename T >
728 std::vector<float> vs( 4, 1. );
734 if( vso->size() >= 4 )
743 for( i=0, it=vso->objectIterator();
744 it->isValid() && i<4; ++i, it->next() )
745 vs[i] = it->currentValue()->getScalar();
758 template <
typename T >
768 std::vector<float> vs( 4 );
778 template <
typename T >
787 std::vector<float> vs( 4 );
788 vs[0] = other.
sizeX();
789 vs[1] = other.
sizeY();
790 vs[2] = other.
sizeZ();
791 vs[3] = other.
sizeT();
797 template <
typename T >
801 return _volume->allocatorContext();
805 template <
typename T >
813 template <
typename T >
860 template <
typename T >
865 return *(
begin() + n );
869 template <
typename T >
874 return *(
begin() + n );
878 template <
typename T >
884 return (*_volume)( x, y, z, t );
888 template <
typename T >
895 return (*_volume)( x, y, z, t );
899 template <
typename T >
904 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
908 template <
typename T >
913 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
917 template <
typename T >
922 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
926 template <
typename T >
931 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
935 template <
typename T >
940 return (*
this)( pt[0], pt[1], pt[2] );
944 template <
typename T >
949 return (*
this)( pt[0], pt[1], pt[2] );
953 template <
typename T >
958 return (*
this)( pt[0], pt[1], pt[2] );
962 template <
typename T >
967 return (*
this)( pt[0], pt[1], pt[2] );
971 template <
typename T >
976 return (*
this)( pt[0], pt[1] );
980 template <
typename T >
985 return (*
this)( pt[0], pt[1] );
989 template <
typename T >
994 return (*
this)( pt[0], pt[1] );
998 template <
typename T >
1003 return (*
this)( pt[0], pt[1] );
1007 template <
typename T >
1015 template <
typename T >
1023 template <
typename T >
1027 int minxind = 0,minyind = 0,minzind = 0,mintind = 0;
1034 for ( t = 0; t < tm; t++ )
1036 for ( z = 0; z < zm; z++ )
1038 for ( y = 0; y < ym; y++ )
1040 for ( x = 0; x < xm; x++ )
1071 template <
typename T >
1075 int maxxind = 0,maxyind = 0,maxzind = 0,maxtind = 0;
1082 for ( t = 0; t < tm; t++ )
1084 for ( z = 0; z < zm; z++ )
1086 for ( y = 0; y < ym; y++ )
1088 for ( x = 0; x < xm; x++ )
1119 template <
typename T >
1128 long of = &_volume->at( 0, 0, 0, 0 ) - &bigger->
at( 0, 0, 0, 0 ),
1129 op = &_volume->at( 0, 1, 0, 0 ) - &_volume->at( xm, 0, 0, 0 ),
1130 ol = &_volume->at( 0, 0, 1, 0 ) - &_volume->at( 0, ym, 0, 0 );
1132 for ( t = 0; t < tm; t++ )
1134 it = &bigger->
at( 0, 0, 0, t );
1135 for ( x = 0; x < of; x++ )
1137 for ( z = 0; z < zm; z++ )
1139 for ( y = 0; y < ym; y++ )
1142 for ( x = 0; x < op; x++ )
1145 for ( x = 0; x < ol; x++ )
1148 for ( x = 0; x < of - op - ol; x++ )
1154 template<
typename T>
1158 if( !_volume->refVolume().
isNull() )
1162 _volume->refVolume()->getSizeX(), _volume->refVolume()->getSizeY(),
1163 _volume->refVolume()->getSizeZ(), _volume->refVolume()->getSizeT(),
1164 _volume->refVolume()->allocatorContext(),
1165 _volume->refVolume()->allocatorContext().isAllocated() ) );
1167 if( _volume->refVolume()->allocatorContext().isAllocated() )
1168 transfer( _volume->refVolume(), rvol );
1172 _volume->getSizeY(),
1173 _volume->getSizeZ(),
1174 _volume->getSizeT() ) ) );
1175 dat._volume->header().copyProperties(
1188 template <
typename T >
1193 dimZ() == 1 && other.
dimZ() == 1 );
1198 for (
long y = 0; y < other.
dimY(); y++ )
1199 for (
long x = 0; x <
dimX(); x++ )
1201 prod( x, y ) = T( 0 );
1202 for (
long k = 0; k <
dimY(); k++ )
1203 prod( x, y ) += (*this)( x, k ) * other( k, y );
1210 template <
typename T >
1231 for ( t = 0; t < tm; t++ )
1232 for ( z = 0; z < zm; z++ )
1233 for ( y = 0; y < ym; y++ )
1234 for ( x = 0; x < xm; x++ )
1235 tmp( y, x, z, t ) = (*this)( x, y, z, t );
1242 template <
typename T >
1253 template <
typename T >
1263 template <
typename T >
1275 #define ForEach4d( thing , x , y , z , t) \ 1276 for ( t = 0; t < thing.dimT(); t++ ) \ 1277 for ( z = 0; z < thing.dimZ(); z++ ) \ 1278 for ( y = 0; y < thing.dimY(); y++ ) \ 1279 for ( x = 0; x < thing.dimX(); x++ ) 1281 #define ForEach3d( thing , x , y , z) \ 1282 for ( z = 0; z < thing.dimZ(); z++ ) \ 1283 for ( y = 0; y < thing.dimY(); y++ ) \ 1284 for ( x = 0; x < thing.dimX(); x++ ) 1286 #define ForEach2d( thing , x , y) \ 1287 for ( y = 0; y < thing.dimY(); y++ ) \ 1288 for ( x = 0; x < thing.dimX(); x++ ) 1290 #define ForEach1d( thing , x) \ 1291 for ( x = 0; x < thing.dimX(); x++ ) 1294 #define ForEach4dp( thing , x , y , z , t) \ 1295 for ( t = 0; t < thing->dimT(); t++ ) \ 1296 for ( z = 0; z < thing->dimZ(); z++ ) \ 1297 for ( y = 0; y < thing->dimY(); y++ ) \ 1298 for ( x = 0; x < thing->dimX(); x++ ) 1300 #define ForEach3dp( thing , x , y , z) \ 1301 for ( z = 0; z < thing->dimZ(); z++ ) \ 1302 for ( y = 0; y < thing->dimY(); y++ ) \ 1303 for ( x = 0; x < thing->dimX(); x++ ) 1305 #define ForEach2dp( thing , x , y) \ 1306 for ( y = 0; y < thing->dimY(); y++ ) \ 1307 for ( x = 0; x < thing->dimX(); x++ ) 1309 #define ForEach1dp( thing , x) \ 1310 for ( x = 0; x < thing->dimX(); x++ ) 1319 extern template class VolumeProxy<DtiTensor*>;
1320 extern template class Volume<DtiTensor*>;
int oLineBetweenSlice() const
Number of lines between 2 consecutive slices.
void setSizeT(float sizet)
T & reference
basic reference
reference operator()(size_type x=0, size_type y=0, size_type z=0, size_type t=0)
AimsData< T > & transpose()
const T * const_iterator
basic constant iterator
virtual bool getProperty(const std::string &, Object &) const
T **** pointer4d
4D-pointer
AimsData(int dimx=1, int dimy=1, int dimz=1, int dimt=1, int borderw=0)
int _oSlice
Length of a slice.
int oPointBetweenLine() const
Offset between the end of a line and the start of the consecutive line.
void _setBorder(int dimx, int dimy, int dimz, int width)
Function that sets up all protected datas.
static int borderWidth(carto::rc_ptr< carto::Volume< T > > vol)
static std::string dataType()
T * iterator
basic iterator
const std::vector< int > & borders() const
Sizes of the border.
The base class to manage borders on data containers.
ptrdiff_t difference_type
difference type
static std::string objectType()
The class for EcatSino data write operation.
size_t size_type
size of the basic type
AimsData< T > operator+(const AimsData< T > &firstThing, const AimsData< T > &secondThing)
AimsData< T > operator-(const AimsData< T > &firstThing, const AimsData< T > &secondThing)
static Object reference(T &value)
void setSizeX(float sizex)
virtual bool removeProperty(const std::string &)
void setSizeY(float sizey)
void setHeader(aims::Header *hdr)
int _oPointBetweenLine
Offset between two consecutive lines.
static std::string name()
const T & at(long x, long y=0, long z=0, long t=0) const
int _oSliceBetweenVolume
Offset between two consecutive volumes.
void transfer(const Volume< T > &src, Volume< T > &dst)
int _oFirstPoint
Offset up to first point.
void fillBorder(const T &val)
carto::Object getObjectHeader(AimsData< T > &obj)
virtual void clearProperties()
AimsData< T > & operator=(carto::rc_ptr< carto::Volume< T > > vol)
AimsData< T > clone() const
T minIndex(int *x, int *y, int *z, int *t) const
const aims::Header * header() const
Volume< T > deepcopy(const Volume< T > &src)
AimsData< T > operator*(const AimsData< T > &firstThing, float scale)
AimsData< T > cross(const AimsData< T > &other)
int _oLineBetweenSlice
Offset between two consecutive slices.
Border(int dimx, int dimy, int dimz, int width=0)
The constructor precalculates offsets to speed-up access to data during loops.
carto::rc_ptr< carto::Volume< T > > volume()
int _oVolume
Length of a volume.
T maxIndex(int *x, int *y, int *z, int *t) const
const carto::AllocatorContext & allocator() const
int oSliceBetweenVolume() const
Number of slices between 2 consecutive volumes.
int _oLine
Length of a line.
virtual void setProperty(const std::string &, Object)
void setSizeXYZT(float sizex=1.0f, float sizey=1.0f, float sizez=1.0f, float sizet=1.0f)
const T & const_reference
basic constant reference
virtual bool hasProperty(const std::string &) const
void setSizeZ(float sizez)
int oFirstPoint() const
Offset from the start of the allocated memory to the first point.
reference operator[](size_type n)
int borderWidth() const
Usefull offsets for A.I.M.S.