aimsdata 6.0.0
Neuroimaging data handling
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>
38#include <cartodata/volume/volume.h>
39
40namespace 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:
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
79 {
80 public:
81 typedef const T* const_iterator;
82
83 const_LowLevelStorage() : _begin(0), _end(0) {}
85 int t )
86 : _volume( vol ), _begin( &vol->at( 0, y, z, t ) ),
87 _end( &vol->at( vol->getSizeX(), y, z, t ) )
88 {}
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
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
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 {}
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;
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 ); }
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; }
232
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;
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; }
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
245 ( const typename const_LowLevelStorage::const_iterator & iv )
246 { return *iv; }
247
248 private:
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;
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;
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 if( allocated )
391 _data->fill( _background );
392 }
393
394
395 template <typename T>
396 inline
398 int sizeZ, int sizeT,
399 T* buffer )
400 : _data( new carto::Volume<T>( sizeX, sizeY, sizeZ, sizeT, buffer ) ),
401 _background( 0 )
402 {
403 }
404
405
406 template <typename T>
407 inline
409 other )
410 : _data( other ),
411 _background( 0 )
412 {
413 }
414
415
416 template <typename T>
417 inline
419 other )
420 : _data( new carto::Volume<T>( other ) ),
421 _background( 0 )
422 {
423 }
424
425
426 template <typename T>
427 inline
429 ( const carto::rc_ptr<carto::Volume<T> > & x )
430 : _data( x ),
431 _background( 0 )
432 {
433 }
434
435
436 template <typename T>
437 inline
441
442
443 template <typename T>
444 inline
445 std::vector<int> SparseVolume<carto::Volume<T> >::getSize() const
446 {
447 std::vector<int> sz( 4 );
448 sz[0] = _data->getSizeX();
449 sz[1] = _data->getSizeY();
450 sz[2] = _data->getSizeZ();
451 sz[3] = _data->getSizeT();
452
453 return sz;
454 }
455
456
457 template <typename T>
458 inline
459 std::vector<float> SparseVolume<carto::Volume<T> >::voxelSize() const
460 {
461 std::vector<float> vs( 4 );
462 int i = 0;
463 try
464 {
465 carto::Object j, v = header().getProperty( "voxel_size" );
466 for( j=v->objectIterator(); j->isValid(); j->next(), ++i )
467 vs[i] = j->currentValue()->getScalar();
468 }
469 catch( ... )
470 {
471 }
472 for( ; i<4; ++i )
473 vs[i] = 1.;
474 return vs;
475 }
476
477
478 template <typename T>
479 inline const T &
481 int t ) const
482 {
483 if( x < 0 || y < 0 || z < 0 || t < 0 || x >= _data->getSizeX()
484 || y >= _data->getSizeY() || z >= _data->getSizeZ()
485 || t >= _data->getSizeT() )
486 return _background;
487 return _data->at( x, y, z, t );
488 }
489
490
491 template <typename T>
492 inline void
494 {
495 _data.reset( d );
496 }
497
498
499 template <typename T> template <typename U>
502 ( const SparseVolume<carto::Volume<U> > & other )
503 {
504 carto::Volume<U> & src = *other.data();
505 const carto::AllocatorContext *ac = &src.allocatorContext();
506 // look for the upper-level allocator, because views have an "Unallocated"
507 // allocator
508 if( src.refVolume().get() )
509 {
510 carto::Volume<U> *rvol = &src;
511 while( rvol->refVolume().get() )
512 {
513 rvol = rvol->refVolume().get();
514 if( rvol->allocatorContext().isAllocated() )
515 ac = &rvol->allocatorContext();
516 else
517 break;
518 }
519 }
520 std::unique_ptr<carto::AllocatorContext> pac;
521 if( ac->allocatorType() == carto::AllocatorStrategy::Unallocated )
522 {
523 // if src is unallocated (does not own its data), we still need to
524 // allocate a volume.
525 pac.reset( new carto::AllocatorContext );
526 ac = pac.get();
527 }
529 src.getSizeY(), src.getSizeZ(), src.getSizeT(), *ac );
530 data->copyHeaderFrom( src.header() );
531 data->fill( other.background() );
533 svol.setBackground( other.background() );
534 return svol;
535 }
536
537
538 // ------
539
540 template <typename T>
541 inline
543 const carto::AllocatorContext&,
544 bool )
545 : _data( new BucketMap<T> ),
546 _background( 0 )
547 {
548 typename BucketMap<T>::iterator i = _data->find( 0 );
549 if( i != _data->end() )
550 _firstbck = &i->second;
551 else
552 _firstbck = 0;
553 }
554
555
556 template <typename T>
557 inline
559 & other )
560 : _data( other ),
561 _background( 0 )
562 {
563 typename BucketMap<T>::iterator i = _data->find( 0 );
564 if( i != _data->end() )
565 _firstbck = &i->second;
566 else
567 _firstbck = 0;
568 }
569
570
571 template <typename T>
572 inline
574 : _data( new BucketMap<T>( other ) ),
575 _background( 0 )
576 {
577 typename BucketMap<T>::iterator i = _data->find( 0 );
578 if( i != _data->end() )
579 _firstbck = &i->second;
580 else
581 _firstbck = 0;
582 }
583
584
585 template <typename T>
586 inline
590
591
592 template <typename T>
593 inline std::vector<int>
595 {
596 std::vector<int> sz(4);
597 if( _data->empty() )
598 {
599 sz[0] = 0;
600 sz[1] = 0;
601 sz[2] = 0;
602 sz[3] = 0;
603 return sz;
604 }
605 sz[3] = _data->rbegin()->first + 1;
606 int & x = sz[0];
607 int & y = sz[1];
608 int & z = sz[2];
609 typename BucketMap<T>::const_iterator ib, eb = _data->end();
610 typename BucketMap<T>::Bucket::const_iterator i, e;
611 for( ib=_data->begin(); ib!=eb; ++ib )
612 for( i=ib->second.begin(), e=ib->second.end(); i!=e; ++i )
613 {
614 const Point3d & p = i->first;
615 if( p[0] > x )
616 x = p[0];
617 if( p[1] > y )
618 y = p[1];
619 if( p[2] > z )
620 z = p[2];
621 }
622 ++x;
623 ++y;
624 ++z;
625
626 return sz;
627 }
628
629
630 template <typename T>
631 inline
632 std::vector<float> SparseVolume<BucketMap<T> >::voxelSize() const
633 {
634 std::vector<float> vs( 4 );
635 vs[0] = _data->sizeX();
636 vs[1] = _data->sizeY();
637 vs[2] = _data->sizeZ();
638 vs[3] = _data->sizeT();
639 return vs;
640 }
641
642
643 template <typename T>
644 inline const T &
645 SparseVolume<BucketMap<T> >::at( int x, int y, int z, int t ) const
646 {
647 typename BucketMap<T>::const_iterator ib = _data->find( t );
648 if( ib == _data->end() )
649 return _background;
650 typename BucketMap<T>::Bucket::const_iterator i
651 = ib->second.find( Point3d( x, y, z ) );
652 if( i != ib->second.end() )
653 return i->second;
654 return _background;
655 }
656
657
658 template <typename T>
659 inline const T &
661 {
662 if( !_firstbck )
663 return _background;
664 typename BucketMap<T>::Bucket::const_iterator i
665 = _firstbck->find( p );
666 if( i != _firstbck->end() )
667 return i->second;
668 return _background;
669 }
670
671
672 template <typename T>
673 inline const T &
674 SparseVolume<BucketMap<T> >::at( int x, int y, int z ) const
675 {
676 return at( Point3d( x, y, z ) );
677 }
678
679
680 template <typename T>
681 inline void
682 SparseVolume<BucketMap<T> >::setValue( const T & value, int x, int y, int z,
683 int t )
684 {
685 (*_data)[t][ Point3d( x, y, z ) ] = value;
686 }
687
688
689 template <typename T>
690 inline void
691 SparseVolume<BucketMap<T> >::setValue( const T & value, const Point3d & p )
692 {
693 if( !_firstbck )
694 _firstbck = &(*_data)[0];
695 (*_firstbck)[ p ] = value;
696 }
697
698
699 template <typename T>
700 inline void
701 SparseVolume<BucketMap<T> >::setValue( const T & value, int x, int y, int z )
702 {
703 setValue( value, Point3d( x, y, z ) );
704 }
705
706
707 template <typename T>
708 inline void
710 {
711 _data.reset( d );
712 typename BucketMap<T>::iterator i = _data->find( 0 );
713 if( i != _data->end() )
714 _firstbck = &i->second;
715 else
716 _firstbck = 0;
717 }
718
719
720 template <typename T> template <typename U>
723 ( const SparseVolume<BucketMap<U> > & other )
724 {
725 BucketMap<U> & src = *other.data();
727 data->setSizeXYZT( src.sizeX(), src.sizeY(), src.sizeZ(), src.sizeT() );
728 data->header().getValue() = src.header().getValue();
730 }
731
732 // --------
733
734
735 inline
737 ( int, int, int, int, const carto::AllocatorContext&, bool )
738 : _data( new BucketMap<Void> ),
739 _background( 0 )
740 {
741 }
742
743
744 inline
747 : _data( other ),
748 _background( 0 )
749 {
750 }
751
752
753 inline
755 : _data( new BucketMap<Void>( other ) ),
756 _background( 0 )
757 {
758 }
759
760
761 inline
765
766
767 inline std::vector<int>
769 {
770 std::vector<int> sz(4);
771 sz[3] = _data->rbegin()->first + 1;
772 int & x = sz[0];
773 int & y = sz[1];
774 int & z = sz[2];
775 BucketMap<Void>::const_iterator ib, eb = _data->end();
776 BucketMap<Void>::Bucket::const_iterator i, e;
777 for( ib=_data->begin(); ib!=eb; ++ib )
778 for( i=ib->second.begin(), e=ib->second.end(); i!=e; ++i )
779 {
780 const Point3d & p = i->first;
781 if( p[0] > x )
782 x = p[0];
783 if( p[1] > y )
784 y = p[1];
785 if( p[2] > z )
786 z = p[2];
787 }
788 ++x;
789 ++y;
790 ++z;
791
792 return sz;
793 }
794
795
796 inline
797 std::vector<float> SparseVolume<BucketMap<Void> >::voxelSize() const
798 {
799 std::vector<float> vs( 4 );
800 vs[0] = _data->sizeX();
801 vs[1] = _data->sizeY();
802 vs[2] = _data->sizeZ();
803 vs[3] = _data->sizeT();
804 return vs;
805 }
806
807
808 inline const int &
809 SparseVolume<BucketMap<Void> >::at( int x, int y, int z, int ) const
810 {
811 return at( Point3d( x, y, z ) );
812 }
813
814
815 inline const int &
817 {
818 BucketMap<Void>::const_iterator ib, eb = _data->end();
819 for( ib=_data->begin(); ib!=eb; ++ib )
820 {
821 BucketMap<Void>::Bucket::const_iterator i
822 = ib->second.find( p );
823 if( i != ib->second.end() )
824 return ib->first;
825 }
826 return _background;
827 }
828
829
830 inline void
831 SparseVolume<BucketMap<Void> >::setValue( const int & value, int x, int y,
832 int z, int )
833 {
834 setValue( value, Point3d( x, y, z ) );
835 }
836
837
838 inline void
840 const Point3d & p )
841 {
842 // erase first
843 BucketMap<Void>::iterator ib, eb = _data->end();
844 for( ib=_data->begin(); ib!=eb; ++ib )
845 ib->second.erase( p );
846 if( value != background() )
847 (*_data)[value][p] = Void();
848 }
849
850
851 inline void
853 {
854 _data.reset( d );
855 }
856
857
858 template <typename U>
861 ( const SparseVolume<BucketMap<U> > & other )
862 {
863 BucketMap<U> & src = *other.data();
865 data->setSizeXYZT( src.sizeX(), src.sizeY(), src.sizeZ(), src.sizeT() );
866 data->header().getValue() = src.header().getValue();
869 }
870
871}
872
873#endif
874
875
876
An alternate, ordered, representation for buckets (voxels lists).
Definition bucketMap.h:99
float sizeZ() const
returns the Z resolution in mm
Definition bucketMap.h:254
std::map< int, Bucket >::const_iterator const_iterator
Definition bucketMap.h:104
const aims::PythonHeader & header() const
Definition bucketMap.h:155
std::map< Point3d, T, BucketMapLess > Bucket
Definition bucketMap.h:102
float sizeT() const
returns the T resolution in s
Definition bucketMap.h:264
float sizeY() const
returns the Y resolution in mm
Definition bucketMap.h:244
std::map< int, Bucket >::iterator iterator
Definition bucketMap.h:103
float sizeX() const
returns the X resolution in mm
Definition bucketMap.h:234
static SparseVolume< BucketMap< T > > alloc(const SparseVolume< BucketMap< U > > &other)
std::vector< int > getSize() const
static const T & at(const typename const_LowLevelStorage::const_iterator &iv)
static const Point3d & position3d(const const_iterator &, const typename const_LowLevelStorage::const_iterator &iv)
const T & checkedAt(const Point3d &p) const
const T & at(int x, int y, int z, int t) const
BucketMap< T >::iterator iterator
BucketMap< T >::const_iterator const_iterator
void setValue(const T &value, int x, int y, int z, int t)
const carto::PropertySet & header() const
std::vector< float > voxelSize() const
carto::rc_ptr< BucketMap< T > > data() const
BucketMap< T >::Bucket LowLevelStorage
const BucketMap< T >::Bucket const_LowLevelStorage
SparseVolume(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, const carto::AllocatorContext &allocatorContext=carto::AllocatorContext(), bool allocated=true)
const T & checkedAt(int x, int y=0, int z=0) const
const T & checkedAt(int x, int y, int z, int t) const
const carto::PropertySet & header() const
carto::rc_ptr< BucketMap< Void > > data() const
void setBackground(const VoxelType &x)
const VoxelType & checkedAt(const Point3d &p) const
const VoxelType & checkedAt(int x, int y, int z, int t) const
std::vector< int > getSize() const
BucketMap< Void >::iterator iterator
static const Void & at(const const_LowLevelStorage::const_iterator &iv)
void reset(BucketMap< Void > *x)
BucketMap< Void >::const_iterator const_iterator
const VoxelType & checkedAt(int x, int y=0, int z=0) const
static const Point3d & position3d(const const_iterator &, const const_LowLevelStorage::const_iterator &iv)
std::vector< float > voxelSize() const
void fill(const VoxelType &value)
static SparseVolume< BucketMap< Void > > alloc(const SparseVolume< BucketMap< U > > &other)
const VoxelType & background() const
SparseVolume(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, const carto::AllocatorContext &allocatorContext=carto::AllocatorContext(), bool allocated=true)
void setValue(const VoxelType &value, int x, int y=0, int z=0, int t=0)
BucketMap< Void >::Bucket LowLevelStorage
const BucketMap< Void >::Bucket const_LowLevelStorage
const VoxelType & at(int x, int y=0, int z=0, int t=0) const
LowLevelStorage(carto::VolumeRef< T > vol, int y, int z, int t)
const_LowLevelStorage(const carto::VolumeRef< T > vol, int y, int z, int t)
const const_LowLevelStorage & storage() const
const_iterator(carto::VolumeRef< T > vol, int y, int z, int t)
iterator(carto::VolumeRef< T > vol, int y, int z, int t)
SparseVolume(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, const carto::AllocatorContext &allocatorContext=carto::AllocatorContext(), bool allocated=true)
static const T & at(const typename const_LowLevelStorage::const_iterator &iv)
void reset(carto::Volume< T > *x)
static Point3d position3d(const const_iterator &i, const typename const_LowLevelStorage::const_iterator &iv)
void setValue(const T &value, const Point3d &p)
const T & at(const Point3d &p) const
const carto::PropertySet & header() const
void setValue(const T &value, int x, int y=0, int z=0, int t=0)
static Point4d position(const const_iterator &i, const typename const_LowLevelStorage::const_iterator &iv)
static SparseVolume< carto::Volume< T > > alloc(const SparseVolume< carto::Volume< U > > &other)
const T & at(int x, int y=0, int z=0, int t=0) const
std::vector< float > voxelSize() const
std::vector< int > getSize() const
carto::VolumeRef< T > data() const
const T & checkedAt(const Point3d &p) const
checks volume bounds before returning value
const PropertySet & header() const
virtual T & getValue()
int getSizeY() const
int getSizeX() const
int getSizeZ() const
int getSizeT() const
const T & at(long x, long y=0, long z=0, long t=0) const
const AllocatorContext & allocatorContext() const
rc_ptr< Volume< T > > refVolume() const
T * get() const
The class for EcatSino data write operation.
AimsVector< int16_t, 3 > Point3d
AimsVector< int16_t, 4 > Point4d