cartodata  5.0.5
volumeref_d_inline.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_VOLUMEREF_D_INLINE_H
35 #define CARTODATA_VOLUME_VOLUMEREF_D_INLINE_H
36 
37 //--- cartodata --------------------------------------------------------------
39 //----------------------------------------------------------------------------
40 
41 namespace carto {
42 
43  //==========================================================================
44  // RCPTR CONSTRUCTORS
45  //==========================================================================
46  template <typename T>
48  rc_ptr<Volume<T> >( new Volume<T> )
49  {}
50 
51  template <typename T>
53  rc_ptr<Volume<T> >(x)
54  {}
55 
56  template <typename T>
58  rc_ptr<Volume<T> >(x)
59  {}
60 
61  template <typename T>
63  {}
64 
65 #ifdef CARTO_VOLUME_AUTO_DEREFERENCE
66 
67  //==========================================================================
68  // CONSTRUCTORS
69  //==========================================================================
70  template <typename T>
71  VolumeRef<T>::VolumeRef( int sizeX, int sizeY, int sizeZ, int sizeT,
72  const AllocatorContext& allocatorContext,
73  bool allocated ):
74  rc_ptr<Volume<T> >( new Volume<T>( sizeX, sizeY, sizeZ, sizeT,
75  allocatorContext, allocated ) )
76  {}
77 
78  template <typename T>
80  const AllocatorContext& allocatorContext,
81  bool allocated ):
82  rc_ptr<Volume<T> >( new Volume<T>( size, allocatorContext, allocated ) )
83  {}
84 
85  template <typename T>
86  VolumeRef<T>::VolumeRef( int sizeX, int sizeY, int sizeZ, int sizeT,
87  int border,
88  const AllocatorContext& allocatorContext,
89  bool allocated ):
90  rc_ptr<Volume<T> >( new Volume<T>( sizeX, sizeY, sizeZ, sizeT, border,
91  allocatorContext, allocated ) )
92  {}
93 
94  template <typename T>
95  VolumeRef<T>::VolumeRef( const Position4Di & size, int border,
96  const AllocatorContext& allocatorContext,
97  bool allocated ):
98  rc_ptr<Volume<T> >( new Volume<T>( size, border, allocatorContext, allocated ) )
99  {}
100 
101  template <typename T>
102  VolumeRef<T>::VolumeRef( int sizeX, int sizeY, int sizeZ, int sizeT,
103  const Position4Di & border,
104  const AllocatorContext& allocatorContext,
105  bool allocated ):
106  rc_ptr<Volume<T> >( new Volume<T>( sizeX, sizeY, sizeZ, sizeT, border,
107  allocatorContext, allocated ) )
108  {}
109 
110  template <typename T>
112  const Position4Di & border,
113  const AllocatorContext& allocatorContext,
114  bool allocated ):
115  rc_ptr<Volume<T> >( new Volume<T>( size, border, allocatorContext, allocated ) )
116  {}
117 
118  template <typename T>
120  const Position4Di & pos,
121  const Position4Di & size,
122  const AllocatorContext & allocContext ):
123  rc_ptr<Volume<T> >( new Volume<T>( other, pos, size, allocContext ) )
124  {}
125 
126  template <typename T>
128  const Position & pos,
129  const Position & size,
130  const AllocatorContext & allocContext ):
131  rc_ptr<Volume<T> >( new Volume<T>( other, pos, size, allocContext ) )
132  {}
133 
134  //==========================================================================
135  // VOLUME PROXY
136  //==========================================================================
137  template <typename T>
138  inline
139  std::vector<int> VolumeRef<T>::getSize() const
140  {
141  return (*this)->getSize();
142  }
143 
144  template <typename T>
145  inline
147  {
148  return (*this)->getSizeX();
149  }
150 
151  template <typename T>
152  inline
154  {
155  return (*this)->getSizeY();
156  }
157 
158  template <typename T>
159  inline
161  {
162  return (*this)->getSizeZ();
163  }
164 
165  template <typename T>
166  inline
168  {
169  return (*this)->getSizeT();
170  }
171 
172  template <typename T>
173  inline
175  {
176  return (*this)->header();
177  }
178 
179  template <typename T>
180  inline
182  {
183  return (*this)->header();
184  }
185 
186  template <typename T>
187  inline
189  {
190  return (*this)->header();
191  }
192 
193  template <typename T>
194  inline
196  {
197  return (*this)->header();
198  }
199 
200  template <typename T>
201  inline
202  std::vector<float> VolumeRef<T>::getVoxelSize() const
203  {
204  return (*this)->getVoxelSize();
205  }
206 
207  //==========================================================================
208  // ITERATORS
209  //==========================================================================
210  template <typename T>
211  inline
213  {
214  return (*this)->begin();
215  }
216 
217  template <typename T>
218  inline
220  {
221  return (*this)->end();
222  }
223 
224  template <typename T>
225  inline
227  {
228  return (*this)->begin();
229  }
230 
231  template <typename T>
232  inline
234  {
235  return (*this)->end();
236  }
237 
238  //==========================================================================
239  // ACCESSORS
240  //==========================================================================
241  template <typename T>
242  inline
243  const T& VolumeRef<T>::operator()( long x, long y, long z, long t ) const
244  {
245  return (**this)( x, y, z, t );
246  }
247 
248  template <typename T>
249  inline
250  T& VolumeRef<T>::operator() ( long x, long y, long z, long t )
251  {
252  return (**this)( x, y, z, t );
253  }
254 
255  template <typename T>
256  inline
257  const T& VolumeRef<T>::at( long x, long y, long z, long t ) const
258  {
259  return (*this)->at( x, y, z, t );
260  }
261 
262  template <typename T>
263  inline
264  T& VolumeRef<T>::at( long x, long y, long z, long t )
265  {
266  return (*this)->at( x, y, z, t );
267  }
268 
269  template <typename T>
270  inline
271  const T& VolumeRef<T>::operator() ( const Position4Di & position ) const
272  {
273  return (**this)(position);
274  }
275 
276  template <typename T>
277  inline
278  T& VolumeRef<T>::operator() ( const Position4Di & position )
279  {
280  return (**this)(position);
281  }
282 
283  template <typename T>
284  inline
285  const T& VolumeRef<T>::at( const Position4Di & position ) const
286  {
287  return (*this)->at(position);
288  }
289 
290  template <typename T>
291  inline
292  T& VolumeRef<T>::at( const Position4Di & position )
293  {
294  return (*this)->at(position);
295  }
296 
297  template <typename T>
298  inline
299  const T& VolumeRef<T>::operator() ( const Position & position ) const
300  {
301  return (**this)(position);
302  }
303 
304  template <typename T>
305  inline
306  T& VolumeRef<T>::operator() ( const Position & position )
307  {
308  return (**this)(position);
309  }
310 
311  template <typename T>
312  inline
313  const T& VolumeRef<T>::at( const Position & position ) const
314  {
315  return (*this)->at(position);
316  }
317 
318  template <typename T>
319  inline
320  T& VolumeRef<T>::at( const Position & position )
321  {
322  return (*this)->at(position);
323  }
324 
325  //==========================================================================
326  // INIT / ALLOCATION
327  //==========================================================================
328  template <typename T>
329  inline
331  {
332  (*this)->initialize();
333  }
334 
335  template <typename T>
336  inline
337  const AllocatorContext & VolumeRef<T>::allocatorContext() const
338  {
339  return (*this)->allocatorContext();
340  }
341 
342  template <typename T>
343  inline
345  {
346  (*this)->allocate();
347  }
348 
349  template <typename T>
350  inline
351  void VolumeRef<T>::reallocate( int sizeX, int sizeY, int sizeZ, int sizeT,
352  bool keepcontents,
353  const AllocatorContext& allocatorContext,
354  bool allocate )
355  {
356  (*this)->reallocate( sizeX, sizeY, sizeZ, sizeT,
357  keepcontents, allocatorContext, allocate );
358  }
359 
360 #if 0
361  template <typename T>
362  inline
363  void VolumeRef<T>::reallocate( const Position4Di & size, bool keepcontents,
364  const AllocatorContext& allocatorContext,
365  bool allocate )
366  {
367  (*this)->reallocate( size, keepcontents, allocatorContext, allocate );
368  }
369 #endif
370 
371 
372  //==========================================================================
373  // COPY / VIEW
374  //==========================================================================
375 
376  template <typename T>
377  inline
379  {
380  return (*this)->refVolume();
381  }
382 
383  template <typename T>
384  inline
386  {
387  return (*this)->setRefVolume( refvol );
388  }
389 
390  template <typename T>
391  inline
393  {
394  return (*this)->posInRefVolume();
395  }
396 
397  template <typename T>
398  inline
400  {
401  return (*this)->setPosInRefVolume( pos );
402  }
403 
404 
405  template <typename T>
406  inline
408  return (*this)->getLevelsCount();
409  }
410 
411  template <typename T>
412  inline
413  int VolumeRef<T>::refLevel(const int level) const {
414  return (*this)->refLevel(level);
415  }
416 
417  template <typename T>
418  inline
420  return (*this)->refVolumeAtLevel(level);
421  }
422 
423  template <typename T>
424  inline
426  const int level) const {
427  return (*this)->posInRefVolumeAtLevel(level);
428  }
429 
430  template <typename T>
431  inline
432  std::vector<int> VolumeRef<T>::getBorders() const
433  {
434  return (*this)->getBorders();
435  }
436 
437  template <typename T>
438  inline
439  std::vector<size_t> VolumeRef<T>::getStrides() const
440  {
441  return (*this)->getStrides();
442  }
443 
444  template < typename T >
445  inline
447  {
448  (*this)->copyHeaderFrom( other );
449  }
450 
451 #endif // CARTO_VOLUME_AUTO_DEREFERENCE
452 
453  //==========================================================================
454  // MAKE VIEW
455  //==========================================================================
456 
457  template <typename T>
458  inline
460  {
461  return VolumeRef<T>( *this, pos, size );
462  }
463 
464  template <typename T>
465  inline
466  const VolumeRef<T> VolumeRef<T>::view( const Position4Di & pos, const Position4Di & size ) const
467  {
468  return VolumeRef<T>( *this, pos, size );
469  }
470 
471  template <typename T>
473  {
474  return Object::reference( obj->header() );
475  }
476 
477  //==========================================================================
478  // STREAMS
479  //==========================================================================
480 
481  template <typename T>
482  std::ostream & operator<< ( const carto::VolumeOStream & out,
483  const carto::rc_ptr<carto::Volume<T> > & volume )
484  {
485  out.ostream() << "VolumeRef" << std::flush;
486  if( !volume.get() ) {
487  out.ostream() << " of " << carto::DataTypeCode<T>::dataType()
488  << ": empty" << std::endl;
489  return out.ostream();
490  }
491  else
492  {
493  out.ostream() << ": " << std::flush;
494  return out << *(volume.get());
495  }
496  }
497 
498  template <typename T>
499  std::ostream & operator<< ( std::ostream & out,
500  const carto::rc_ptr<carto::Volume<T> > & volume )
501  {
502  carto::VolumeOStream volumeout( out );
503  return volumeout << volume;
504  }
505 
506  template <typename T>
507  inline
509  carto::displayRefVolumes(*(vol.get()));
510  }
511 
512 } // namespace carto
513 
514 
515 
516 
517 #endif // CARTODATA_VOLUME_VOLUMEREF_D_INLINE_H
N-D Volume main class.
std::string dataType()
rc_ptr< Volume< T > > refVolumeAtLevel(const int level) const
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)
virtual void initialize()
void setRefVolume(const rc_ptr< Volume< T > > &refvol)
std::ostream & ostream() const
int refLevel(const int level) const
Convenient handle for a Volume - this is normally the entry point for all volumes handling...
static Object reference(T &value)
std::ostream & operator<<(std::ostream &out, const VoxelValue< T, C > &aa)
const T & operator()(long x, long y=0, long z=0, long t=0) const
int getLevelsCount() const
VolumeRef< T > view(const Position4Di &pos, const Position4Di &size)
const T & at(long x, long y=0, long z=0, long t=0) const
const PropertySet & header() const
Volume< T >::iterator iterator
Definition: volumeref.h:96
std::vector< float > getVoxelSize() const
Volume< T >::const_iterator const_iterator
Definition: volumeref.h:97
carto::Object getObjectHeader(Headered &h)
void setPosInRefVolume(const Position4Di &pos)
Volume< T >::Position Position
Definition: volumeref.h:95
const Position4Di posInRefVolume() const
void displayRefVolumes(const Volume< T > &vol)
Display information about volumes hierarchy.
std::vector< int > getSize() const
rc_ptr< Volume< T > > refVolume() const
Volume< T >::Position posInRefVolumeAtLevel(const int level) const
std::vector< size_t > getStrides() const
Volume< T > * get() const
virtual void copyHeaderFrom(const PropertySet &other)
const PropertySet & getPropertySet() const __attribute__((__deprecated__("use header() instead")))
const AllocatorContext & allocatorContext() const
std::vector< int > getBorders() const
std::vector< int > Position
Definition: volumebase.h:131