cartodata 6.0.1
volumebase.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_VOLUMEBASE_H
35#define CARTODATA_VOLUME_VOLUMEBASE_H
36//--- cartodata --------------------------------------------------------------
40//--- soma-io ----------------------------------------------------------------
43//--- cartobase --------------------------------------------------------------
45#include <cartobase/smart/rcptr.h>
46#include <cartobase/type/datatypetraits.h>
47//--- blitz ------------------------------------------------------------------
48 #ifdef _WIN32
49 // disable thread-safe operations in blitz++ on windows since it uses pthread
50 #ifdef _REENTRANT
51 #define CARTO_REENTRANT_MEMO
52 #undef _REENTRANT
53 #endif
54 #include <blitz/blitz.h>
55 #ifdef CARTO_REENTRANT_MEMO
56 #define _REENTRANT
57 #undef CARTO_REENTRANT_MEMO
58 #endif
59 #endif
60 #include <blitz/array.h>
61
62namespace carto {
63 typedef ptrdiff_t BlitzStridesType;
64}
65
66
67//--- std --------------------------------------------------------------------
68#include <vector>
69//--- forward declarations ---------------------------------------------------
70namespace carto {
71 class AllocatorContext;
72 class PropertyFilter;
73}
74//----------------------------------------------------------------------------
75
76namespace carto
77{
78//============================================================================
79// V O L U M E
80//============================================================================
118 template < typename T >
119 class Volume : public VolumeProxy< T >
120 {
121 public:
122 //========================================================================
123 // TYPES
124 //========================================================================
129 class Position4Di;
130 typedef std::vector<int> Position;
131
133 typedef T datatype;
134
139 // static const int DIM_MAX = 8; leads to build issues on old GCC versions
140 // so we need to use enum to be able to declare DIM_MAX in carto::Volume
141 enum { DIM_MAX = 8 };
142 typedef typename blitz::Array<T,Volume<T>::DIM_MAX>::iterator iterator;
143 typedef typename blitz::Array<T,Volume<T>::DIM_MAX>::const_iterator const_iterator;
144
145 //========================================================================
146 // CONSTRUCTORS
147 //========================================================================
159 explicit Volume( int sizeX = 1, int sizeY = 1, int sizeZ = 1,
160 int sizeT = 1,
161 const AllocatorContext& allocatorContext
162 = AllocatorContext(),
163 bool allocated = true );
172 explicit Volume( const Position4Di & size,
173 const AllocatorContext& allocatorContext
174 = AllocatorContext(),
175 bool allocated = true );
180 explicit Volume( int sizeX, int sizeY, int sizeZ,
181 int sizeT, int bordersize,
182 const AllocatorContext& allocatorContext
183 = AllocatorContext(),
184 bool allocated = true );
189 explicit Volume( const Position4Di & size, int bordersize,
190 const AllocatorContext& allocatorContext
191 = AllocatorContext(),
192 bool allocated = true );
196 explicit Volume( int sizeX, int sizeY, int sizeZ, int sizeT,
197 const Position4Di & border,
198 const AllocatorContext& allocatorContext
199 = AllocatorContext(),
200 bool allocated = true );
204 explicit Volume( const Position4Di & size,
205 const Position4Di & border,
206 const AllocatorContext& allocatorContext
207 = AllocatorContext(),
208 bool allocated = true );
212 explicit Volume( const std::vector<int> & size,
213 const AllocatorContext& allocatorContext
214 = AllocatorContext(),
215 bool allocated = true );
219 explicit Volume( const std::vector<int> & size,
220 const std::vector<int> & border,
221 const AllocatorContext& allocatorContext
222 = AllocatorContext(),
223 bool allocated = true );
226 Volume( int sizeX, int sizeY, int sizeZ, int sizeT, T* buffer,
227 const std::vector<long> *strides = 0 );
231 Volume( const Position4Di & size, T* buffer,
232 const std::vector<long> *strides = 0 );
233 Volume( const std::vector<int> & size, T* buffer,
234 const std::vector<long> *strides = 0 );
243 const Position4Di & pos = Position4Di( 0, 0, 0, 0 ),
244 const Position4Di & size = Position4Di( -1, -1, -1, -1 ),
245 const AllocatorContext & allocContext = AllocatorContext(),
246 bool transToParent = false );
255 const Position & pos,
256 const Position & size = Position(),
257 const AllocatorContext & allocContext = AllocatorContext(),
258 bool transToParent = false );
262 const Position & pos,
263 const Position & size,
264 T* buffer, const std::vector<long> & strides );
269 Volume( const Volume< T >& other );
270 virtual ~Volume();
271
273
274 //========================================================================
275 // ITERATORS
276 //========================================================================
277
287
288 //========================================================================
289 // ACCESSORS
290 //========================================================================
291
294 const T& operator()( long x, long y = 0, long z = 0, long t = 0 ) const;
295// T& operator() ( long x );
296 T& operator() ( long x, long y = 0, long z = 0, long t = 0 );
297 const T& at( long x, long y = 0, long z = 0, long t = 0 ) const;
298 T& at( long x, long y = 0, long z = 0, long t = 0 );
299 const T& operator() ( const Position4Di & position ) const;
300 T& operator() ( const Position4Di & position );
301 const T& at( const Position4Di & position ) const;
302 T& at( const Position4Di & position );
303 const T & at( const std::vector<int> & ) const;
304 T & at( const std::vector<int> & );
305 const T& operator() ( const std::vector<int> & position ) const;
306 T& operator() ( const std::vector<int> & position );
307
308 const T & at( const blitz::TinyVector<int,1> & ) const;
309 T & at( const blitz::TinyVector<int,1> & );
310 const T & at( const blitz::TinyVector<int,2> & ) const;
311 T & at( const blitz::TinyVector<int,2> & );
312 const T & at( const blitz::TinyVector<int,3> & ) const;
313 T & at( const blitz::TinyVector<int,3> & );
314 const T & at( const blitz::TinyVector<int,4> & ) const;
315 T & at( const blitz::TinyVector<int,4> & );
316 const T & at( const blitz::TinyVector<int,Volume<T>::DIM_MAX> & ) const;
317 T & at( const blitz::TinyVector<int,Volume<T>::DIM_MAX> & );
318 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::RectDomain<Volume<T>::DIM_MAX>
319 & subdomain ) const;
320 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::StridedDomain<Volume<T>::DIM_MAX>
321 & subdomain ) const;
322 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0 ) const;
323 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0,
324 const blitz::Range & r1 ) const;
325 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0,
326 const blitz::Range & r1,
327 const blitz::Range & r2 ) const;
328 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0,
329 const blitz::Range & r1,
330 const blitz::Range & r2,
331 const blitz::Range & r3 ) const;
332 // to get beyond 4 dimensions
333 const T & at( long x1, long x2, long x3, long x4, long x5, long x6=0,
334 long x7=0, long x8=0 ) const;
335 T & at( long x1, long x2, long x3, long x4, long x5, long x6=0,
336 long x7=0, long x8=0 );
337 const T& operator()( long x1, long x2, long x3, long x4, long x5,
338 long x6=0, long x7=0, long x8=0 ) const;
339 T& operator() ( long x1, long x2, long x3, long x4, long x5, long x6=0,
340 long x7=0, long x8=0 );
341
342 //========================================================================
343 // INIT / ALLOCATION
344 //========================================================================
345
347 virtual void initialize();
349 const AllocatorContext & allocatorContext() const;
355 void allocate();
357 virtual void reallocate( int sizeX = 1, int sizeY = 1, int sizeZ = 1,
358 int sizeT = 1, bool keepcontents = false,
359 const AllocatorContext& allocatorContext
360 = AllocatorContext(), bool allocate = true,
361 const std::vector<long> *strides = 0 );
362 virtual void reallocate( const Position4Di & size,
363 bool keepcontents = false,
364 const AllocatorContext& allocatorContext
365 = AllocatorContext(), bool allocate = true,
366 const std::vector<long> *strides = 0 );
367 virtual void reallocate( const std::vector<int> & size,
368 bool keepcontents = false,
369 const AllocatorContext& allocatorContext
370 = AllocatorContext(), bool allocate = true,
371 const std::vector<long> *strides = 0 );
373 void allocateBorders( int bsx, int bsy = -1, int bsz = -1 );
376 void allocateBorders( const std::vector<int> & border );
377
378 //========================================================================
379 // COPY / VIEW
380 //========================================================================
381
386 template <typename OUTP>
391 template <typename OUTP>
393
397 template <typename OUTP>
399
405 void copySubVolume( const Volume<T> & source,
406 const std::vector<int> & pos = std::vector<int>() );
412 void copySubVolume( const rc_ptr<Volume<T> > & source,
413 const std::vector<int> & pos = std::vector<int>() );
414
416 template <typename OUTP>
417 operator Volume<OUTP>() const;
418
421 int getLevelsCount() const;
422
427 int refLevel(const int level) const;
428
436
443 rc_ptr<Volume<T> > refVolumeAtLevel(const int level) const;
444
446 void setRefVolume(const rc_ptr<Volume<T> > & refvol);
448 const Position & posInRefVolume() const;
450 Position posInRefVolumeAtLevel(const int level) const;
451
453 void setPosInRefVolume(const Position4Di & pos);
454 void setPosInRefVolume(const Position & pos);
455
456
468 std::vector<int> getBorders() const;
469
472 std::vector<long> getStrides() const;
473
474 //========================================================================
475 // BOOLEANS / ACCUMULATED VALUES
476 //========================================================================
479 operator bool() const;
481 bool all() const;
483 bool any() const;
484 T min() const;
485 T max() const;
489
490 //========================================================================
491 // FILL / REPLACE
492 //========================================================================
494 void fill( const T & value );
500 void fillBorder( const T & value );
501
503 const Referential & referential() const;
506
521 Volume<T> & operator= ( const T & value );
522
536 void flipToOrientation( const std::string & orient );
545 void flipToOrientation( const std::string & orient,
546 const std::string & force_memory_layout );
548 Object reorientedHeader( const std::string & orient ) const;
556 std::vector<int> memoryLayoutOrientation() const;
567 std::vector<int> storageLayoutOrientation() const;
568
569 protected:
570 //========================================================================
571 // PRIVATE UTILS
572 //========================================================================
573 void allocate( int oldSizeX, int oldSizeY, int oldSizeZ, int oldSizeT,
574 bool allocate, const AllocatorContext& allocatorContext,
575 const std::vector<long> *strides = 0 );
576 void allocate( const std::vector<int> & oldSize,
577 bool allocate, const AllocatorContext& allocatorContext,
578 const std::vector<long> *strides = 0 );
579 void slotSizeChanged( const PropertyFilter& propertyFilter );
581
582 void constructBorders( const Position & bordersize,
583 const AllocatorContext& allocatorContext,
584 bool allocated );
585
586 AllocatedVector<T> _items;
587 // in case of negative strides, _start adds an offset to _items 1st element
589 blitz::Array<T, Volume<T>::DIM_MAX> _blitz;
591 std::vector<int> _pos;
593 };
594
595//============================================================================
596// POSITION VECTOR
597//============================================================================
598 template <typename T>
600 {
601 public:
602 explicit Position4Di( int x = 0, int y = 0, int z = 0, int t = 0 )
603 : _coords( 4 )
604 {
605 _coords[0] = x;
606 _coords[1] = y;
607 _coords[2] = z;
608 _coords[3] = t;
609 }
610
615 template <typename U>
616 Position4Di( const U & other ):
617 _coords(4)
618 {
619 for( size_t i = 0; i < size_t( other.size() ) && i < 4; ++i )
620 _coords[i] = other[i];
621 for( size_t i = size_t( other.size() ); i < 4; ++i )
622 _coords[i] = 0;
623 }
624
625 Position4Di( const Position4Di & pos ) : _coords( pos._coords )
626 {
627 }
628
630
631 int & operator [] ( int coord ) { return _coords[ coord ]; }
632 const int & operator [] ( int coord ) const { return _coords[ coord ]; }
633
634 bool operator==(const Position4Di& p) const
635 {
636 return ( _coords == p._coords );
637 }
638 bool operator!=(const Position4Di& p) const
639 { return !(this->operator ==(p)); }
640
641 unsigned size() const { return _coords.size(); }
642 const std::vector<int> & toVector() const
643 { return _coords; }
644
645 /* utility functions, not really related, but which we don't really know
646 where to put them */
647 static std::vector<int> fixed_position( const std::vector<int> & vec )
648 {
649 if( vec.size() >= 4 )
650 return vec;
651 std::vector<int> fixed( vec );
652 fixed.resize( 4 );
653 for( int i=vec.size(); i<4; ++i )
654 fixed[i] = 0;
655 return fixed;
656 }
657
658 static std::vector<int> fixed_size( const std::vector<int> & vec )
659 {
660 if( vec.size() >= 4 )
661 return vec;
662 std::vector<int> fixed( vec );
663 fixed.resize( 4 );
664 for( int i=vec.size(); i<4; ++i )
665 fixed[i] = 1;
666 return fixed;
667 }
668
669 static unsigned long long size_num_elements( const std::vector<int> & vec )
670 {
671 int i, n = vec.size();
672 unsigned long long num = 1;
673 for( i=0; i<n; ++i )
674 num *= vec[i];
675 return num;
676 }
677
678 private:
679 std::vector<int> _coords;
680 };
681
682//============================================================================
683// UTILITIES
684//============================================================================
685#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
686
687 template <typename T>
689 {
690 public:
691 static std::string objectType()
692 { return "CartoVolume"; }
693 static std::string dataType()
694 { return DataTypeCode<T>::dataType(); }
695 static std::string name()
696 {
697 return std::string("carto_volume of ") + DataTypeCode< T >::name();
698 }
699 };
700
701 template <typename T>
702 class Creator<Volume<T> >
703 {
704 public:
705 static Volume<T>* create( Object, const AllocatorContext &, Object );
706 static void setup( Volume<T> &, Object, const AllocatorContext &, Object );
707 };
708
709#endif
710
711//============================================================================
712// STREAM
713//============================================================================
714
715#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
716
717 // Warper for output streams that integrates parameters for volume
718 // printing
719 class VolumeOStream // : public std::ostream // is not really a stream
720 {
721 public:
722 VolumeOStream( std::ostream & ostream );
723 VolumeOStream( const VolumeOStream & other );
725
726 std::ostream & ostream() const;
727
728 const size_t & maxT() const;
729 const size_t & maxZ() const;
730 const size_t & maxY() const;
731 const size_t & maxX() const;
732
733 size_t & maxT();
734 size_t & maxZ();
735 size_t & maxY();
736 size_t & maxX();
737
738 private:
739 size_t _maxT;
740 size_t _maxZ;
741 size_t _maxY;
742 size_t _maxX;
743 std::ostream & _ostream;
744 };
745
746 // Object returned by setMaxDim used to set Volume printing parameters
748 {
749 public:
751
752 const size_t & maxT() const;
753 const size_t & maxZ() const;
754 const size_t & maxY() const;
755 const size_t & maxX() const;
756
757 size_t & maxT();
758 size_t & maxZ();
759 size_t & maxY();
760 size_t & maxX();
761
762 private:
763 size_t _maxT;
764 size_t _maxZ;
765 size_t _maxY;
766 size_t _maxX;
767 };
768
769 VolumeOStream operator<< ( std::ostream & out,
770 const VolumeOStreamSetter & setter );
771
772 template <typename T>
773 std::ostream & operator<< ( const VolumeOStream & out,
774 const Volume<T> & volume );
775
776 // Method used to set Volume printing parameters
778 VolumeOStreamSetter setMaxDim( size_t mx, size_t my, size_t mz, size_t mt );
779
780 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
781
782
799 template <typename T>
800 std::ostream & operator<< ( std::ostream & out,
801 const Volume<T> & volume );
802
803
805 template <typename T>
806 void displayRefVolumes(const Volume<T> & vol);
807
808} // namespace carto:
809
810
811// the CT macro defined in blitz++ interferes with QColor::CT in Qt
812# ifdef CT
813# undef CT
814# endif
815
816#endif // CARTODATA_VOLUME_VOLUMEBASE_H
static void setup(Volume< T > &, Object, const AllocatorContext &, Object)
static Volume< T > * create(Object, const AllocatorContext &, Object)
static std::string objectType()
Definition volumebase.h:691
static std::string dataType()
Definition volumebase.h:693
std::string name()
std::string dataType()
Referential holds information about coordinates system and axes.
Definition referential.h:78
const size_t & maxX() const
const size_t & maxT() const
const size_t & maxZ() const
const size_t & maxY() const
VolumeOStream(const VolumeOStream &other)
VolumeOStream(std::ostream &ostream)
const size_t & maxZ() const
const size_t & maxY() const
std::ostream & ostream() const
const size_t & maxT() const
const size_t & maxX() const
VolumeProxy(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1)
Position4Di(const Position4Di &pos)
Definition volumebase.h:625
static std::vector< int > fixed_position(const std::vector< int > &vec)
Definition volumebase.h:647
bool operator!=(const Position4Di &p) const
Definition volumebase.h:638
static std::vector< int > fixed_size(const std::vector< int > &vec)
Definition volumebase.h:658
Position4Di(int x=0, int y=0, int z=0, int t=0)
Definition volumebase.h:602
static unsigned long long size_num_elements(const std::vector< int > &vec)
Definition volumebase.h:669
Position4Di(const U &other)
Generic constructor from any "vector-like" object, i.e.
Definition volumebase.h:616
const std::vector< int > & toVector() const
Definition volumebase.h:642
unsigned size() const
Definition volumebase.h:641
bool operator==(const Position4Di &p) const
Definition volumebase.h:634
N-D Volume main class.
Definition volumebase.h:120
T & at(long x1, long x2, long x3, long x4, long x5, long x6=0, long x7=0, long x8=0)
iterator begin()
Iterators returned here are the most "basic" (and fastest) iterators: they go from the first voxel li...
const T & operator()(long x1, long x2, long x3, long x4, long x5, long x6=0, long x7=0, long x8=0) const
T & at(const blitz::TinyVector< int, 2 > &)
Volume(int sizeX, int sizeY, int sizeZ, int sizeT, T *buffer, const std::vector< long > *strides=0)
This constructor builds a Volume on an already allocated buffer.
void flipToOrientation(const std::string &orient, const std::string &force_memory_layout)
Flip the volume to a given orientation.
const T & at(long x1, long x2, long x3, long x4, long x5, long x6=0, long x7=0, long x8=0) const
std::vector< int > _pos
Definition volumebase.h:591
std::vector< int > Position
Definition volumebase.h:130
const T & at(const std::vector< int > &) const
T & at(const Position4Di &position)
Volume(const Position4Di &size, T *buffer, const std::vector< long > *strides=0)
Position4Di version This constructor builds a Volume on an already allocated buffer.
blitz::Array< T, Volume< T >::DIM_MAX > at(const blitz::StridedDomain< Volume< T >::DIM_MAX > &subdomain) const
const T & at(const blitz::TinyVector< int, 2 > &) const
const Referential & referential() const
Referential and orientation information.
const AllocatorContext & allocatorContext() const
rc_ptr< Volume< T > > _refvol
Definition volumebase.h:590
T & at(const std::vector< int > &)
bool all() const
True if all values compare to true.
Volume< T > copyStructure() const
Copy the full data structure without copying the actual data.
Volume(rc_ptr< Volume< T > > other, const Position &pos, const Position &size, T *buffer, const std::vector< long > &strides)
This "very special" constructor should not be used in regular programs.
void allocate(int oldSizeX, int oldSizeY, int oldSizeZ, int oldSizeT, bool allocate, const AllocatorContext &allocatorContext, const std::vector< long > *strides=0)
virtual void reallocate(const std::vector< int > &size, bool keepcontents=false, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocate=true, const std::vector< long > *strides=0)
Volume(const Position4Di &size, const Position4Di &border, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation: Position4Di version Same as the above constructor,...
Volume(const std::vector< int > &size, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation: std::vector version Same as the above constructor,...
void setPosInRefVolume(const Position4Di &pos)
Set position in parent volume.
T & at(const blitz::TinyVector< int, 3 > &)
blitz::Array< T, Volume< T >::DIM_MAX > at(const blitz::Range &r0, const blitz::Range &r1, const blitz::Range &r2) const
const T & at(const blitz::TinyVector< int, 3 > &) const
const_iterator begin() const
Volume< T > & operator=(const Volume< T > &other)
Volume< T > deepcopy() const
Copy the full data structure.
Volume< OUTP > copy() const
blitz::Array< T, Volume< T >::DIM_MAX >::const_iterator const_iterator
Definition volumebase.h:143
Referential _referential
Definition volumebase.h:592
void copySubVolume(const rc_ptr< Volume< T > > &source, const std::vector< int > &pos=std::vector< int >())
Copy voxels values from another volume pos is the position into the destination (this) volume,...
blitz::Array< T, Volume< T >::DIM_MAX > at(const blitz::Range &r0) const
bool any() const
True if at least one value compares to true.
virtual void initialize()
Initializes header info.
Object reorientedHeader(const std::string &orient) const
used by flipToOrientation(), reorient header information
Volume(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation.
Referential & referential()
Referential and orientation information.
const Position & posInRefVolume() const
Get position in parent volume.
void allocateBorders(const std::vector< int > &border)
reallocate the volume with given borders, keep (copy) the contents.
void constructBorders(const Position &bordersize, const AllocatorContext &allocatorContext, bool allocated)
blitz::Array< T, Volume< T >::DIM_MAX > at(const blitz::RectDomain< Volume< T >::DIM_MAX > &subdomain) const
void allocate()
This function is only useful in the particular context of an unallocated Volume, when the constructor...
const T & at(const Position4Di &position) const
Volume(const Volume< T > &other)
Copy constructor The copy constructors actually duplicates data buffers.
void setRefVolume(const rc_ptr< Volume< T > > &refvol)
Set parent volume.
iterator end()
Volume< T > copy() const
Create a volume of same dimension and copy the data.
T & at(const blitz::TinyVector< int, Volume< T >::DIM_MAX > &)
void setPosInRefVolume(const Position &pos)
Volume(rc_ptr< Volume< T > > other, const Position &pos, const Position &size=Position(), const AllocatorContext &allocContext=AllocatorContext(), bool transToParent=false)
This is the volume view constructor.
virtual ~Volume()
Volume(const Position4Di &size, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation: Position4Di version.
const_iterator end() const
blitz::Array< T, Volume< T >::DIM_MAX >::iterator iterator
Definition volumebase.h:142
Position posInRefVolumeAtLevel(const int level) const
Get position relatively to parent volume at specified level.
rc_ptr< Volume< T > > refVolume() const
Get parent volume.
Volume(rc_ptr< Volume< T > > other, const Position4Di &pos=Position4Di(0, 0, 0, 0), const Position4Di &size=Position4Di(-1, -1, -1, -1), const AllocatorContext &allocContext=AllocatorContext(), bool transToParent=false)
This is the volume view constructor.
const T & at(const blitz::TinyVector< int, 4 > &) const
Volume(const std::vector< int > &size, T *buffer, const std::vector< long > *strides=0)
void copySubVolume(const Volume< T > &source, const std::vector< int > &pos=std::vector< int >())
Copy voxels values from another volume.
blitz::Array< T, Volume< T >::DIM_MAX > at(const blitz::Range &r0, const blitz::Range &r1, const blitz::Range &r2, const blitz::Range &r3) const
std::vector< int > getBorders() const
Get borders for the volume.
Volume< OUTP > deepcopy() const
blitz::Array< T, Volume< T >::DIM_MAX > at(const blitz::Range &r0, const blitz::Range &r1) const
T & at(long x, long y=0, long z=0, long t=0)
int refLevel(const int level) const
Transform a level index to a valid level index in the volume hierarchy.
std::vector< int > storageLayoutOrientation() const
determine the storage (disk) layout orientation.
Volume(int sizeX, int sizeY, int sizeZ, int sizeT, const Position4Di &border, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation Same as the above constructor, but allows to specify a border size...
DataTypeTraits< T >::LongType sum() const
To avoid overflow, the biggest possible type (intmax_t, uintmax_t, double...) is used for computation...
std::vector< long > getStrides() const
Get strides for the volume.
Volume(const Position4Di &size, int bordersize, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation: Position4Di version Same as the above constructor,...
const T & at(const blitz::TinyVector< int, 1 > &) const
rc_ptr< Volume< T > > refVolumeAtLevel(const int level) const
Get parent volume at a specified level in volume hierarchy.
void fill(const T &value)
Fills the volume with a given value.
const T & at(long x, long y=0, long z=0, long t=0) const
int getLevelsCount() const
Get levels count in volume hierarchy from the current volume to the topmost volume.
void slotSizeChanged(const PropertyFilter &propertyFilter)
virtual void reallocate(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, bool keepcontents=false, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocate=true, const std::vector< long > *strides=0)
allows resizing and changing allocator
T & at(const blitz::TinyVector< int, 1 > &)
Volume(int sizeX, int sizeY, int sizeZ, int sizeT, int bordersize, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation Same as the above constructor, but allows to specify a border size...
void allocateBorders(int bsx, int bsy=-1, int bsz=-1)
reallocate the volume with given borders, keep (copy) the contents.
T & at(const blitz::TinyVector< int, 4 > &)
blitz::Array< T, Volume< T >::DIM_MAX > _blitz
Definition volumebase.h:589
Volume< OUTP > copyStructure() const
Copy the full data structure without copying the actual data.
void allocate(const std::vector< int > &oldSize, bool allocate, const AllocatorContext &allocatorContext, const std::vector< long > *strides=0)
void flipToOrientation(const std::string &orient)
Flip the volume to a given orientation.
const T & operator()(long x, long y=0, long z=0, long t=0) const
Warning: this operator is not virtual, so may not have the expected result on inherited classes (see ...
const T & at(const blitz::TinyVector< int, Volume< T >::DIM_MAX > &) const
std::vector< int > memoryLayoutOrientation() const
determine the memory layout orientation from strides and current indices orientation.
void updateItemsBuffer()
Volume(const std::vector< int > &size, const std::vector< int > &border, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation: std::vector version Same as the above constructor,...
AllocatedVector< T > _items
Definition volumebase.h:586
virtual void reallocate(const Position4Di &size, bool keepcontents=false, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocate=true, const std::vector< long > *strides=0)
void fillBorder(const T &value)
Fill border with a constant value.
T datatype
Access to T type.
Definition volumebase.h:133
void displayRefVolumes(const Volume< T > &vol)
Display information about volumes hierarchy.
carto::Volume< bool > operator==(const carto::Volume< T > &vol, const U &value)
std::ostream & operator<<(std::ostream &out, const VoxelValue< T, C > &aa)
VolumeOStreamSetter setMaxDim(size_t m)
ptrdiff_t BlitzStridesType
Definition volumebase.h:63