A.I.M.S


sparsevolume.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 AIMS_data_SPARSEVOLUME_H
35 #define AIMS_data_SPARSEVOLUME_H
36 
37 #include <aims/bucket/bucket.h>
39 
40 namespace aims
41 {
42 
43  template <typename T>
45  {
46  public:
47  };
48 
49 
50  template <typename T>
51  class SparseVolume<carto::Volume<T> >
52  {
53  public:
54  class LowLevelStorage
55  {
56  public:
57  typedef T* iterator;
58  typedef const T* const_iterator;
59 
60  LowLevelStorage() : _begin(0), _end(0) {}
61  LowLevelStorage( carto::VolumeRef<T> vol, int y, int z, int t )
62  : _volume( vol ), _begin( &vol->at( 0, y, z, t ) ),
63  _end( &vol->at( vol->getSizeX(), y, z, t ) )
64  {}
65  iterator begin() { return _begin; }
66  const_iterator begin() const { return _begin; }
67  iterator end() { return _end; }
68  const_iterator end() const { return _end; }
69  carto::VolumeRef<T> volume() const { return _volume; }
70 
71  private:
72  carto::VolumeRef<T> _volume;
73  T* _begin;
74  T* _end;
75  };
76 
77 
78  class const_LowLevelStorage
79  {
80  public:
81  typedef const T* const_iterator;
82 
83  const_LowLevelStorage() : _begin(0), _end(0) {}
84  const_LowLevelStorage( const carto::VolumeRef<T> vol, int y, int z,
85  int t )
86  : _volume( vol ), _begin( &vol->at( 0, y, z, t ) ),
87  _end( &vol->at( vol->getSizeX(), y, z, t ) )
88  {}
89  const_LowLevelStorage( const LowLevelStorage & other )
90  : _volume( other.volume() ), _begin( other.begin() ),
91  _end( other.end() )
92  {}
93  const_iterator begin() const { return _begin; }
94  const_iterator end() const { return _end; }
95  carto::VolumeRef<T> volume() const { return _volume; }
96 
97  private:
98  carto::VolumeRef<T> _volume;
99  const T* _begin;
100  const T* _end;
101  };
102 
103 
104  class iterator
105  {
106  public:
107  iterator() : _pos( Point4d( 0, 0, 0 ), LowLevelStorage() ) {}
108  iterator( carto::VolumeRef<T> vol, int y, int z, int t )
109  : _pos( Point4d( 0, y, z, t ), LowLevelStorage( vol, y, z, t ) ) {}
110  std::pair<Point4d, LowLevelStorage> & operator * ()
111  { return _pos; }
112  std::pair<Point4d, LowLevelStorage> *operator -> ()
113  { return &_pos; }
114  LowLevelStorage & storage() { return _pos.second; }
115  bool operator == ( const iterator & x ) const
116  {
117  return &_pos.second.volume()->at( 0, _pos.first[1], _pos.first[2],
118  _pos.first[3] )
119  == &x._pos.second.volume()->at( 0, x._pos.first[1], x._pos.first[2],
120  x._pos.first[3] );
121  }
122  bool operator != ( const iterator & x ) const
123  { return !( *this == x ); }
124  iterator & operator ++ ()
125  {
126  int16_t & y = _pos.first[1];
127  int16_t & z = _pos.first[2];
128  int16_t & t = _pos.first[3];
129  ++y;
130  if( y >= _pos.second.volume()->getSizeY() )
131  {
132  y = 0;
133  ++z;
134  if( z >= _pos.second.volume()->getSizeZ() )
135  {
136  z = 0;
137  ++t;
138  }
139  }
140  _pos.second = LowLevelStorage( _pos.second.volume(), y, z, t );
141  return *this;
142  }
143 
144  private:
145  std::pair<Point4d, LowLevelStorage> _pos;
146  };
147 
148  class const_iterator
149  {
150  public:
151  const_iterator() : _pos( Point4d( 0, 0, 0 ), const_LowLevelStorage() ) {}
152  const_iterator( carto::VolumeRef<T> vol, int y, int z, int t )
153  : _pos( Point4d( 0, y, z, t ), const_LowLevelStorage( vol, y, z, t ) )
154  {}
155  const_iterator( iterator other )
156  : _pos( other->first, other->second )
157  {}
158  const std::pair<Point4d, const_LowLevelStorage> & operator * () const
159  { return _pos; }
160  const std::pair<Point4d, const_LowLevelStorage> *operator -> () const
161  { return &_pos; }
162  const const_LowLevelStorage & storage() const { return _pos.second; }
163  bool operator == ( const const_iterator & x ) const
164  {
165  return &_pos.second.volume()->at( 0, _pos.first[1], _pos.first[2],
166  _pos.first[3] )
167  == &x._pos.second.volume()->at( 0, x._pos.first[1],
168  x._pos.first[2], x._pos.first[3] );
169  }
170  bool operator != ( const const_iterator & x ) const
171  { return !( *this == x ); }
172  const_iterator & operator ++ ()
173  {
174  int16_t & y = _pos.first[1];
175  int16_t & z = _pos.first[2];
176  int16_t & t = _pos.first[3];
177  ++y;
178  if( y >= _pos.second.volume()->getSizeY() )
179  {
180  y = 0;
181  ++z;
182  if( z >= _pos.second.volume()->getSizeZ() )
183  {
184  z = 0;
185  ++t;
186  }
187  }
188  _pos.second = const_LowLevelStorage( _pos.second.volume(), y, z, t );
189  return *this;
190  }
191 
192  private:
193  std::pair<Point4d, const_LowLevelStorage> _pos;
194  };
195 
196  SparseVolume( int sizeX = 1, int sizeY = 1, int sizeZ = 1, int sizeT = 1,
197  const carto::AllocatorContext& allocatorContext
198  = carto::AllocatorContext(), bool allocated = true );
199  SparseVolume( int sizeX, int sizeY, int sizeZ, int sizeT, T* buffer );
200  SparseVolume( const carto::VolumeRef< T >& other );
201  SparseVolume( const carto::Volume< T >& other );
203  virtual ~SparseVolume();
204  carto::VolumeRef<T> data() const { return _data; }
205  void reset( carto::Volume<T> *x );
206  template <typename U>
207  static SparseVolume<carto::Volume<T> > alloc(
208  const SparseVolume<carto::Volume<U> > & other );
209  const T & background() const { return _background; }
210  void setBackground( const T & value ) { _background = value; }
211  std::vector<int> getSize() const;
212  const carto::PropertySet& header() const
213  { return _data->header(); }
214  carto::PropertySet& header() { return _data->header(); }
215  std::vector<float> voxelSize() const;
216 
217  void fill( const T & value )
218  { _data->fill( value ); setBackground( value ); }
219  iterator begin() { return iterator( data(), 0, 0, 0 ); }
220  iterator end() { return iterator( data(), 0, 0, data()->getSizeT() ); }
221  const_iterator begin() const { return const_iterator( data(), 0, 0, 0 ); }
222  const_iterator end() const
223  { return const_iterator( data(), 0, 0, data()->getSizeT() ); }
224  const T & at( int x, int y = 0, int z = 0, int t = 0 ) const
225  { return _data->at( x, y, z, t ); }
226  void setValue( const T & value, int x, int y = 0, int z = 0, int t = 0 )
227  { _data->at( x, y, z, t ) = value; }
228  const T & at( const Point3d & p ) const
229  { return _data->at( p[0], p[1], p[2], 0 ); }
230  void setValue( const T & value, const Point3d & p )
231  { _data->at( p[0], p[1], p[2], 0 ) = value; }
233  const T & checkedAt( const Point3d & p ) const
234  { return checkedAt( p[0], p[1], p[2] ); }
235  const T & checkedAt( int x, int y = 0, int z = 0, int t = 0 ) const;
236  static Point4d position
237  ( const const_iterator & i,
238  const typename const_LowLevelStorage::const_iterator & iv )
239  { Point4d x( i->first ); x[0] = iv - i->storage().begin(); return x; }
240  static Point3d position3d
241  ( const const_iterator & i,
242  const typename const_LowLevelStorage::const_iterator & iv )
243  { return Point3d( iv - i->second.begin(), i->first[1], i->first[2] ); }
244  static const T & at
246  { return *iv; }
247 
248  private:
249  carto::VolumeRef<T> _data;
250  T _background;
251  };
252 
253 
254  template <typename T>
256  {
257  public:
258  typedef T VoxelType;
263 
264  SparseVolume( int sizeX = 1, int sizeY = 1, int sizeZ = 1, int sizeT = 1,
265  const carto::AllocatorContext& allocatorContext
266  = carto::AllocatorContext(), bool allocated = true );
267  SparseVolume( const carto::rc_ptr<BucketMap<T> >& other );
268  SparseVolume( const BucketMap< T >& other );
269  virtual ~SparseVolume();
270  carto::rc_ptr<BucketMap<T> > data() const { return _data; }
271  void reset( BucketMap<T> *x );
272  template <typename U>
273  static SparseVolume<BucketMap<T> > alloc(
274  const SparseVolume<BucketMap<U> > & other );
275  const T & background() const { return _background; }
276  void setBackground( const T & x ) { _background = x; }
277  std::vector<int> getSize() const;
278  const carto::PropertySet& header() const
279  { return _data->header().getValue(); }
281  { return _data->header().getValue(); }
282  std::vector<float> voxelSize() const;
283 
284  void fill( const T& value )
285  { _data->clear(); setBackground( value ); }
286  const T & at( int x, int y, int z, int t ) const;
287  void setValue( const T & value, int x, int y, int z, int t );
288  const T & at( int x, int y = 0, int z = 0 ) const;
289  void setValue( const T & value, int x, int y = 0, int z = 0 );
290  const T & at( const Point3d & p ) const;
291  void setValue( const T & value, const Point3d & p );
292  const T & checkedAt( const Point3d & p ) const
293  { return at( p ); }
294  const T & checkedAt( int x, int y = 0, int z = 0 ) const
295  { return at( x, y, z ); }
296  const T & checkedAt( int x, int y, int z, int t ) const
297  { return at( x, y, z, t ); }
298  iterator begin() { return data()->begin(); }
299  const_iterator begin() const { return data()->begin(); }
300  iterator end() { return data()->end(); }
301  const_iterator end() const { return data()->end(); }
302  static const Point3d & position3d
303  ( const const_iterator &,
304  const typename const_LowLevelStorage::const_iterator & iv )
305  { return iv->first; }
306  static const T & at
307  ( const typename const_LowLevelStorage::const_iterator & iv )
308  { return iv->second; }
309 
310  private:
312  mutable typename BucketMap<T>::Bucket *_firstbck;
313  T _background;
314  };
315 
316 
317  template <>
319  {
320  public:
321  typedef int VoxelType;
326 
327  SparseVolume( int sizeX = 1, int sizeY = 1, int sizeZ = 1, int sizeT = 1,
328  const carto::AllocatorContext& allocatorContext
329  = carto::AllocatorContext(), bool allocated = true );
330  SparseVolume( const carto::rc_ptr<BucketMap<Void> > & other );
331  SparseVolume( const BucketMap<Void> & other );
332  virtual ~SparseVolume();
333  carto::rc_ptr<BucketMap<Void> > data() const { return _data; }
334  void reset( BucketMap<Void> *x );
335  template <typename U>
336  static SparseVolume<BucketMap<Void> > alloc(
337  const SparseVolume<BucketMap<U> > & other );
338  const VoxelType & background() const { return _background; }
339  void setBackground( const VoxelType & x ) { _background = x; }
340  std::vector<int> getSize() const;
341  const carto::PropertySet& header() const
342  { return _data->header().getValue(); }
344  { return _data->header().getValue(); }
345  std::vector<float> voxelSize() const;
346 
347  void fill( const VoxelType & value )
348  { _data->clear(); setBackground( value ); }
349  const VoxelType & at( int x, int y = 0, int z = 0, int t = 0 ) const;
350  void setValue( const VoxelType & value, int x, int y = 0, int z = 0,
351  int t = 0 );
352  const VoxelType & at( const Point3d & p ) const;
353  void setValue( const VoxelType & value, const Point3d & p );
354  const VoxelType & checkedAt( const Point3d & p ) const
355  { return at( p ); }
356  const VoxelType & checkedAt( int x, int y = 0, int z = 0 ) const
357  { return at( x, y, z ); }
358  const VoxelType & checkedAt( int x, int y, int z, int t ) const
359  { return at( x, y, z, t ); }
360  iterator begin() { return data()->begin(); }
361  const_iterator begin() const { return data()->begin(); }
362  iterator end() { return data()->end(); }
363  const_iterator end() const { return data()->end(); }
364  static const Point3d & position3d
365  ( const const_iterator &,
366  const const_LowLevelStorage::const_iterator & iv )
367  { return iv->first; }
368  static const Void & at( const const_LowLevelStorage::const_iterator
369  & iv )
370  { return iv->second; }
371 
372  private:
374  VoxelType _background;
375  };
376 
377 
378  // ---
379 
380  template <typename T>
381  inline
383  int sizeZ, int sizeT,
384  const carto::AllocatorContext&
385  allocatorContext,
386  bool allocated )
387  : _data( sizeX, sizeY, sizeZ, sizeT, allocatorContext, allocated ),
388  _background( 0 )
389  {
390  }
391 
392 
393  template <typename T>
394  inline
396  int sizeZ, int sizeT,
397  T* buffer )
398  : _data( new carto::Volume<T>( sizeX, sizeY, sizeZ, sizeT, buffer ) ),
399  _background( 0 )
400  {
401  }
402 
403 
404  template <typename T>
405  inline
407  other )
408  : _data( other ),
409  _background( 0 )
410  {
411  }
412 
413 
414  template <typename T>
415  inline
417  other )
418  : _data( new carto::Volume<T>( other ) ),
419  _background( 0 )
420  {
421  }
422 
423 
424  template <typename T>
425  inline
428  : _data( x ),
429  _background( 0 )
430  {
431  }
432 
433 
434  template <typename T>
435  inline
436  SparseVolume<carto::Volume<T> >::~SparseVolume()
437  {
438  }
439 
440 
441  template <typename T>
442  inline
443  std::vector<int> SparseVolume<carto::Volume<T> >::getSize() const
444  {
445  std::vector<int> sz( 4 );
446  sz[0] = _data->getSizeX();
447  sz[1] = _data->getSizeY();
448  sz[2] = _data->getSizeZ();
449  sz[3] = _data->getSizeT();
450 
451  return sz;
452  }
453 
454 
455  template <typename T>
456  inline
457  std::vector<float> SparseVolume<carto::Volume<T> >::voxelSize() const
458  {
459  std::vector<float> vs( 4 );
460  int i = 0;
461  try
462  {
463  carto::Object j, v = header().getProperty( "voxel_size" );
464  for( j=v->objectIterator(); j->isValid(); j->next(), ++i )
465  vs[i] = j->currentValue()->getScalar();
466  }
467  catch( ... )
468  {
469  }
470  for( ; i<4; ++i )
471  vs[i] = 1.;
472  return vs;
473  }
474 
475 
476  template <typename T>
477  inline const T &
478  SparseVolume<carto::Volume<T> >::checkedAt( int x, int y, int z,
479  int t ) const
480  {
481  if( x < 0 || y < 0 || z < 0 || t < 0 || x >= _data->getSizeX()
482  || y >= _data->getSizeY() || z >= _data->getSizeZ()
483  || t >= _data->getSizeT() )
484  return _background;
485  return _data->at( x, y, z, t );
486  }
487 
488 
489  template <typename T>
490  inline void
492  {
493  _data.reset( d );
494  }
495 
496 
497  template <typename T> template <typename U>
500  ( const SparseVolume<carto::Volume<U> > & other )
501  {
502  carto::Volume<U> & src = *other.data();
503  carto::Volume<T> *data = new carto::Volume<T>( src.getSizeX(),
504  src.getSizeY(), src.getSizeZ(), src.getSizeT(),
505  src.allocatorContext() );
506  data->header() = src.header();
507  return SparseVolume<carto::Volume<T> >( data );
508  }
509 
510 
511  // ------
512 
513  template <typename T>
514  inline
516  const carto::AllocatorContext&,
517  bool )
518  : _data( new BucketMap<T> ),
519  _background( 0 )
520  {
521  typename BucketMap<T>::iterator i = _data->find( 0 );
522  if( i != _data->end() )
523  _firstbck = &i->second;
524  else
525  _firstbck = 0;
526  }
527 
528 
529  template <typename T>
530  inline
532  & other )
533  : _data( other ),
534  _background( 0 )
535  {
536  typename BucketMap<T>::iterator i = _data->find( 0 );
537  if( i != _data->end() )
538  _firstbck = &i->second;
539  else
540  _firstbck = 0;
541  }
542 
543 
544  template <typename T>
545  inline
547  : _data( new BucketMap<T>( other ) ),
548  _background( 0 )
549  {
550  typename BucketMap<T>::iterator i = _data->find( 0 );
551  if( i != _data->end() )
552  _firstbck = &i->second;
553  else
554  _firstbck = 0;
555  }
556 
557 
558  template <typename T>
559  inline
560  SparseVolume<BucketMap<T> >::~SparseVolume()
561  {
562  }
563 
564 
565  template <typename T>
566  inline std::vector<int>
567  SparseVolume<BucketMap<T> >::getSize() const
568  {
569  std::vector<int> sz(4);
570  if( _data->empty() )
571  {
572  sz[0] = 0;
573  sz[1] = 0;
574  sz[2] = 0;
575  sz[3] = 0;
576  return sz;
577  }
578  sz[3] = _data->rbegin()->first + 1;
579  int & x = sz[0];
580  int & y = sz[1];
581  int & z = sz[2];
582  typename BucketMap<T>::const_iterator ib, eb = _data->end();
584  for( ib=_data->begin(); ib!=eb; ++ib )
585  for( i=ib->second.begin(), e=ib->second.end(); i!=e; ++i )
586  {
587  const Point3d & p = i->first;
588  if( p[0] > x )
589  x = p[0];
590  if( p[1] > y )
591  y = p[1];
592  if( p[2] > z )
593  z = p[2];
594  }
595  ++x;
596  ++y;
597  ++z;
598 
599  return sz;
600  }
601 
602 
603  template <typename T>
604  inline
605  std::vector<float> SparseVolume<BucketMap<T> >::voxelSize() const
606  {
607  std::vector<float> vs( 4 );
608  vs[0] = _data->sizeX();
609  vs[1] = _data->sizeY();
610  vs[2] = _data->sizeZ();
611  vs[3] = _data->sizeT();
612  return vs;
613  }
614 
615 
616  template <typename T>
617  inline const T &
618  SparseVolume<BucketMap<T> >::at( int x, int y, int z, int t ) const
619  {
620  typename BucketMap<T>::const_iterator ib = _data->find( t );
621  if( ib == _data->end() )
622  return _background;
624  = ib->second.find( Point3d( x, y, z ) );
625  if( i != ib->second.end() )
626  return i->second;
627  return _background;
628  }
629 
630 
631  template <typename T>
632  inline const T &
633  SparseVolume<BucketMap<T> >::at( const Point3d & p ) const
634  {
635  if( !_firstbck )
636  return _background;
638  = _firstbck->find( p );
639  if( i != _firstbck->end() )
640  return i->second;
641  return _background;
642  }
643 
644 
645  template <typename T>
646  inline const T &
647  SparseVolume<BucketMap<T> >::at( int x, int y, int z ) const
648  {
649  return at( Point3d( x, y, z ) );
650  }
651 
652 
653  template <typename T>
654  inline void
655  SparseVolume<BucketMap<T> >::setValue( const T & value, int x, int y, int z,
656  int t )
657  {
658  (*_data)[t][ Point3d( x, y, z ) ] = value;
659  }
660 
661 
662  template <typename T>
663  inline void
664  SparseVolume<BucketMap<T> >::setValue( const T & value, const Point3d & p )
665  {
666  if( !_firstbck )
667  _firstbck = &(*_data)[0];
668  (*_firstbck)[ p ] = value;
669  }
670 
671 
672  template <typename T>
673  inline void
674  SparseVolume<BucketMap<T> >::setValue( const T & value, int x, int y, int z )
675  {
676  setValue( value, Point3d( x, y, z ) );
677  }
678 
679 
680  template <typename T>
681  inline void
683  {
684  _data.reset( d );
685  typename BucketMap<T>::iterator i = _data->find( 0 );
686  if( i != _data->end() )
687  _firstbck = &i->second;
688  else
689  _firstbck = 0;
690  }
691 
692 
693  template <typename T> template <typename U>
696  ( const SparseVolume<BucketMap<U> > & other )
697  {
698  BucketMap<U> & src = *other.data();
699  BucketMap<T> *data = new BucketMap<T>;
700  data->setSizeXYZT( src.sizeX(), src.sizeY(), src.sizeZ(), src.sizeT() );
701  data->header().getValue() = src.header().getValue();
703  }
704 
705  // --------
706 
707 
708  inline
710  ( int, int, int, int, const carto::AllocatorContext&, bool )
711  : _data( new BucketMap<Void> ),
712  _background( 0 )
713  {
714  }
715 
716 
717  inline
719  carto::rc_ptr<BucketMap<Void> > & other )
720  : _data( other ),
721  _background( 0 )
722  {
723  }
724 
725 
726  inline
728  : _data( new BucketMap<Void>( other ) ),
729  _background( 0 )
730  {
731  }
732 
733 
734  inline
735  SparseVolume<BucketMap<Void> >::~SparseVolume()
736  {
737  }
738 
739 
740  inline std::vector<int>
741  SparseVolume<BucketMap<Void> >::getSize() const
742  {
743  std::vector<int> sz(4);
744  sz[3] = _data->rbegin()->first + 1;
745  int & x = sz[0];
746  int & y = sz[1];
747  int & z = sz[2];
748  BucketMap<Void>::const_iterator ib, eb = _data->end();
750  for( ib=_data->begin(); ib!=eb; ++ib )
751  for( i=ib->second.begin(), e=ib->second.end(); i!=e; ++i )
752  {
753  const Point3d & p = i->first;
754  if( p[0] > x )
755  x = p[0];
756  if( p[1] > y )
757  y = p[1];
758  if( p[2] > z )
759  z = p[2];
760  }
761  ++x;
762  ++y;
763  ++z;
764 
765  return sz;
766  }
767 
768 
769  inline
770  std::vector<float> SparseVolume<BucketMap<Void> >::voxelSize() const
771  {
772  std::vector<float> vs( 4 );
773  vs[0] = _data->sizeX();
774  vs[1] = _data->sizeY();
775  vs[2] = _data->sizeZ();
776  vs[3] = _data->sizeT();
777  return vs;
778  }
779 
780 
781  inline const int &
782  SparseVolume<BucketMap<Void> >::at( int x, int y, int z, int ) const
783  {
784  return at( Point3d( x, y, z ) );
785  }
786 
787 
788  inline const int &
789  SparseVolume<BucketMap<Void> >::at( const Point3d & p ) const
790  {
791  BucketMap<Void>::const_iterator ib, eb = _data->end();
792  for( ib=_data->begin(); ib!=eb; ++ib )
793  {
795  = ib->second.find( p );
796  if( i != ib->second.end() )
797  return ib->first;
798  }
799  return _background;
800  }
801 
802 
803  inline void
804  SparseVolume<BucketMap<Void> >::setValue( const int & value, int x, int y,
805  int z, int )
806  {
807  setValue( value, Point3d( x, y, z ) );
808  }
809 
810 
811  inline void
812  SparseVolume<BucketMap<Void> >::setValue( const int & value,
813  const Point3d & p )
814  {
815  // erase first
816  BucketMap<Void>::iterator ib, eb = _data->end();
817  for( ib=_data->begin(); ib!=eb; ++ib )
818  ib->second.erase( p );
819  if( value != background() )
820  (*_data)[value][p] = Void();
821  }
822 
823 
824  inline void
826  {
827  _data.reset( d );
828  }
829 
830 
831  template <typename U>
834  ( const SparseVolume<BucketMap<U> > & other )
835  {
836  BucketMap<U> & src = *other.data();
837  BucketMap<Void> *data = new BucketMap<Void>;
838  data->setSizeXYZT( src.sizeX(), src.sizeY(), src.sizeZ(), src.sizeT() );
839  data->header().getValue() = src.header().getValue();
841  ( carto::rc_ptr<BucketMap<Void> >( data ) );
842  }
843 
844 }
845 
846 #endif
847 
848 
849 
BucketMap< Void >::iterator iterator
Definition: sparsevolume.h:324
const BucketMap< Void >::Bucket const_LowLevelStorage
Definition: sparsevolume.h:323
const AllocatorContext & allocatorContext() const
void erase(const Point3d &pos)
Function redefined to omit time.
Definition: bucketMap.h:201
int getSizeT() const
The template class to implement basic vectors.
Definition: vector.h:48
const VoxelType & checkedAt(int x, int y=0, int z=0) const
Definition: sparsevolume.h:356
BucketMap< T >::iterator iterator
Definition: sparsevolume.h:261
LowLevelStorage(carto::VolumeRef< T > vol, int y, int z, int t)
Definition: sparsevolume.h:61
const T & checkedAt(const Point3d &p) const
checks volume bounds before returning value
Definition: sparsevolume.h:233
bool operator!=(const AimsVector< T, D > &v1, const AimsVector< T, D > &v2)
should be defined implicitely, but fails with some compilers (Intel)
Definition: vector.h:61
float sizeX() const
returns the X resolution in mm
Definition: bucketMap.h:216
const const_LowLevelStorage & storage() const
Definition: sparsevolume.h:162
BucketMap< T >::Bucket LowLevelStorage
Definition: sparsevolume.h:259
const T & at(int x, int y=0, int z=0, int t=0) const
Definition: sparsevolume.h:224
const VoxelType & background() const
Definition: sparsevolume.h:338
static const Void & at(const const_LowLevelStorage::const_iterator &iv)
Definition: sparsevolume.h:368
const BucketMap< T >::Bucket const_LowLevelStorage
Definition: sparsevolume.h:260
float sizeT() const
returns the T resolution in s
Definition: bucketMap.h:246
const T & checkedAt(int x, int y, int z, int t) const
Definition: sparsevolume.h:296
An alternate, ordered, representation for buckets (voxels lists).
Definition: bucket.h:57
BucketMap< Void >::Bucket LowLevelStorage
Definition: sparsevolume.h:322
const_iterator begin() const
Definition: sparsevolume.h:299
std::map< Point3d, T, BucketMapLess > Bucket
Definition: bucketMap.h:102
virtual double getScalar() const =0
const PropertySet & header() const
const T & checkedAt(int x, int y=0, int z=0) const
Definition: sparsevolume.h:294
const VoxelType & checkedAt(int x, int y, int z, int t) const
Definition: sparsevolume.h:358
float sizeZ() const
returns the Z resolution in mm
Definition: bucketMap.h:236
carto::rc_ptr< BucketMap< T > > data() const
Definition: sparsevolume.h:270
const carto::PropertySet & header() const
Definition: sparsevolume.h:212
void setSizeXYZT(float sizex, float sizey, float sizez, float sizet)
sets X,Y,Z and T resolutions of the data
Definition: bucketMap.h:309
const carto::PropertySet & header() const
Definition: sparsevolume.h:278
void setValue(const T &value, int x, int y=0, int z=0, int t=0)
Definition: sparsevolume.h:226
const_iterator(carto::VolumeRef< T > vol, int y, int z, int t)
Definition: sparsevolume.h:152
const VoxelType & checkedAt(const Point3d &p) const
Definition: sparsevolume.h:354
virtual Object objectIterator() const =0
int getSizeZ() const
iterator(carto::VolumeRef< T > vol, int y, int z, int t)
Definition: sparsevolume.h:108
BucketMap< T >::const_iterator const_iterator
Definition: sparsevolume.h:262
void fill(const VoxelType &value)
Definition: sparsevolume.h:347
int getSizeX() const
BucketMap< Void >::const_iterator const_iterator
Definition: sparsevolume.h:325
void setValue(const T &value, const Point3d &p)
Definition: sparsevolume.h:230
virtual T & getValue()
AimsVector< int16_t, 3 > Point3d
Definition: vector.h:212
std::map< int, Bucket >::iterator iterator
Definition: bucketMap.h:103
const T & at(const Point3d &p) const
Definition: sparsevolume.h:228
carto::VolumeRef< T > data() const
Definition: sparsevolume.h:204
void setBackground(const VoxelType &x)
Definition: sparsevolume.h:339
carto::rc_ptr< BucketMap< Void > > data() const
Definition: sparsevolume.h:333
std::map< int, Bucket >::const_iterator const_iterator
Definition: bucketMap.h:104
virtual Object currentValue() const =0
float sizeY() const
returns the Y resolution in mm
Definition: bucketMap.h:226
const_LowLevelStorage(const carto::VolumeRef< T > vol, int y, int z, int t)
Definition: sparsevolume.h:84
const aims::PythonHeader & header() const
Definition: bucketMap.h:148
int operator==(const AimsBucketItem< T > &thing1, const AimsBucketItem< T > &thing2)
Definition: item.h:110
const carto::PropertySet & header() const
Definition: sparsevolume.h:341
const T & checkedAt(const Point3d &p) const
Definition: sparsevolume.h:292
Quaternion operator*(const Quaternion &a, const Quaternion &b)
virtual bool isValid() const =0
int getSizeY() const