cartodata 6.0.0
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 );
241 const Position4Di & pos = Position4Di( 0, 0, 0, 0 ),
242 const Position4Di & size = Position4Di( -1, -1, -1, -1 ),
243 const AllocatorContext & allocContext = AllocatorContext() );
250 const Position & pos,
251 const Position & size = Position(),
252 const AllocatorContext & allocContext = AllocatorContext() );
256 const Position & pos,
257 const Position & size,
258 T* buffer, const std::vector<long> & strides );
263 Volume( const Volume< T >& other );
264 virtual ~Volume();
265
267
268 //========================================================================
269 // ITERATORS
270 //========================================================================
271
281
282 //========================================================================
283 // ACCESSORS
284 //========================================================================
285
288 const T& operator()( long x, long y = 0, long z = 0, long t = 0 ) const;
289// T& operator() ( long x );
290 T& operator() ( long x, long y = 0, long z = 0, long t = 0 );
291 const T& at( long x, long y = 0, long z = 0, long t = 0 ) const;
292 T& at( long x, long y = 0, long z = 0, long t = 0 );
293 const T& operator() ( const Position4Di & position ) const;
294 T& operator() ( const Position4Di & position );
295 const T& at( const Position4Di & position ) const;
296 T& at( const Position4Di & position );
297 const T & at( const std::vector<int> & ) const;
298 T & at( const std::vector<int> & );
299 const T& operator() ( const std::vector<int> & position ) const;
300 T& operator() ( const std::vector<int> & position );
301
302 const T & at( const blitz::TinyVector<int,1> & ) const;
303 T & at( const blitz::TinyVector<int,1> & );
304 const T & at( const blitz::TinyVector<int,2> & ) const;
305 T & at( const blitz::TinyVector<int,2> & );
306 const T & at( const blitz::TinyVector<int,3> & ) const;
307 T & at( const blitz::TinyVector<int,3> & );
308 const T & at( const blitz::TinyVector<int,4> & ) const;
309 T & at( const blitz::TinyVector<int,4> & );
310 const T & at( const blitz::TinyVector<int,Volume<T>::DIM_MAX> & ) const;
311 T & at( const blitz::TinyVector<int,Volume<T>::DIM_MAX> & );
312 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::RectDomain<Volume<T>::DIM_MAX>
313 & subdomain ) const;
314 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::StridedDomain<Volume<T>::DIM_MAX>
315 & subdomain ) const;
316 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0 ) const;
317 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0,
318 const blitz::Range & r1 ) const;
319 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0,
320 const blitz::Range & r1,
321 const blitz::Range & r2 ) const;
322 blitz::Array<T,Volume<T>::DIM_MAX> at( const blitz::Range & r0,
323 const blitz::Range & r1,
324 const blitz::Range & r2,
325 const blitz::Range & r3 ) const;
326 // to get beyond 4 dimensions
327 const T & at( long x1, long x2, long x3, long x4, long x5, long x6=0,
328 long x7=0, long x8=0 ) const;
329 T & at( long x1, long x2, long x3, long x4, long x5, long x6=0,
330 long x7=0, long x8=0 );
331 const T& operator()( long x1, long x2, long x3, long x4, long x5,
332 long x6=0, long x7=0, long x8=0 ) const;
333 T& operator() ( long x1, long x2, long x3, long x4, long x5, long x6=0,
334 long x7=0, long x8=0 );
335
336 //========================================================================
337 // INIT / ALLOCATION
338 //========================================================================
339
341 virtual void initialize();
343 const AllocatorContext & allocatorContext() const;
349 void allocate();
351 virtual void reallocate( int sizeX = 1, int sizeY = 1, int sizeZ = 1,
352 int sizeT = 1, bool keepcontents = false,
353 const AllocatorContext& allocatorContext
354 = AllocatorContext(), bool allocate = true,
355 const std::vector<long> *strides = 0 );
356 virtual void reallocate( const Position4Di & size,
357 bool keepcontents = false,
358 const AllocatorContext& allocatorContext
359 = AllocatorContext(), bool allocate = true,
360 const std::vector<long> *strides = 0 );
361 virtual void reallocate( const std::vector<int> & size,
362 bool keepcontents = false,
363 const AllocatorContext& allocatorContext
364 = AllocatorContext(), bool allocate = true,
365 const std::vector<long> *strides = 0 );
367 void allocateBorders( int bsx, int bsy = -1, int bsz = -1 );
370 void allocateBorders( const std::vector<int> & border );
371
372 //========================================================================
373 // COPY / VIEW
374 //========================================================================
375
380 template <typename OUTP>
385 template <typename OUTP>
387
391 template <typename OUTP>
393
399 void copySubVolume( const Volume<T> & source,
400 const std::vector<int> & pos = std::vector<int>() );
406 void copySubVolume( const rc_ptr<Volume<T> > & source,
407 const std::vector<int> & pos = std::vector<int>() );
408
410 template <typename OUTP>
411 operator Volume<OUTP>() const;
412
415 int getLevelsCount() const;
416
421 int refLevel(const int level) const;
422
430
437 rc_ptr<Volume<T> > refVolumeAtLevel(const int level) const;
438
440 void setRefVolume(const rc_ptr<Volume<T> > & refvol);
442 const Position & posInRefVolume() const;
444 Position posInRefVolumeAtLevel(const int level) const;
445
447 void setPosInRefVolume(const Position4Di & pos);
448 void setPosInRefVolume(const Position & pos);
449
450
462 std::vector<int> getBorders() const;
463
466 std::vector<long> getStrides() const;
467
468 //========================================================================
469 // BOOLEANS / ACCUMULATED VALUES
470 //========================================================================
473 operator bool() const;
475 bool all() const;
477 bool any() const;
478 T min() const;
479 T max() const;
483
484 //========================================================================
485 // FILL / REPLACE
486 //========================================================================
488 void fill( const T & value );
494 void fillBorder( const T & value );
495
497 const Referential & referential() const;
500
515 Volume<T> & operator= ( const T & value );
516
530 void flipToOrientation( const std::string & orient );
539 void flipToOrientation( const std::string & orient,
540 const std::string & force_memory_layout );
542 Object reorientedHeader( const std::string & orient ) const;
550 std::vector<int> memoryLayoutOrientation() const;
561 std::vector<int> storageLayoutOrientation() const;
562
563 protected:
564 //========================================================================
565 // PRIVATE UTILS
566 //========================================================================
567 void allocate( int oldSizeX, int oldSizeY, int oldSizeZ, int oldSizeT,
568 bool allocate, const AllocatorContext& allocatorContext,
569 const std::vector<long> *strides = 0 );
570 void allocate( const std::vector<int> & oldSize,
571 bool allocate, const AllocatorContext& allocatorContext,
572 const std::vector<long> *strides = 0 );
573 void slotSizeChanged( const PropertyFilter& propertyFilter );
575
576 void constructBorders( const Position & bordersize,
577 const AllocatorContext& allocatorContext,
578 bool allocated );
579
580 AllocatedVector<T> _items;
581 // in case of negative strides, _start adds an offset to _items 1st element
583 blitz::Array<T, Volume<T>::DIM_MAX> _blitz;
585 std::vector<int> _pos;
587 };
588
589//============================================================================
590// POSITION VECTOR
591//============================================================================
592 template <typename T>
594 {
595 public:
596 explicit Position4Di( int x = 0, int y = 0, int z = 0, int t = 0 )
597 : _coords( 4 )
598 {
599 _coords[0] = x;
600 _coords[1] = y;
601 _coords[2] = z;
602 _coords[3] = t;
603 }
604
609 template <typename U>
610 Position4Di( const U & other ):
611 _coords(4)
612 {
613 for( size_t i = 0; i < size_t( other.size() ) && i < 4; ++i )
614 _coords[i] = other[i];
615 for( size_t i = size_t( other.size() ); i < 4; ++i )
616 _coords[i] = 0;
617 }
618
619 Position4Di( const Position4Di & pos ) : _coords( pos._coords )
620 {
621 }
622
624
625 int & operator [] ( int coord ) { return _coords[ coord ]; }
626 const int & operator [] ( int coord ) const { return _coords[ coord ]; }
627
628 bool operator==(const Position4Di& p) const
629 {
630 return ( _coords == p._coords );
631 }
632 bool operator!=(const Position4Di& p) const
633 { return !(this->operator ==(p)); }
634
635 unsigned size() const { return _coords.size(); }
636 const std::vector<int> & toVector() const
637 { return _coords; }
638
639 /* utility functions, not really related, but which we don't really know
640 where to put them */
641 static std::vector<int> fixed_position( const std::vector<int> & vec )
642 {
643 if( vec.size() >= 4 )
644 return vec;
645 std::vector<int> fixed( vec );
646 fixed.resize( 4 );
647 for( int i=vec.size(); i<4; ++i )
648 fixed[i] = 0;
649 return fixed;
650 }
651
652 static std::vector<int> fixed_size( const std::vector<int> & vec )
653 {
654 if( vec.size() >= 4 )
655 return vec;
656 std::vector<int> fixed( vec );
657 fixed.resize( 4 );
658 for( int i=vec.size(); i<4; ++i )
659 fixed[i] = 1;
660 return fixed;
661 }
662
663 static unsigned long long size_num_elements( const std::vector<int> & vec )
664 {
665 int i, n = vec.size();
666 unsigned long long num = 1;
667 for( i=0; i<n; ++i )
668 num *= vec[i];
669 return num;
670 }
671
672 private:
673 std::vector<int> _coords;
674 };
675
676//============================================================================
677// UTILITIES
678//============================================================================
679#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
680
681 template <typename T>
683 {
684 public:
685 static std::string objectType()
686 { return "CartoVolume"; }
687 static std::string dataType()
688 { return DataTypeCode<T>::dataType(); }
689 static std::string name()
690 {
691 return std::string("carto_volume of ") + DataTypeCode< T >::name();
692 }
693 };
694
695 template <typename T>
696 class Creator<Volume<T> >
697 {
698 public:
699 static Volume<T>* create( Object, const AllocatorContext &, Object );
700 static void setup( Volume<T> &, Object, const AllocatorContext &, Object );
701 };
702
703#endif
704
705//============================================================================
706// STREAM
707//============================================================================
708
709#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
710
711 // Warper for output streams that integrates parameters for volume
712 // printing
713 class VolumeOStream // : public std::ostream // is not really a stream
714 {
715 public:
716 VolumeOStream( std::ostream & ostream );
717 VolumeOStream( const VolumeOStream & other );
719
720 std::ostream & ostream() const;
721
722 const size_t & maxT() const;
723 const size_t & maxZ() const;
724 const size_t & maxY() const;
725 const size_t & maxX() const;
726
727 size_t & maxT();
728 size_t & maxZ();
729 size_t & maxY();
730 size_t & maxX();
731
732 private:
733 size_t _maxT;
734 size_t _maxZ;
735 size_t _maxY;
736 size_t _maxX;
737 std::ostream & _ostream;
738 };
739
740 // Object returned by setMaxDim used to set Volume printing parameters
742 {
743 public:
745
746 const size_t & maxT() const;
747 const size_t & maxZ() const;
748 const size_t & maxY() const;
749 const size_t & maxX() const;
750
751 size_t & maxT();
752 size_t & maxZ();
753 size_t & maxY();
754 size_t & maxX();
755
756 private:
757 size_t _maxT;
758 size_t _maxZ;
759 size_t _maxY;
760 size_t _maxX;
761 };
762
763 VolumeOStream operator<< ( std::ostream & out,
764 const VolumeOStreamSetter & setter );
765
766 template <typename T>
767 std::ostream & operator<< ( const VolumeOStream & out,
768 const Volume<T> & volume );
769
770 // Method used to set Volume printing parameters
772 VolumeOStreamSetter setMaxDim( size_t mx, size_t my, size_t mz, size_t mt );
773
774 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
775
776
793 template <typename T>
794 std::ostream & operator<< ( std::ostream & out,
795 const Volume<T> & volume );
796
797
799 template <typename T>
800 void displayRefVolumes(const Volume<T> & vol);
801
802} // namespace carto:
803
804
805// the CT macro defined in blitz++ interferes with QColor::CT in Qt
806# ifdef CT
807# undef CT
808# endif
809
810#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:685
static std::string dataType()
Definition volumebase.h:687
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:619
static std::vector< int > fixed_position(const std::vector< int > &vec)
Definition volumebase.h:641
bool operator!=(const Position4Di &p) const
Definition volumebase.h:632
static std::vector< int > fixed_size(const std::vector< int > &vec)
Definition volumebase.h:652
Position4Di(int x=0, int y=0, int z=0, int t=0)
Definition volumebase.h:596
static unsigned long long size_num_elements(const std::vector< int > &vec)
Definition volumebase.h:663
Position4Di(const U &other)
Generic constructor from any "vector-like" object, i.e.
Definition volumebase.h:610
const std::vector< int > & toVector() const
Definition volumebase.h:636
unsigned size() const
Definition volumebase.h:635
bool operator==(const Position4Di &p) const
Definition volumebase.h:628
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:585
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:584
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:586
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(rc_ptr< Volume< T > > other, const Position &pos, const Position &size=Position(), const AllocatorContext &allocContext=AllocatorContext())
This is the volume view constructor.
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)
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.
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
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())
This is the volume view constructor.
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:583
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:580
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