cartodata  4.7.0
volumebase_d.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_D_H
35 #define CARTODATA_VOLUME_VOLUMEBASE_D_H
36 
37 //--- cartodata --------------------------------------------------------------
44 //--- cartobase --------------------------------------------------------------
45 #include <cartobase/type/limits.h>
50 //--- soma-io ----------------------------------------------------------------
52 //--- std --------------------------------------------------------------------
53 #include <cstdlib>
54 #include <algorithm>
55 #include <stdexcept>
56 #include <string>
57 #include <stdio.h>
58 //----------------------------------------------------------------------------
59 
60 namespace carto
61 {
62 //============================================================================
63 // CONSTRUCTORS
64 //============================================================================
65 
66  /***************************************************************************
67  * Default Constructor
68  **************************************************************************/
69  template < typename T >
70  Volume< T >::Volume( int sizeX, int sizeY, int sizeZ, int sizeT,
71  const AllocatorContext& allocatorContext,
72  bool allocated )
73  : VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
74  _items( 0U, allocatorContext ),
75 #ifndef CARTO_USE_BLITZ
76  _lineoffset( 0 ),
77  _sliceoffset( 0 ),
78  _volumeoffset( 0 ),
79 #endif
80  _pos( 4, 0 )
81  {
82  allocate( -1, -1, -1, -1, allocated, allocatorContext );
83  }
84 
85  template < typename T >
87  const AllocatorContext& allocatorContext,
88  bool allocated ):
89  VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
90  size[1] > 0 ? size[1] : 1,
91  size[2] > 0 ? size[2] : 1,
92  size[3] > 0 ? size[3] : 1 ),
93  _items( 0U, allocatorContext ),
94 #ifndef CARTO_USE_BLITZ
95  _lineoffset( 0 ),
96  _sliceoffset( 0 ),
97  _volumeoffset( 0 ),
98 #endif
99  _pos( 4, 0 )
100  {
101  allocate( -1, -1, -1, -1, allocated, allocatorContext );
102  }
103 
104  /***************************************************************************
105  * Constructor with border
106  **************************************************************************/
107 
108  template < typename T >
109  void Volume< T >::constructBorders( const Position & bordersize,
110  const AllocatorContext& allocatorContext,
111  bool allocated )
112  {
113  if( !bordersize.empty()
114  && bordersize != Position4Di().toVector() )
115  {
116  size_t i, n = VolumeProxy<T>::_size.size();
117  size_t bsize = sizeof(T);
118  std::vector<int> large_size( n );
119  for( i=0; i<n; ++i )
120  {
121  large_size[i] = VolumeProxy<T>::_size[i];
122  if( i < bordersize.size() )
123  large_size[i] += bordersize[i] * 2;
124  bsize *= VolumeProxy<T>::_size[i];
125  }
126  _refvol.reset( new Volume<T>( large_size,
127  allocatorContext, allocated ) );
128 
129  allocate( -1, -1, -1, -1, true,
130  _refvol->allocatorContext().isAllocated()
131  ? AllocatorContext( AllocatorStrategy::NotOwner,
132  rc_ptr<DataSource>( new BufferDataSource
133  ( (char *) &(*_refvol)( bordersize ),
134  bsize ) ) )
135  : allocatorContext );
136  if( _refvol->allocatorContext().isAllocated() )
137  {
138  // fix offsets
139 #ifdef CARTO_USE_BLITZ
140  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
141  int i, n=VolumeProxy<T>::_size.size();
142  for(i=0; i<n; ++i )
143  dims[i] = VolumeProxy<T>::_size[i];
144  for( ; i<Volume<T>::DIM_MAX; ++i )
145  dims[i] = 1;
146  _blitz.reference
147  ( blitz::Array<T,8>
148  ( &_items[0],
149  dims,
150  _refvol->_blitz.stride(),
151  blitz::GeneralArrayStorage<8>
152  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
153 #else
154  _lineoffset = &(*_refvol)( 0, 1, 0 ) - &(*_refvol)( 0, 0, 0 );
155  _sliceoffset = &(*_refvol)( 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
156  _volumeoffset = &(*_refvol)( 0, 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
157 #endif
158  }
159  }
160  else // no border
161  {
162  allocate( -1, -1, -1, -1, allocated, allocatorContext );
163  }
164  }
165 
166  template < typename T >
167  Volume< T >::Volume( int sizeX, int sizeY, int sizeZ, int sizeT,
168  const Position4Di & bordersize,
169  const AllocatorContext& allocatorContext,
170  bool allocated )
171  : VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
172  _items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
173  DataSource::none() ) ),
174 #ifndef CARTO_USE_BLITZ
175  _lineoffset( 0 ),
176  _sliceoffset( 0 ),
177  _volumeoffset( 0 ),
178 #endif
179  _pos( bordersize.toVector() )
180  {
181  constructBorders( bordersize.toVector(), allocatorContext, allocated );
182  }
183 
184  template < typename T >
186  const Position4Di & bordersize,
187  const AllocatorContext& allocatorContext,
188  bool allocated ):
189  VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
190  size[1] > 0 ? size[1] : 1,
191  size[2] > 0 ? size[2] : 1,
192  size[3] > 0 ? size[3] : 1 ),
193  _items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
194  DataSource::none() ) ),
195 #ifndef CARTO_USE_BLITZ
196  _lineoffset( 0 ),
197  _sliceoffset( 0 ),
198  _volumeoffset( 0 ),
199 #endif
200  _pos( bordersize.toVector() )
201  {
202  constructBorders( bordersize.toVector(), allocatorContext, allocated );
203  }
204 
205  template < typename T >
206  Volume< T >::Volume( int sizeX, int sizeY, int sizeZ,
207  int sizeT, int bordersize,
208  const AllocatorContext& allocatorContext,
209  bool allocated )
210  : VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
211  _items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
212  DataSource::none() ) ),
213 #ifndef CARTO_USE_BLITZ
214  _lineoffset( 0 ),
215  _sliceoffset( 0 ),
216  _volumeoffset( 0 ),
217 #endif
218  _pos( 4, 0 )
219  {
220  _pos[0] = bordersize;
221  _pos[1] = bordersize;
222  _pos[2] = bordersize;
223 
225  Position4Di( bordersize, bordersize, bordersize, 0 ).toVector(),
226  allocatorContext, allocated );
227  }
228 
229  template < typename T >
231  int bordersize,
232  const AllocatorContext& allocatorContext,
233  bool allocated ):
234  VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
235  size[1] > 0 ? size[1] : 1,
236  size[2] > 0 ? size[2] : 1,
237  size[3] > 0 ? size[3] : 1 ),
238  _items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
239  DataSource::none() ) ),
240 #ifndef CARTO_USE_BLITZ
241  _lineoffset( 0 ),
242  _sliceoffset( 0 ),
243  _volumeoffset( 0 ),
244 #endif
245  _pos( 4, 0 )
246  {
247  _pos[0] = bordersize;
248  _pos[1] = bordersize;
249  _pos[2] = bordersize;
251  Position4Di( bordersize, bordersize, bordersize, 0 ).toVector(),
252  allocatorContext, allocated );
253  }
254 
255 
256  template < typename T >
257  Volume< T >::Volume( const std::vector<int> & size,
258  const AllocatorContext& allocatorContext,
259  bool allocated ):
260  VolumeProxy< T >( size ),
261  _items( 0U, allocatorContext ),
262 #ifndef CARTO_USE_BLITZ
263  _lineoffset( 0 ),
264  _sliceoffset( 0 ),
265  _volumeoffset( 0 ),
266 #endif
267  _pos( 4, 0 )
268  {
269  allocate( std::vector<int>( 1, -1 ), allocated, allocatorContext );
270  }
271 
272 
273  template < typename T >
274  Volume< T >::Volume( const std::vector<int> & size,
275  const std::vector<int> & bordersize,
276  const AllocatorContext& allocatorContext,
277  bool allocated ):
278  VolumeProxy< T >( size ),
279  _items( 0U, AllocatorContext( AllocatorStrategy::NotOwner,
280  DataSource::none() ) ),
281 #ifndef CARTO_USE_BLITZ
282  _lineoffset( 0 ),
283  _sliceoffset( 0 ),
284  _volumeoffset( 0 ),
285 #endif
286  _pos( bordersize )
287  {
288  while( _pos.size() < 4 )
289  _pos.push_back( 0 );
290  constructBorders( bordersize, allocatorContext, allocated );
291  }
292 
293  /***************************************************************************
294  * Buffer Constructor
295  **************************************************************************/
296  template < typename T >
297  Volume< T >::Volume( int sizeX, int sizeY, int sizeZ, int sizeT, T* buffer )
298  : VolumeProxy< T >( sizeX, sizeY, sizeZ, sizeT ),
299  _items( sizeX * sizeY * sizeZ * sizeT, buffer ),
300 #ifndef CARTO_USE_BLITZ
301  _lineoffset( 0 ),
302  _sliceoffset( 0 ),
303  _volumeoffset( 0 ),
304 #endif
305  _pos( 4, 0 )
306  {
307  allocate( -1, -1, -1, -1, true, allocatorContext() );
308  }
309 
310 
311  template < typename T >
312  Volume< T >::Volume( const Position4Di & size, T* buffer ):
313  VolumeProxy< T >( size[0] > 0 ? size[0] : 1,
314  size[1] > 0 ? size[1] : 1,
315  size[2] > 0 ? size[2] : 1,
316  size[3] > 0 ? size[3] : 1 ),
317  _items( (long)(size[0] > 0 ? size[0] : 1) *
318  (long)(size[1] > 0 ? size[1] : 1) *
319  (long)(size[2] > 0 ? size[2] : 1) *
320  (long)(size[3] > 0 ? size[3] : 1), buffer ),
321 #ifndef CARTO_USE_BLITZ
322  _lineoffset( 0 ),
323  _sliceoffset( 0 ),
324  _volumeoffset( 0 ),
325 #endif
326  _pos( 4, 0 )
327  {
328  allocate( -1, -1, -1, -1, true, allocatorContext() );
329  }
330 
331 
332  template < typename T >
333  Volume< T >::Volume( const std::vector<int> & size, T* buffer ):
334  VolumeProxy< T >( size ),
335  _items( (long) Position4Di::size_num_elements( size ), buffer ),
336 #ifndef CARTO_USE_BLITZ
337  _lineoffset( 0 ),
338  _sliceoffset( 0 ),
339  _volumeoffset( 0 ),
340 #endif
341  _pos( 4, 0 )
342  {
343  allocate( std::vector<int>( 1, -1 ), true, allocatorContext() );
344  }
345 
346 
347  /***************************************************************************
348  * View Constructor
349  **************************************************************************/
350  template<typename T> inline
352  const Position4Di & pos, const Position4Di & size,
353  const AllocatorContext & allocContext )
354  : VolumeProxy<T>( size[0] >= 0 ? size[0] :
355  other->allocatorContext().isAllocated() ? other->getSizeX() : 1,
356  size[1] >= 0 ? size[1] :
357  other->allocatorContext().isAllocated() ? other->getSizeY() : 1,
358  size[2] >= 0 ? size[2] :
359  other->allocatorContext().isAllocated() ? other->getSizeZ() : 1,
360  size[3] >= 0 ? size[3] :
361  other->allocatorContext().isAllocated() ? other->getSizeT() : 1 ),
362  _items( 0U, allocContext ),
363  _refvol( other ),
364 #ifndef CARTO_USE_BLITZ
365  _lineoffset( 0 ),
366  _sliceoffset( 0 ),
367  _volumeoffset( 0 ),
368 #endif
369  _pos( pos.toVector() )
370  {
371  if( other->allocatorContext().isAllocated() )
372  {
373  size_t bsize = sizeof(T);
374  int i, n = size.size();
375  for( i=0; i<n; ++i )
376  bsize *= size[i];
377 
378  allocate( -1, -1, -1, -1, true,
379  AllocatorContext( AllocatorStrategy::NotOwner,
380  rc_ptr<DataSource>( new BufferDataSource
381  ( (char *) &(*other)( pos.toVector() ),
382  bsize ) ) ) );
383  // fix offsets
384 #ifdef CARTO_USE_BLITZ
385  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
386  n = VolumeProxy<T>::_size.size();
387  for( i=0; i<n; ++i )
388  dims[i] = VolumeProxy<T>::_size[i];
389  for( ; i<Volume<T>::DIM_MAX; ++i )
390  dims[i] = 1;
391  _blitz.reference
392  ( blitz::Array<T,Volume<T>::DIM_MAX>
393  ( &_items[0],
394  dims,
395  other->_blitz.stride(),
396  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
397  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
398 #else
399  _lineoffset = &(*other)( 0, 1, 0 ) - &(*other)( 0, 0, 0 );
400  _sliceoffset = &(*other)( 0, 0, 1 ) - &(*other)( 0, 0, 0 );
401  _volumeoffset = &(*other)( 0, 0, 0, 1 ) - &(*other)( 0, 0, 0 );
402 #endif
403  }
404  else
405  allocate( -1, -1, -1, -1, true, allocContext );
406 
407  /* copy voxel_size from underlying volume, if any.
408  This should probably be more general, but cannot be applied to all
409  header properties (size, transformations...).
410  WARNING: Moreover here we do not guarantee to keep both voxel_size
411  unique: we point to the same vector of values for now, but it can be
412  replaced (thus, duplicated) by a setProperty().
413  We could use a addBuiltinProperty(), but then the voxel size has to be
414  stored in a fixed location somewhere.
415  */
416  try
417  {
418  carto::Object vs = other->header().getProperty( "voxel_size" );
419  size_t n = this->getSize().size();
420  if( vs->size() > n )
421  {
422  // drop additional sizes
423  size_t i;
424  std::vector<carto::Object> vs2( n );
425  for( i=0; i<n; ++i )
426  vs2[i] = vs->getArrayItem( i );
427  this->header().setProperty( "voxel_size", vs2 );
428  }
429  else
430  this->header().setProperty( "voxel_size", vs );
431  }
432  catch( ... )
433  {
434  // never mind.
435  }
436  }
437 
438 
439  template<typename T> inline
441  const Position & pos, const Position & size,
442  const AllocatorContext & allocContext )
443  : VolumeProxy<T>( Position4Di::fixed_size( size ) ),
444  _items( 0U, allocContext ),
445  _refvol( other ),
446 #ifndef CARTO_USE_BLITZ
447  _lineoffset( 0 ),
448  _sliceoffset( 0 ),
449  _volumeoffset( 0 ),
450 #endif
451  _pos( Position4Di::fixed_position( pos ) )
452  {
453  if( other->allocatorContext().isAllocated() )
454  {
455  size_t bsize = sizeof(T);
456  int i, n = size.size();
457  for( i=0; i<n; ++i )
458  bsize *= size[i];
459 
460  allocate( -1, -1, -1, -1, true,
461  AllocatorContext( AllocatorStrategy::NotOwner,
462  rc_ptr<DataSource>( new BufferDataSource
463  ( (char *) &(*other)( pos ),
464  bsize ) ) ) );
465 
466  // fix offsets
467 #ifdef CARTO_USE_BLITZ
468  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
469  n = VolumeProxy<T>::_size.size();
470  for(i=0; i<n; ++i )
471  dims[i] = VolumeProxy<T>::_size[i];
472  for( ; i<Volume<T>::DIM_MAX; ++i )
473  dims[i] = 1;
474  _blitz.reference
475  ( blitz::Array<T,Volume<T>::DIM_MAX>
476  ( &_items[0],
477  dims,
478  other->_blitz.stride(),
479  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
480  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
481 #else
482  _lineoffset = &(*other)( 0, 1, 0 ) - &(*other)( 0, 0, 0 );
483  _sliceoffset = &(*other)( 0, 0, 1 ) - &(*other)( 0, 0, 0 );
484  _volumeoffset = &(*other)( 0, 0, 0, 1 ) - &(*other)( 0, 0, 0 );
485 #endif
486  }
487  else
488  allocate( -1, -1, -1, -1, true, allocContext );
489 
490  /* copy voxel_size from underlying volume, if any.
491  This should probably be more general, but cannot be applied to all
492  header properties (size, transformations...).
493  WARNING: Moreover here we do not guarantee to keep both voxel_size
494  unique: we point to the same vector of values for now, but it can be
495  replaced (thus, duplicated) by a setProperty().
496  We could use a addBuiltinProperty(), but then the voxel size has to be
497  stored in a fixed location somewhere.
498  */
499  try
500  {
501  carto::Object vs = other->header().getProperty( "voxel_size" );
502  size_t n = this->getSize().size();
503  if( vs->size() > n )
504  {
505  // drop additional sizes
506  size_t i;
507  std::vector<carto::Object> vs2( n );
508  for( i=0; i<n; ++i )
509  vs2[i] = vs->getArrayItem( i );
510  this->header().setProperty( "voxel_size", vs2 );
511  }
512  else
513  this->header().setProperty( "voxel_size", vs );
514  }
515  catch( ... )
516  {
517  // never mind.
518  }
519  }
520 
521 
522  /***************************************************************************
523  * Copy Constructor
524  **************************************************************************/
525  template < typename T >
527  : RCObject(),
528  VolumeProxy< T >( other ),
529  _items( other._items ),
530 #ifdef CARTO_USE_BLITZ
531  // TODO: test blitz ownership / strides
532  // _blitz = other.blitz;
533  _blitz( &_items[0],
534  other._blitz.shape(),
535  blitz::GeneralArrayStorage<8>
536  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ),
537 #else
538  _lineoffset( other._lineoffset ),
539  _sliceoffset( other._sliceoffset ),
540  _volumeoffset( other._volumeoffset ),
541 #endif
542  _refvol( other.refVolume().get() ?
543  new Volume<T>( *other.refVolume() ) : 0 ),
544  _pos( other.posInRefVolume() )
545  {
546  if( _refvol.get() ) // view case: the underlying volume is copied.
547  {
548  Position4Di pos = other.posInRefVolume();
549  std::vector<int> oldSize(1, -1);
550  allocate( oldSize, true, _refvol->allocatorContext().isAllocated()
551  ? AllocatorContext( AllocatorStrategy::NotOwner,
552  rc_ptr<DataSource>( new BufferDataSource
553  ( (char *) &(*_refvol)( pos[0], pos[1], pos[2], pos[3] ),
557  * sizeof(T) ) ) )
558  : AllocatorContext( other.allocatorContext() ) );
559  if( _refvol->allocatorContext().isAllocated() )
560  {
561  // fix offsets
562 #ifdef CARTO_USE_BLITZ
563  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
564  int i, n=VolumeProxy<T>::_size.size();
565  for( i=0; i<n; ++i )
566  dims[i] = VolumeProxy<T>::_size[i];
567  for( ; i<Volume<T>::DIM_MAX; ++i )
568  dims[i] = 1;
569  _blitz.reference
570  ( blitz::Array<T,Volume<T>::DIM_MAX>
571  ( &_items[0],
572  dims,
573  other._blitz.stride(),
574  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
575  ( blitz::shape( 0, 1, 2, 3, 5, 6, 7, 8 ), true ) ) );
576 #else
577  _lineoffset = &other( 0, 1, 0 ) - &other( 0, 0, 0 );
578  _sliceoffset = &other( 0, 0, 1 ) - &other( 0, 0, 0 );
579  _volumeoffset = &other( 0, 0, 0, 1 ) - &other( 0, 0, 0 );
580 #endif
581  }
582  }
583  }
584 
585  template < typename T >
587  {
588  }
589 
590 //============================================================================
591 // M E T H O D S
592 //============================================================================
593 
594  template < typename T > inline
595  const AllocatorContext& Volume<T>::allocatorContext() const
596  {
597  return _items.allocatorContext();
598  }
599 
600  template <typename T> inline
602  {
603  return _refvol;
604  }
605 
606  template <typename T> inline
608  {
609  return _pos;
610  }
611 
612  template <typename T>
613  inline
615  int l = 0;
616  rc_ptr<Volume<T> > v(const_cast<Volume<T> *>(this));
617  while (!v.isNull()) {
618  l++;
619  v = v->refVolume();
620  }
621  return l;
622  }
623 
624  template <typename T>
625  inline
626  int Volume<T>::refLevel(const int level) const {
627  int c = getLevelsCount();
628  int l = level;
629  if (l < 0) {
630  l = c + l;
631  }
632 
633  if ((l < 0) && (l >= c)) {
634  throw std::out_of_range("level " + carto::toString(level)
635  + " is out range (" + carto::toString(-c)
636  + ", " + carto::toString(c-1) + ")");
637  }
638 
639  return l;
640  }
641 
642  template <typename T>
643  inline
645  int l = refLevel(level);
646  int c = 0;
647  rc_ptr<Volume<T> > v(const_cast<Volume<T> *>(this));
648 
649  while ((c < l) && (!v.isNull())) {
650  v = v->refVolume();
651  c++;
652  }
653 
654  return v;
655  }
656 
657  template <typename T>
658  inline
660  const int level) const {
661  int l = refLevel(level);
662  size_t s = this->getSize().size();
663  typename Volume<T>::Position offset(s, 0);
664  int c = 0;
665  rc_ptr<Volume<T> > v(const_cast<Volume<T> *>(this));
666  while ((c < l) && (!v.isNull())) {
667  const Position & pos = v->posInRefVolume();
668 
669  for (size_t i = 0; i < s; ++i)
670  offset[i] += pos[i];
671 
672  v = v->refVolume();
673  c++;
674  }
675 
676  return offset;
677  }
678 
679  template <typename T> inline
681  {
682 
683  if ( !allocatorContext().isAllocated()
684  || (allocatorContext().accessMode() == AllocatorStrategy::NotOwner) )
685  {
686 
687  // Free old buffer
688  _items.free();
689 
690  if (_refvol.get())
691  {
692  // Recreate items buffer that reference volume
693  // using correct sizes and position
694  if( _refvol->allocatorContext().isAllocated() )
695  {
696  size_t size = sizeof(T);
697  int i, n = VolumeProxy<T>::_size.size();
698  for( i=0; i<n; ++i )
699  size *= VolumeProxy<T>::_size[i];
700  _items.allocate(
701  0U,
702  AllocatorContext( AllocatorStrategy::NotOwner,
703  rc_ptr<DataSource>( new BufferDataSource
704  ( (char *) &(*(_refvol))( _pos ),
705  size ) ) ) );
706  }
707  else
708  _items.allocate( 0U, allocatorContext() );
709 
710  if ( _refvol->allocatorContext().isAllocated() )
711  {
712  // fix offsets
713 #ifdef CARTO_USE_BLITZ
714  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
715  int i, n=VolumeProxy<T>::_size.size();
716  for( i=0; i<n; ++i )
717  dims[i] = VolumeProxy<T>::_size[i];
718  for( ; i<Volume<T>::DIM_MAX; ++i )
719  dims[i] = 1;
720  _blitz.reference
721  ( blitz::Array<T,Volume<T>::DIM_MAX>
722  ( &_items[0],
723  dims,
724  _refvol->_blitz.stride(),
725  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
726  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
727 #else
728  _lineoffset = &(*_refvol)( 0, 1, 0 ) - &(*_refvol)( 0, 0, 0 );
729  _sliceoffset = &(*_refvol)( 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
730  _volumeoffset = &(*_refvol)( 0, 0, 0, 1 ) - &(*_refvol)( 0, 0, 0 );
731 #endif
732  }
733 
734  /* copy voxel_size from underlying volume, if any.
735  This should probably be more general, but cannot be applied to all
736  header properties (size, transformations...).
737  WARNING: Moreover here we do not guarantee to keep both voxel_size
738  unique: we point to the same vector of values for now, but it can be
739  replaced (thus, duplicated) by a setProperty().
740  We could use a addBuiltinProperty(), but then the voxel size has to be
741  stored in a fixed location somewhere.
742  */
743  try
744  {
745  carto::Object vs = _refvol->header().getProperty( "voxel_size" );
746  this->header().setProperty( "voxel_size", vs );
747  }
748  catch( ... )
749  {
750  // never mind.
751  }
752  }
753  }
754  }
755 
756  template <typename T> inline
758  {
759  if ( pos != _pos )
760  {
761  _pos = pos.toVector();
763  }
764  }
765 
766 
767  template <typename T> inline
769  if (pos != _pos)
770  {
771  _pos = pos;
772  while( _pos.size() < 4 )
773  _pos.push_back( 0 );
775  }
776  }
777 
778  template <typename T> inline
779  void Volume<T>::setRefVolume( const rc_ptr<Volume<T> > & refvol) {
780  if (refvol.get() != _refvol.get()) {
781  _refvol = refvol;
783  }
784  }
785 
786  template <typename T> inline
787  std::vector<int> Volume<T>::getBorders() const
788  {
789  std::vector<int> borders( VolumeProxy<T>::_size.size() * 2, 0 );
790  if( _refvol.get() && _refvol->allocatorContext().isAllocated() )
791  {
792  int i, n = VolumeProxy<T>::_size.size();
793  for( i=0; i<n; ++i )
794  borders[i*2 + 1] = _refvol->_size[i] - VolumeProxy<T>::_size[i];
795  for( i=0, n=_pos.size(); i<n; ++i )
796  {
797  borders[i*2] = _pos[i];
798  borders[i*2+1] -= _pos[i];
799  }
800  }
801 
802  return borders;
803  }
804 
805  template <typename T> inline
806  std::vector<size_t> Volume<T>::getStrides() const
807  {
808 
809 #ifdef CARTO_USE_BLITZ
810  const blitz::TinyVector<BlitzStridesType, Volume<T>::DIM_MAX>& bstrides = _blitz.stride();
811  int d, n = VolumeProxy<T>::_size.size();
812  std::vector<size_t> strides( n );
813  for (d = 0; d < n; ++d)
814  strides[d] = bstrides[d];
815 #else
816  std::vector<size_t> strides(4);
817 
818  strides[0] = 1;
819  strides[1] = _lineoffset;
820  strides[2] = _sliceoffset;
821  strides[3] = _volumeoffset;
822 #endif
823 
824  return strides;
825  }
826 
827  template < typename T >
829  {
830  if( &other == this )
831  return *this;
832 
833  bool b = Headered::signalsBlocked();
834  if( !b )
835  Headered::blockSignals( true );
836  this->VolumeProxy< T >::operator=( other );
837  // copy buffer, preserving allocator
838  _items.copy( other._items, other.allocatorContext() );
839 
840 #ifdef CARTO_USE_BLITZ
841  // TODO: test blitz ownership / strides
842  // _blitz.reference( other.blitz );
843  blitz::TinyVector<long, Volume<T>::DIM_MAX> dims;
844  int i, n = VolumeProxy<T>::_size.size();
845  for( i=0; i<n; ++i )
846  dims[i] = VolumeProxy<T>::_size[i];
847  for( ; i<Volume<T>::DIM_MAX; ++i )
848  dims[i] = 1;
849  _blitz.reference
850  ( blitz::Array<T,Volume<T>::DIM_MAX>
851  ( &_items[0],
852  dims,
853  other._blitz.stride(),
854  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
855  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
856 #else
857  _lineoffset = other._lineoffset;
858  _sliceoffset = other._sliceoffset;
859  _volumeoffset = other._volumeoffset;
860 #endif
861  _refvol = other._refvol;
862  _pos = other._pos;
863 
864  initialize();
865 
866  if( !b )
867  Headered::blockSignals( false );
868 
869  return *this;
870 
871  }
872 
873  template < typename T >
875  {
876 
877 #ifdef CARTO_USE_BLITZ
878  return _blitz.begin();
879 #else
880  return _items.begin();
881 #endif
882 
883  }
884 
885 
886  template < typename T >
888  {
889 
890 #ifdef CARTO_USE_BLITZ
891  return _blitz.end();
892 #else
893  return _items.end();
894 #endif
895 
896  }
897 
898 
899  template < typename T >
901  {
902 
903 #ifdef CARTO_USE_BLITZ
904  return _blitz.begin();
905 #else
906  return _items.begin();
907 #endif
908 
909  }
910 
911 
912  template < typename T >
914  {
915 
916 #ifdef CARTO_USE_BLITZ
917  return _blitz.end();
918 #else
919  return _items.end();
920 #endif
921 
922  }
923 
924 
925  template < typename T >
927  {
928 
929  // initializing headered stuff
930  this->Headered::initialize();
931 
932  // creating size filter
933  std::set< std::string > sizePropertyNames;
934  sizePropertyNames.insert( "sizeX" );
935  sizePropertyNames.insert( "sizeY" );
936  sizePropertyNames.insert( "sizeZ" );
937  sizePropertyNames.insert( "sizeT" );
938  sizePropertyNames.insert( "volume_dimension" );
940  sizeRcPropertyFilter( new PropertyFilter( "size", sizePropertyNames ) );
941 
942  // adding size filter to headered and connecting signal to slot
943  Headered::addPropertyFilter( sizeRcPropertyFilter );
944  Headered::connect( sizeRcPropertyFilter->getName(),
945  ::sigc::mem_fun( *this, &Volume< T >::slotSizeChanged ) );
946 
947  }
948 
949 
950  template < typename T >
951  void Volume< T >::allocate( int oldSizeX,
952  int oldSizeY,
953  int oldSizeZ,
954  int oldSizeT,
955  bool allocate,
956  const AllocatorContext& ac )
957  {
958  std::vector<int> oldSize(4);
959  oldSize[0] = oldSizeX;
960  oldSize[1] = oldSizeY;
961  oldSize[2] = oldSizeZ;
962  oldSize[3] = oldSizeT;
963  Volume< T >::allocate( oldSize, allocate, ac );
964  }
965 
966 
967  template < typename T >
968  void Volume< T >::allocate( const std::vector<int> & oldSize,
969  bool allocate,
970  const AllocatorContext& ac )
971  {
972 
973  std::vector<unsigned long long int> strides(Volume<T>::DIM_MAX, 0);
974  int i, n = oldSize.size(), nn = VolumeProxy<T>::_size.size();
975 
976  for( i=0; i<nn; ++i )
977  {
978  strides[i] = ( i == 0 ? VolumeProxy<T>::_size[0]
979  : VolumeProxy<T>::_size[i] * strides[i-1] );
980  }
981  for( ; i<Volume<T>::DIM_MAX; ++i )
982  strides[i] = strides[i-1];
983 
984  unsigned long long int total_len = strides[nn-1];
985 
986  if ( total_len * sizeof(T) >
987  (unsigned long long int) std::numeric_limits< size_t >::max() )
988  {
989 
990  throw std::runtime_error
991  ( std::string( "attempt to allocate a volume which size is greater "
992  "than allowed by the system (" )
993  + toString( std::numeric_limits< size_t >::max() ) + " bytes)" );
994 
995  }
996 
997  bool no_old = true;
998  for( i=0; i<n; ++i )
999  if( oldSize[i] != -1 )
1000  {
1001  no_old = false;
1002  break;
1003  }
1004 
1005  if ( !allocate // why !allocate ?
1006  || !_items.allocatorContext().isAllocated()
1007  || no_old )
1008  {
1009  // allocating memory space
1010  _items.free();
1011  if( allocate )
1012  _items.allocate( ( size_t ) total_len, ac );
1013  }
1014  else if ( oldSize != VolumeProxy<T>::_size
1015  || &ac != &_items.allocatorContext() )
1016  {
1017 
1018  // allocating a new memory space
1019  AllocatedVector<T> newItems( ( size_t ) total_len, ac );
1020 
1021  std::vector<int> minSize = VolumeProxy<T>::_size;
1022  for( i=0; i<std::min(n, nn); ++i )
1023  if( oldSize[i] < minSize[i] )
1024  minSize[i] = oldSize[i];
1025 
1026  // preserving data
1027  int x, y, z, t;
1028  if( newItems.allocatorContext().allocatorType()
1029  != AllocatorStrategy::ReadOnlyMap )
1030  for ( t = 0; t < minSize[3]; t++ )
1031  {
1032 
1033  for ( z = 0; z < minSize[2]; z++ )
1034  {
1035 
1036  for ( y = 0; y < minSize[1]; y++ )
1037  {
1038 
1039  for ( x = 0; x < minSize[0]; x++ )
1040  {
1041  newItems[ x +
1042  y * strides[0] +
1043  z * ( size_t ) strides[1] +
1044  t * ( size_t ) strides[2] ] =
1045  _items[ x +
1046  y * oldSize[0] +
1047  z * ( size_t ) oldSize[0]
1048  * ( size_t ) oldSize[1] +
1049  t * ( size_t ) oldSize[0] *
1050  ( size_t ) oldSize[1]
1051  * ( size_t ) oldSize[2] ];
1052 
1053  }
1054 
1055  }
1056 
1057  }
1058 
1059  }
1060 
1061  // copying new data to old one
1062  _items = newItems;
1063 
1064  }
1065 
1066  if( allocate )
1067  {
1068 #ifdef CARTO_USE_BLITZ
1069  // TODO: test blitz ownership / strides
1070  /*
1071  std::cout << "alloc blitz: " << VolumeProxy<T>::_size[0] << ", "
1072  << VolumeProxy<T>::_size[1] << ", "
1073  << VolumeProxy<T>::_size[2] << ", "
1074  << VolumeProxy<T>::_size[3] << std::endl;
1075  */
1076  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
1077  for( i=0; i<nn; ++i )
1078  dims[i] = VolumeProxy<T>::_size[i];
1079  for( ; i<Volume<T>::DIM_MAX; ++i )
1080  dims[i] = 1;
1081  _blitz.reference( blitz::Array<T,Volume<T>::DIM_MAX>
1082  ( &_items[0],
1083  dims,
1084  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
1085  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ),
1086  true ) ) );
1087  /*
1088  std::cout << &_items[0] << " / " << &_blitz( 0 ) << std::endl;
1089  std::cout << blitz::shape( VolumeProxy<T>::_size[0],
1090  VolumeProxy<T>::_size[1],
1091  VolumeProxy<T>::_size[2],
1092  VolumeProxy<T>::_size[3}] ) << std::endl;
1093  std::cout << "blitz data: " << _blitz.data() << std::endl;
1094  std::cout << "blitz ordering: " << _blitz.ordering() << std::endl;
1095  std::cout << "blitz numEl: " << _blitz.numElements() << std::endl;
1096  std::cout << "blitz strides: " << _blitz.stride() << std::endl;
1097  */
1098 #else
1099  _lineoffset = VolumeProxy<T>::_size[0];
1100  _sliceoffset = strides[1];
1101  _volumeoffset = strides[2];
1102 #endif
1103  }
1104  else
1105  {
1106 #ifdef CARTO_USE_BLITZ
1107  blitz::TinyVector<int, Volume<T>::DIM_MAX> dims;
1108  for( i=0; i<nn; ++i )
1109  dims[i] = VolumeProxy<T>::_size[i];
1110  for( ; i<Volume<T>::DIM_MAX; ++i )
1111  dims[i] = 1;
1112  // TODO: test blitz ownership / strides
1113  _blitz.reference( blitz::Array<T,Volume<T>::DIM_MAX>
1114  ( 0,
1115  dims,
1116  blitz::GeneralArrayStorage<Volume<T>::DIM_MAX>
1117  ( blitz::shape( 0, 1, 2, 3, 4, 5, 6, 7 ), true ) ) );
1118 #else
1119  _lineoffset = 0;
1120  _sliceoffset = 0;
1121  _volumeoffset = 0;
1122 #endif
1123  }
1124 
1125  }
1126 
1127 
1128  template < typename T >
1130  {
1131  if( !allocatorContext().isAllocated() )
1133  }
1134 
1135 
1136  template < typename T >
1137  void Volume< T >::slotSizeChanged( const PropertyFilter& propertyFilter )
1138  {
1139 
1140  std::cout << "Volume< " << DataTypeCode<T>::name()
1141  << " >::slotSizeChanged"
1142  << std::endl;
1143 
1144  std::vector<int> oldSize = VolumeProxy<T>::_size;
1145 
1146  if ( propertyFilter.hasOldValue( "sizeX" ) )
1147  {
1148 
1149  oldSize[0] =
1150  propertyFilter.getOldValue( "sizeX" )->GenericObject::value< int >();
1151 
1152  }
1153  if ( propertyFilter.hasOldValue( "sizeY" ) )
1154  {
1155 
1156  oldSize[1] =
1157  propertyFilter.getOldValue( "sizeY" )->GenericObject::value< int >();
1158 
1159  }
1160  if ( propertyFilter.hasOldValue( "sizeZ" ) )
1161  {
1162 
1163  oldSize[2] =
1164  propertyFilter.getOldValue( "sizeZ" )->GenericObject::value< int >();
1165 
1166  }
1167  if ( propertyFilter.hasOldValue( "sizeT" ) )
1168  {
1169 
1170  oldSize[3] =
1171  propertyFilter.getOldValue( "sizeT" )->GenericObject::value< int >();
1172 
1173  }
1174  std::cout << "old size: " << oldSize[0] << ", " << oldSize[1] << ", "
1175  << oldSize[2] << ", " << oldSize[3] << std::endl;
1176  std::cout << "new size: " << VolumeProxy<T>::_size[0] << ", "
1177  << VolumeProxy<T>::_size[1] << ", "
1178  << VolumeProxy<T>::_size[2] << ", " << VolumeProxy<T>::_size[3]
1179  << std::endl;
1180  allocate( oldSize,
1181  _items.allocatorContext().isAllocated(), allocatorContext() );
1182 
1183  }
1184 
1185 
1186  template < typename T >
1187  void Volume< T >::reallocate( int sizeX,
1188  int sizeY,
1189  int sizeZ,
1190  int sizeT,
1191  bool keepcontents,
1192  const AllocatorContext & ac,
1193  bool alloc )
1194  {
1195  int oldx = VolumeProxy<T>::_size[0];
1196  int oldy = VolumeProxy<T>::_size[1];
1197  int oldz = VolumeProxy<T>::_size[2];
1198  int oldt = VolumeProxy<T>::_size[3];
1199  VolumeProxy<T>::_size.resize( 4 );
1200  VolumeProxy<T>::_size[0] = sizeX;
1201  VolumeProxy<T>::_size[1] = sizeY;
1202  VolumeProxy<T>::_size[2] = sizeZ;
1203  VolumeProxy<T>::_size[3] = sizeT;
1204  if( keepcontents || ( sizeX == oldx && sizeY == oldy && sizeZ == oldz
1205  && sizeT == oldt ) )
1206  allocate( oldx, oldy, oldz, oldt, alloc, ac );
1207  else
1208  allocate( std::vector<int>(1, -1), alloc, ac );
1209  // emit a signal ?
1210  }
1211 
1212  template < typename T >
1214  bool keepcontents,
1215  const AllocatorContext & ac,
1216  bool alloc )
1217  {
1218  return reallocate( size[0] > 0 ? size[0] : 1,
1219  size[1] > 0 ? size[1] : 1,
1220  size[2] > 0 ? size[2] : 1,
1221  size[3] > 0 ? size[3] : 1,
1222  keepcontents, ac, alloc );
1223  }
1224 
1225  template < typename T >
1226  void Volume< T >::reallocate( const std::vector<int> & size,
1227  bool keepcontents,
1228  const AllocatorContext & ac,
1229  bool alloc )
1230  {
1231  std::vector<int> old = VolumeProxy<T>::_size;
1232 
1233  VolumeProxy<T>::_size = size;
1234  while( VolumeProxy<T>::_size.size() < 4 )
1235  VolumeProxy<T>::_size.push_back( 1 );
1236 
1238  VolumeProxy<T>::_size[0] );
1240  VolumeProxy<T>::_size[1] );
1242  VolumeProxy<T>::_size[2] );
1244  VolumeProxy<T>::_size[3] );
1245 
1246  if( keepcontents || size == old )
1247  allocate( old, alloc, ac );
1248  else
1249  allocate( std::vector<int>(1, -1), alloc, ac );
1250  // emit a signal ?
1251  }
1252 
1253 //============================================================================
1254 // U T I L I T I E S
1255 //============================================================================
1256 
1257  template <typename T>
1258  Volume<T>* Creator<Volume<T> >::create( Object header,
1259  const AllocatorContext & context,
1260  Object options )
1261  {
1262  std::vector<int> dims( 4, 1 );
1263  bool unalloc = false;
1264  if( !header->getProperty( "volume_dimension", dims ) )
1265  {
1266  header->getProperty( "sizeX", dims[0] );
1267  header->getProperty( "sizeY", dims[1] );
1268  header->getProperty( "sizeZ", dims[2] );
1269  header->getProperty( "sizeT", dims[3] );
1270  }
1271  options->getProperty( "unallocated", unalloc );
1272  std::vector<int> borders( 3, 0 );
1273  try {
1274  borders[0] = (int) rint( options->getProperty( "border" )->getScalar() );
1275  borders[1] = (int) rint( options->getProperty( "border" )->getScalar() );
1276  borders[2] = (int) rint( options->getProperty( "border" )->getScalar() );
1277  } catch( ... ) {}
1278  try {
1279  borders[0] = (int) rint( options->getProperty( "bx" )->getScalar() );
1280  } catch( ... ) {}
1281  try {
1282  borders[1] = (int) rint( options->getProperty( "by" )->getScalar() );
1283  } catch( ... ) {}
1284  try {
1285  borders[2] = (int) rint( options->getProperty( "bz" )->getScalar() );
1286  } catch( ... ) {}
1287 
1288  Volume<T> *obj;
1289  if( borders[0] != 0 || borders[1] != 0 || borders[2] != 0 )
1290  {
1291  std::vector<int> big_dims = dims;
1292  big_dims[0] += borders[0] * 2;
1293  big_dims[1] += borders[1] * 2;
1294  big_dims[2] += borders[2] * 2;
1295  obj = new Volume<T>( big_dims, context, !unalloc );
1296  obj = new Volume<T>( rc_ptr<Volume<T> >( obj ), borders, dims, context );
1297  }
1298  else
1299  obj = new Volume<T>( dims, context, !unalloc );
1300  obj->blockSignals( true );
1301  obj->header().copyProperties( header );
1302  // restore original sizes : temporary too...
1303  obj->blockSignals( false );
1304  return obj;
1305  }
1306 
1307  template <typename T>
1308  void Creator<Volume<T> >::setup( Volume<T> & obj, Object header,
1309  const AllocatorContext & context,
1310  Object options )
1311  {
1312  std::vector<int> dims( 4, 1 );
1313  bool unalloc = false, partial = false, keep_allocation = false;
1314  options->getProperty( "partial_reading", partial );
1315  if( !partial )
1316  {
1317  if( !header->getProperty( "volume_dimension", dims ) )
1318  {
1319  header->getProperty( "sizeX", dims[0] );
1320  header->getProperty( "sizeY", dims[1] );
1321  header->getProperty( "sizeZ", dims[2] );
1322  header->getProperty( "sizeT", dims[3] );
1323  }
1324  options->getProperty( "unallocated", unalloc );
1325  options->getProperty( "keep_allocation", keep_allocation );
1326  if( !keep_allocation || !obj.allocatorContext().isAllocated() )
1327  obj.reallocate( dims, false, context, !unalloc );
1328  }
1329  else
1330  {
1331  const_cast<AllocatorContext &>( obj.allocatorContext() ).setDataSource
1332  ( context.dataSource() );
1333  // preserve dimensions
1334  dims = obj.getSize();
1335  }
1336  obj.blockSignals( true );
1337  obj.header().copyProperties( header );
1338  if( partial )
1339  {
1340  // restore dimensions
1341  PropertySet & ps = obj.header();
1342  ps.setProperty( "volume_dimension", dims );
1343  ps.setProperty( "sizeX", dims[0] );
1344  ps.setProperty( "sizeY", dims[1] );
1345  ps.setProperty( "sizeZ", dims[2] );
1346  ps.setProperty( "sizeT", dims[3] );
1347  }
1348  obj.blockSignals( false );
1349  }
1350 
1351 } // namespace carto
1352 
1353 #endif // CARTODATA_VOLUME_VOLUMEBASE_D_H
Volume(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocated=true)
Volume construction and allocation.
Definition: volumebase_d.h:70
void setRefVolume(const rc_ptr< Volume< T > > &refvol)
Set parent volume.
Definition: volumebase_d.h:779
const Position & posInRefVolume() const
Get position in parent volume.
Definition: volumebase_d.h:607
int refLevel(const int level) const
Transform a level index to a valid level index in the volume hierarchy.
Definition: volumebase_d.h:626
N-D Volume main class.
void allocate()
This function is only useful in the particular context of an unallocated Volume, when the constructor...
rc_ptr< Volume< T > > _refvol
Definition: volumebase.h:522
void constructBorders(const Position &bordersize, const AllocatorContext &allocatorContext, bool allocated)
Definition: volumebase_d.h:109
blitz::Array< T, Volume< T >::DIM_MAX > _blitz
Definition: volumebase.h:516
int getSizeZ() const
Definition: volumeproxy.h:107
iterator begin()
Iterators returned here are the most "basic" (and fastest) iterators: they go from the first voxel li...
Definition: volumebase_d.h:874
rc_ptr< Volume< T > > refVolumeAtLevel(const int level) const
Get parent volume at a specified level in volume hierarchy.
Definition: volumebase_d.h:644
virtual void initialize()
VolumeProxy< T > & operator=(const VolumeProxy< T > &other)
Position posInRefVolumeAtLevel(const int level) const
Get position relatively to parent volume at specified level.
Definition: volumebase_d.h:659
blitz::Array< T, Volume< T >::DIM_MAX >::const_iterator const_iterator
Definition: volumebase.h:146
void updateItemsBuffer()
Definition: volumebase_d.h:680
void setPosInRefVolume(const Position4Di &pos)
Set position in parent volume.
Definition: volumebase_d.h:757
VolumeProxy is the base class for volumes.
Definition: volumeproxy.h:49
std::vector< size_t > getStrides() const
Get strides for the volume.
Definition: volumebase_d.h:806
std::vector< int > getSize() const
get the 4 dimensions in a vector
Definition: volumeproxy.h:127
std::string name()
bool hasOldValue(const std::string &propertyName) const
const AllocatorContext & allocatorContext() const
returns volume&#39;s AllocatorContext
Definition: volumebase_d.h:595
bool signalsBlocked() const
void addPropertyFilter(const rc_ptr< PropertyFilter > &propertyFilter)
int getSizeX() const
Definition: volumeproxy.h:87
bool isNull() const
T min(const Volume< T > &vol)
Returns the minimum value of the volume.
Definition: volumeutil.h:744
std::vector< int > getBorders() const
Get borders for the volume.
Definition: volumebase_d.h:787
void setProperty(const std::string &, const T &)
Object getOldValue(const std::string &propertyName) const
rc_ptr< Volume< T > > refVolume() const
Get parent volume.
Definition: volumebase_d.h:601
int getLevelsCount() const
Get levels count in volume hierarchy from the current volume to the topmost volume.
Definition: volumebase_d.h:614
std::vector< int > _pos
Definition: volumebase.h:523
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)
allows resizing and changing allocator
const std::vector< int > & toVector() const
Definition: volumebase.h:573
iterator end()
Definition: volumebase_d.h:887
bool connect(const std::string &propertyFilterName, const PropertyFilter::Slot &slot)
void changeBuiltinProperty(const std::string &, T &)
void blockSignals(bool)
T * get() const
blitz::Array< T, Volume< T >::DIM_MAX >::iterator iterator
Definition: volumebase.h:145
int getSizeY() const
Definition: volumeproxy.h:97
Volume< T > & operator=(const Volume< T > &other)
Definition: volumebase_d.h:828
const PropertySet & header() const
std::string toString(const T &object)
int getSizeT() const
Definition: volumeproxy.h:117
Object none()
void slotSizeChanged(const PropertyFilter &propertyFilter)
void reset(T *p=NULL)
std::vector< int > Position
Definition: volumebase.h:131
AllocatedVector< T > _items
Definition: volumebase.h:514
virtual void initialize()
Initializes header info.
Definition: volumebase_d.h:926
unsigned size() const
Definition: volumebase.h:572
virtual ~Volume()
Definition: volumebase_d.h:586