34 #ifndef AIMS_DATA_CARTODATAVOLUME_H
35 #define AIMS_DATA_CARTODATAVOLUME_H
54 #ifndef AIMSDATA_CLASS_NO_DEPREC_WARNING
55 #warning "<aims/data/data.h> and the AimsData<T> classes are obsolete, use carto::VolumeRef() instead"
101 AimsData(
int dimx = 1,
int dimy = 1,
int dimz = 1,
int dimt = 1,
104 int borderw,
const carto::AllocatorContext & al );
140 float sizez = 1.0f,
float sizet = 1.0f );
166 T
minIndex(
int* x,
int* y,
int* z,
int* t )
const;
167 T
maxIndex(
int* x,
int* y,
int* z,
int* t )
const;
202 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
220 template <
typename T>
269 if( !vol->refVolume().isNull() )
270 if (vol->refVolume()->allocatorContext().isAllocated()) {
273 const std::vector<int> vborders = vol->getBorders();
277 std::vector<int>::const_iterator vbordersend = (vborders.size() > 6
278 ? vborders.begin() + 6
280 if(vborders.begin() != vbordersend) {
281 std::vector<int>::const_iterator minit = std::min_element(vborders.begin(),
283 return (minit == vbordersend ? 0 : *minit);
292 template <
typename T>
299 template <
typename T>
306 template <
typename T>
313 template <
typename T>
324 return &*_volume->
begin();
332 return &*_volume->
begin();
362 return _volume->
begin() == _volume->
end();
369 _volume( new
carto::Volume<T>( dimx + borderw * 2, dimy + borderw * 2,
370 dimz + borderw * 2, dimt ) ),
382 template <
typename T >
385 int borderw,
const carto::AllocatorContext & al )
387 _volume( new
carto::Volume<T>( dimx + borderw * 2, dimy + borderw * 2,
388 dimz + borderw * 2, dimt, al ) ),
400 template <
typename T >
404 _volume( other._volume ),
411 template <
typename T >
415 _volume( new
carto::Volume<T>( other.dimX() + borderw * 2,
416 other.dimY() + borderw * 2, other.dimZ() + borderw * 2, other.dimT() ) ),
429 for ( t = 0; t < tm; t++ )
430 for ( z = 0; z < zm; z++ )
431 for ( y = 0; y < ym; y++ )
432 for ( x = 0; x < xm; x++ )
433 (*
this)( x, y, z, t ) = other( x, y, z, t );
438 template <
typename T >
446 template <
typename T >
456 template <
typename T >
467 template <
typename T >
472 if( _volume.get() == vol.get() )
483 template <
typename T >
487 if ( &other ==
this )
491 _volume = other._volume;
499 template <
typename T >
503 iterator it = begin() + oFirstPoint();
504 long x, xm = dimX(), y, ym = dimY(), z, zm = dimZ(), t, tm = dimT();
506 for ( t = 0; t < tm; t++ )
508 for ( z = 0; z < zm; z++ )
510 for ( y = 0; y < ym; y++ )
512 for ( x = 0; x < xm; x++ )
514 it += oPointBetweenLine();
516 it += oLineBetweenSlice();
518 it += oSliceBetweenVolume();
544 return _volume->getSizeX();
552 return _volume->getSizeY();
560 return _volume->getSizeZ();
568 return _volume->getSizeT();
572 template <
typename T >
576 std::vector<float> vs = _volume->getVoxelSize();
584 template <
typename T >
588 std::vector<float> vs = _volume->getVoxelSize();
596 template <
typename T >
600 std::vector<float> vs = _volume->getVoxelSize();
608 template <
typename T >
612 std::vector<float> vs = _volume->getVoxelSize();
620 template <
typename T >
624 std::vector<float> vs = _volume->getVoxelSize();
628 _volume->setVoxelSize( vs );
632 template <
typename T >
636 std::vector<float> vs = _volume->getVoxelSize();
637 while( vs.size() < 2 )
640 _volume->setVoxelSize( vs );
644 template <
typename T >
648 std::vector<float> vs = _volume->getVoxelSize();
649 while( vs.size() < 3 )
652 _volume->setVoxelSize( vs );
656 template <
typename T >
660 std::vector<float> vs = _volume->getVoxelSize();
661 while( vs.size() < 4 )
664 _volume->setVoxelSize( vs );
668 template <
typename T >
673 _volume->setVoxelSize( sizex, sizey, sizez, sizet );
677 template <
typename T >
685 template <
typename T >
689 return _volume->allocatorContext();
693 template <
typename T >
702 template <
typename T >
708 != &_volume->header() )
723 if( hdr != header() )
758 template <
typename T >
763 return *( begin() + n );
767 template <
typename T >
772 return *( begin() + n );
776 template <
typename T >
782 return (*_volume)( x, y, z, t );
786 template <
typename T >
793 return (*_volume)( x, y, z, t );
797 template <
typename T >
802 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
806 template <
typename T >
811 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
815 template <
typename T >
820 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
824 template <
typename T >
829 return (*
this)( pt[0], pt[1], pt[2], pt[3] );
833 template <
typename T >
838 return (*
this)( pt[0], pt[1], pt[2] );
842 template <
typename T >
847 return (*
this)( pt[0], pt[1], pt[2] );
851 template <
typename T >
856 return (*
this)( pt[0], pt[1], pt[2] );
860 template <
typename T >
865 return (*
this)( pt[0], pt[1], pt[2] );
869 template <
typename T >
874 return (*
this)( pt[0], pt[1] );
878 template <
typename T >
883 return (*
this)( pt[0], pt[1] );
887 template <
typename T >
892 return (*
this)( pt[0], pt[1] );
896 template <
typename T >
901 return (*
this)( pt[0], pt[1] );
905 template <
typename T >
909 return volume()->min();
913 template <
typename T >
917 return volume()->max();
921 template <
typename T >
925 int minxind = 0,minyind = 0,minzind = 0,mintind = 0;
930 int x, xm = dimX(), y, ym = dimY(), z, zm = dimZ(), t, tm = dimT();
932 for ( t = 0; t < tm; t++ )
934 for ( z = 0; z < zm; z++ )
936 for ( y = 0; y < ym; y++ )
938 for ( x = 0; x < xm; x++ )
950 it += oPointBetweenLine();
952 it += oLineBetweenSlice();
954 it += oSliceBetweenVolume();
969 template <
typename T >
973 int maxxind = 0,maxyind = 0,maxzind = 0,maxtind = 0;
978 int x, xm = dimX(), y, ym = dimY(), z, zm = dimZ(), t, tm = dimT();
980 for ( t = 0; t < tm; t++ )
982 for ( z = 0; z < zm; z++ )
984 for ( y = 0; y < ym; y++ )
986 for ( x = 0; x < xm; x++ )
998 it += oPointBetweenLine();
1000 it += oLineBetweenSlice();
1002 it += oSliceBetweenVolume();
1017 template <
typename T >
1025 long x, xm = dimX(), y, ym = dimY(), z, zm = dimZ(), t, tm = dimT();
1026 long of = &_volume->at( 0, 0, 0, 0 ) - &bigger->
at( 0, 0, 0, 0 ),
1027 op = &_volume->at( 0, 1, 0, 0 ) - &_volume->at( xm, 0, 0, 0 ),
1028 ol = &_volume->at( 0, 0, 1, 0 ) - &_volume->at( 0, ym, 0, 0 );
1030 for ( t = 0; t < tm; t++ )
1032 it = &bigger->
at( 0, 0, 0, t );
1033 for ( x = 0; x < of; x++ )
1035 for ( z = 0; z < zm; z++ )
1037 for ( y = 0; y < ym; y++ )
1040 for ( x = 0; x < op; x++ )
1043 for ( x = 0; x < ol; x++ )
1046 for ( x = 0; x < of - op - ol; x++ )
1052 template<
typename T>
1056 if( !_volume->refVolume().isNull() )
1060 _volume->refVolume()->getSizeX(), _volume->refVolume()->getSizeY(),
1061 _volume->refVolume()->getSizeZ(), _volume->refVolume()->getSizeT(),
1062 _volume->refVolume()->allocatorContext(),
1063 _volume->refVolume()->allocatorContext().isAllocated() ) );
1065 if( _volume->refVolume()->allocatorContext().isAllocated() )
1066 transfer( _volume->refVolume(), rvol );
1070 _volume->getSizeY(),
1071 _volume->getSizeZ(),
1072 _volume->getSizeT() ) ) );
1085 template <
typename T >
1090 dimZ() == 1 && other.
dimZ() == 1 );
1095 for (
long y = 0; y < other.
dimY(); y++ )
1096 for (
long x = 0; x < dimX(); x++ )
1098 prod( x, y ) = T( 0 );
1099 for (
long k = 0; k < dimY(); k++ )
1100 prod( x, y ) += (*this)( x, k ) * other( k, y );
1107 template <
typename T >
1111 AimsData<T> tmp( dimY(), dimX(), dimZ(), dimT(), borderWidth() );
1123 tmp.
setSizeXYZT( sizeY(), sizeX(), sizeZ(), sizeT() );
1126 long x, xm = dimX(), y, ym = dimY(), z, zm = dimZ(), t, tm = dimT();
1128 for ( t = 0; t < tm; t++ )
1129 for ( z = 0; z < zm; z++ )
1130 for ( y = 0; y < ym; y++ )
1131 for ( x = 0; x < xm; x++ )
1132 tmp( y, x, z, t ) = (*this)( x, y, z, t );
1139 template <
typename T >
1143 std::vector<int> borders = _volume->getBorders();
1144 int s = borders.size();
1149 for(
int i = 1; i < s; ++i )
1150 width = std::min( width, borders[i] );
1157 template <
typename T >
1161 return _volume->getBorders();
1165 template <
typename T >
1169 if( _volume->refVolume().isNull() )
1171 return &_volume->at(0) - &_volume->refVolume()->at( 0 );
1175 template <
typename T >
1178 return &_volume->at( 0, 1 ) - &_volume->at( 0 );
1182 template <
typename T >
1186 return &_volume->at( 0, 1 ) - &_volume->at( _volume->getSizeX() );
1190 template <
typename T >
1194 return &_volume->at( 0, 0, 1 ) - &_volume->at( 0 );
1198 template <
typename T >
1202 return &_volume->at( 0, 0, 1 ) - &_volume->at( 0, _volume->getSizeY() );
1206 template <
typename T >
1210 return &_volume->at( 0, 0, 0, 1 ) - &_volume->at( 0 );
1214 template <
typename T >
1218 return &_volume->at( 0, 0, 0, 1 )
1219 - &_volume->at( 0, 0, _volume->getSizeZ() );
1223 template <
typename T >
1234 template <
typename T >
1244 template <
typename T >
1256 #define ForEach4d( thing , x , y , z , t) \
1257 for ( t = 0; t < thing.dimT(); t++ ) \
1258 for ( z = 0; z < thing.dimZ(); z++ ) \
1259 for ( y = 0; y < thing.dimY(); y++ ) \
1260 for ( x = 0; x < thing.dimX(); x++ )
1262 #define ForEach3d( thing , x , y , z) \
1263 for ( z = 0; z < thing.dimZ(); z++ ) \
1264 for ( y = 0; y < thing.dimY(); y++ ) \
1265 for ( x = 0; x < thing.dimX(); x++ )
1267 #define ForEach2d( thing , x , y) \
1268 for ( y = 0; y < thing.dimY(); y++ ) \
1269 for ( x = 0; x < thing.dimX(); x++ )
1271 #define ForEach1d( thing , x) \
1272 for ( x = 0; x < thing.dimX(); x++ )
1275 #define ForEach4dp( 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 ForEach3dp( 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 ForEach2dp( thing , x , y) \
1287 for ( y = 0; y < thing->dimY(); y++ ) \
1288 for ( x = 0; x < thing->dimX(); x++ )
1290 #define ForEach1dp( thing , x) \
1291 for ( x = 0; x < thing->dimX(); x++ )
1300 extern template class VolumeProxy<DtiTensor*>;
1301 extern template class Volume<DtiTensor*>;
AimsData< T > operator-(const AimsData< T > &firstThing, const AimsData< T > &secondThing)
AimsData< T > operator*(const AimsData< T > &firstThing, float scale)
AimsData< T > operator+(const AimsData< T > &firstThing, const AimsData< T > &secondThing)
T & reference
basic reference
AimsData(const AimsData< T > &other)
int oVolume() const
Offset between 2 consecutive volumes.
T **** pointer4d
4D-pointer
void setSizeY(float sizey)
int borderWidth() const
Size of the border.
int oSlice() const
Offset between 2 consecutive slices.
const carto::AllocatorContext & allocator() const
reference operator()(size_type x=0, size_type y=0, size_type z=0, size_type t=0)
T maxIndex(int *x, int *y, int *z, int *t) const
T minIndex(int *x, int *y, int *z, int *t) const
void setSizeT(float sizet)
AimsData(const AimsData< T > &other, int borderw)
void setHeader(aims::Header *hdr)
carto::VolumeRef< T > & volume()
const carto::VolumeRef< T > & volume() const
AimsData< T > & transpose()
int oLineBetweenSlice() const
Number of lines between 2 consecutive slices.
size_t size_type
size of the basic type
void setSizeXYZT(const AimsData< T > &other)
void setSizeXYZT(float sizex=1.0f, float sizey=1.0f, float sizez=1.0f, float sizet=1.0f)
T * iterator
basic iterator
int oLine() const
Offset between 2 consecutive lines.
AimsData< T > & operator=(const carto::rc_ptr< carto::Volume< T > > &vol)
const_iterator end() const
AimsData< T > clone() const
const T * const_iterator
basic constant iterator
const std::vector< int > & borders() const
Sizes of the border.
ptrdiff_t difference_type
difference type
int oFirstPoint() const
Offset from the start of the allocated memory to the first point.
AimsData< T > cross(const AimsData< T > &other)
AimsData(const carto::rc_ptr< carto::Volume< T > > &vol)
const T & const_reference
basic constant reference
int oSliceBetweenVolume() const
Number of slices between 2 consecutive volumes.
int oPointBetweenLine() const
Offset between the end of a line and the start of the consecutive line.
reference operator[](size_type n)
const aims::Header * header() const
void setSizeZ(float sizez)
AimsData(int dimx=1, int dimy=1, int dimz=1, int dimt=1, int borderw=0)
AimsData(int dimx, int dimy, int dimz, int dimt, int borderw, const carto::AllocatorContext &al)
AimsData(const carto::VolumeRef< T > &vol)
void fillBorder(const T &val)
void setSizeX(float sizex)
const_iterator begin() const
static std::string objectType()
static std::string name()
static std::string dataType()
virtual void copyProperties(Object source)
Object reference(Object &value)
virtual void clearProperties()
virtual bool getProperty(const std::string &, Object &) const
virtual bool removeProperty(const std::string &)
virtual void setProperty(const std::string &, Object)
virtual bool hasProperty(const std::string &) const
std::vector< float > getVoxelSize() const
VolumeRef< T > deepcopy() const
virtual void copyHeaderFrom(const PropertySet &other)
rc_ptr< Volume< T > > refVolume() const
const T & at(long x, long y=0, long z=0, long t=0) const
const PropertySet & header() const
carto::Object getObjectHeader(Headered &h)
void transfer(const Volume< T > &src, Volume< T > &dst)
static int borderWidth(carto::rc_ptr< carto::Volume< T > > vol)