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;
153 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES 171 template <
typename T>
179 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES 220 if( !vol->refVolume().isNull() )
221 if (vol->refVolume()->allocatorContext().isAllocated()) {
224 const std::vector<int> vborders = vol->getBorders();
228 std::vector<int>::const_iterator vbordersend = (vborders.size() > 6
229 ? vborders.begin() + 6
231 if(vborders.begin() != vbordersend) {
232 std::vector<int>::const_iterator minit = std::min_element(vborders.begin(),
234 return (minit == vbordersend ? 0 : *minit);
243 template <
typename T>
250 template <
typename T>
261 return &*_volume->begin();
269 return &*_volume->begin();
279 return &_volume->at( _volume->getSizeX() - 1, _volume->getSizeY() - 1,
280 _volume->getSizeZ() - 1, _volume->getSizeT() - 1 ) + 1;
290 return &_volume->at( _volume->getSizeX() - 1, _volume->getSizeY() - 1,
291 _volume->getSizeZ() - 1, _volume->getSizeT() - 1 ) + 1;
299 return _volume->begin() == _volume->end();
307 _volume( new
carto::Volume<T>( dimx + borderw * 2, dimy + borderw * 2,
308 dimz + borderw * 2, dimt ) ),
321 template <
typename T >
324 int borderw,
const carto::AllocatorContext & al )
326 _volume( new
carto::Volume<T>( dimx + borderw * 2, dimy + borderw * 2,
327 dimz + borderw * 2, dimt, al ) ),
340 template <
typename T >
345 _volume( other._volume ),
349 _oLine = &_volume->at( 0, 1 ) - &_volume->at( 0 );
351 _oSlice = &_volume->at( 0, 0, 1 ) - &_volume->at( 0 );
353 _oVolume = &_volume->at( 0, 0, 0, 1 ) - &_volume->at( 0 );
355 - &_volume->at( 0, 0,
dimZ() );
360 template <
typename T >
364 borderw ), _volume( new
carto::Volume<T>( other.
dimX() + borderw * 2,
365 other.
dimY() + borderw * 2, other.
dimZ() + borderw * 2, other.
dimT() ) ),
368 _volume->copyHeaderFrom( other.
volume()->header() );
379 for ( t = 0; t < tm; t++ )
380 for ( z = 0; z < zm; z++ )
381 for ( y = 0; y < ym; y++ )
382 for ( x = 0; x < xm; x++ )
383 (*
this)( x, y, z, t ) = other( x, y, z, t );
388 template <
typename T >
396 template <
typename T >
408 _oLine = &_volume->at( 0, 1 ) - &_volume->at( 0 );
410 _oSlice = &_volume->at( 0, 0, 1 ) - &_volume->at( 0 );
412 _oVolume = &_volume->at( 0, 0, 0, 1 ) - &_volume->at( 0 );
414 - &_volume->at( 0, 0,
dimZ() );
419 template <
typename T >
423 if( _volume.
get() == vol.get() )
429 vol->getSizeZ(), border );
439 template <
typename T >
443 if ( &other ==
this )
448 _volume = other._volume;
451 _oLine = &_volume->at( 0, 1 ) - &_volume->at( 0 );
453 _oSlice = &_volume->at( 0, 0, 1 ) - &_volume->at( 0 );
455 _oVolume = &_volume->at( 0, 0, 0, 1 ) - &_volume->at( 0 );
457 - &_volume->at( 0, 0,
dimZ() );
463 template <
typename T >
470 for ( t = 0; t < tm; t++ )
472 for ( z = 0; z < zm; z++ )
474 for ( y = 0; y < ym; y++ )
476 for ( x = 0; x < xm; x++ )
508 return _volume->getSizeX();
516 return _volume->getSizeY();
524 return _volume->getSizeZ();
532 return _volume->getSizeT();
536 template <
typename T >
548 if( !vs.
isNull() && vs->size() >= 1 )
549 return (
float) vs->getArrayItem( 0 )->getScalar();
558 template <
typename T >
570 if( !vs.
isNull() && vs->size() >= 2 )
571 return (
float) vs->getArrayItem( 1 )->getScalar();
580 template <
typename T >
592 if( !vs.
isNull() && vs->size() >= 3 )
593 return (
float) vs->getArrayItem( 2 )->getScalar();
602 template <
typename T >
614 if( !vs.
isNull() && vs->size() >= 4 )
615 return (
float) vs->getArrayItem( 3 )->getScalar();
624 template <
typename T >
637 if( vs->size() >= 1 )
642 std::vector<float> vs( 4, 1. );
650 template <
typename T >
659 std::vector<float> vs( 4, 1. );
665 if( vso->size() >= 2 )
672 if( vso->size() >= 1 )
673 vs[0] = vso->getArrayItem(0)->getScalar();
686 template <
typename T >
695 std::vector<float> vs( 4, 1. );
701 if( vso->size() >= 3 )
710 for( i=0, it=vso->objectIterator();
711 it->isValid() && i<3; ++i, it->next() )
712 vs[i] = it->currentValue()->getScalar();
725 template <
typename T >
734 std::vector<float> vs( 4, 1. );
740 if( vso->size() >= 4 )
749 for( i=0, it=vso->objectIterator();
750 it->isValid() && i<4; ++i, it->next() )
751 vs[i] = it->currentValue()->getScalar();
764 template <
typename T >
774 std::vector<float> vs( 4 );
784 template <
typename T >
793 std::vector<float> vs( 4 );
794 vs[0] = other.
sizeX();
795 vs[1] = other.
sizeY();
796 vs[2] = other.
sizeZ();
797 vs[3] = other.
sizeT();
803 template <
typename T >
807 return _volume->allocatorContext();
811 template <
typename T >
819 template <
typename T >
866 template <
typename T >
871 return *(
begin() + n );
875 template <
typename T >
880 return *(
begin() + n );
884 template <
typename T >
890 return (*_volume)( x, y, z, t );
894 template <
typename T >
901 return (*_volume)( x, y, z, t );
905 template <
typename T >
910 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
914 template <
typename T >
919 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
923 template <
typename T >
928 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
932 template <
typename T >
937 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
941 template <
typename T >
946 return (*
this)( pt[0], pt[1], pt[2] );
950 template <
typename T >
955 return (*
this)( pt[0], pt[1], pt[2] );
959 template <
typename T >
964 return (*
this)( pt[0], pt[1], pt[2] );
968 template <
typename T >
973 return (*
this)( pt[0], pt[1], pt[2] );
977 template <
typename T >
982 return (*
this)( pt[0], pt[1] );
986 template <
typename T >
991 return (*
this)( pt[0], pt[1] );
995 template <
typename T >
1000 return (*
this)( pt[0], pt[1] );
1004 template <
typename T >
1009 return (*
this)( pt[0], pt[1] );
1013 template <
typename T >
1021 template <
typename T >
1029 template <
typename T >
1033 int minxind = 0,minyind = 0,minzind = 0,mintind = 0;
1040 for ( t = 0; t < tm; t++ )
1042 for ( z = 0; z < zm; z++ )
1044 for ( y = 0; y < ym; y++ )
1046 for ( x = 0; x < xm; x++ )
1077 template <
typename T >
1081 int maxxind = 0,maxyind = 0,maxzind = 0,maxtind = 0;
1088 for ( t = 0; t < tm; t++ )
1090 for ( z = 0; z < zm; z++ )
1092 for ( y = 0; y < ym; y++ )
1094 for ( x = 0; x < xm; x++ )
1125 template <
typename T >
1134 long of = &_volume->at( 0, 0, 0, 0 ) - &bigger->
at( 0, 0, 0, 0 ),
1135 op = &_volume->at( 0, 1, 0, 0 ) - &_volume->at( xm, 0, 0, 0 ),
1136 ol = &_volume->at( 0, 0, 1, 0 ) - &_volume->at( 0, ym, 0, 0 );
1138 for ( t = 0; t < tm; t++ )
1140 it = &bigger->
at( 0, 0, 0, t );
1141 for ( x = 0; x < of; x++ )
1143 for ( z = 0; z < zm; z++ )
1145 for ( y = 0; y < ym; y++ )
1148 for ( x = 0; x < op; x++ )
1151 for ( x = 0; x < ol; x++ )
1154 for ( x = 0; x < of - op - ol; x++ )
1160 template<
typename T>
1164 if( !_volume->refVolume().
isNull() )
1171 _volume->getSizeY(),
1172 _volume->getSizeZ(),
1173 _volume->getSizeT() ) ) );
1174 dat._volume->header().copyProperties(
1185 template <
typename T >
1190 dimZ() == 1 && other.
dimZ() == 1 );
1195 for (
long y = 0; y < other.
dimY(); y++ )
1196 for (
long x = 0; x <
dimX(); x++ )
1198 prod( x, y ) = T( 0 );
1199 for (
long k = 0; k <
dimY(); k++ )
1200 prod( x, y ) += (*this)( x, k ) * other( k, y );
1207 template <
typename T >
1228 for ( t = 0; t < tm; t++ )
1229 for ( z = 0; z < zm; z++ )
1230 for ( y = 0; y < ym; y++ )
1231 for ( x = 0; x < xm; x++ )
1232 tmp( y, x, z, t ) = (*this)( x, y, z, t );
1239 template <
typename T >
1250 template <
typename T >
1260 template <
typename T >
1272 #define ForEach4d( thing , x , y , z , t) \ 1273 for ( t = 0; t < thing.dimT(); t++ ) \ 1274 for ( z = 0; z < thing.dimZ(); z++ ) \ 1275 for ( y = 0; y < thing.dimY(); y++ ) \ 1276 for ( x = 0; x < thing.dimX(); x++ ) 1278 #define ForEach3d( thing , x , y , z) \ 1279 for ( z = 0; z < thing.dimZ(); z++ ) \ 1280 for ( y = 0; y < thing.dimY(); y++ ) \ 1281 for ( x = 0; x < thing.dimX(); x++ ) 1283 #define ForEach2d( thing , x , y) \ 1284 for ( y = 0; y < thing.dimY(); y++ ) \ 1285 for ( x = 0; x < thing.dimX(); x++ ) 1287 #define ForEach1d( thing , x) \ 1288 for ( x = 0; x < thing.dimX(); x++ ) 1291 #define ForEach4dp( thing , x , y , z , t) \ 1292 for ( t = 0; t < thing->dimT(); t++ ) \ 1293 for ( z = 0; z < thing->dimZ(); z++ ) \ 1294 for ( y = 0; y < thing->dimY(); y++ ) \ 1295 for ( x = 0; x < thing->dimX(); x++ ) 1297 #define ForEach3dp( thing , x , y , z) \ 1298 for ( z = 0; z < thing->dimZ(); z++ ) \ 1299 for ( y = 0; y < thing->dimY(); y++ ) \ 1300 for ( x = 0; x < thing->dimX(); x++ ) 1302 #define ForEach2dp( thing , x , y) \ 1303 for ( y = 0; y < thing->dimY(); y++ ) \ 1304 for ( x = 0; x < thing->dimX(); x++ ) 1306 #define ForEach1dp( thing , x) \ 1307 for ( x = 0; x < thing->dimX(); x++ ) 1316 extern template class VolumeProxy<DtiTensor*>;
1317 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
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.
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.