cartodata 6.0.1
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
41namespace 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>
55
56 template <typename T>
58 rc_ptr<Volume<T> >(x)
59 {}
60
61 template <typename T>
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 bool transToParent ):
124 rc_ptr<Volume<T> >( new Volume<T>( other, pos, size, allocContext,
125 transToParent ) )
126 {}
127
128 template <typename T>
130 const Position & pos,
131 const Position & size,
132 const AllocatorContext & allocContext,
133 bool transToParent ):
134 rc_ptr<Volume<T> >( new Volume<T>( other, pos, size, allocContext,
135 transToParent ) )
136 {}
137
138 //==========================================================================
139 // VOLUME PROXY
140 //==========================================================================
141 template <typename T>
142 inline
143 std::vector<int> VolumeRef<T>::getSize() const
144 {
145 return (*this)->getSize();
146 }
147
148 template <typename T>
149 inline
151 {
152 return (*this)->getSizeX();
153 }
154
155 template <typename T>
156 inline
158 {
159 return (*this)->getSizeY();
160 }
161
162 template <typename T>
163 inline
165 {
166 return (*this)->getSizeZ();
167 }
168
169 template <typename T>
170 inline
172 {
173 return (*this)->getSizeT();
174 }
175
176 template <typename T>
177 inline
179 {
180 return (*this)->header();
181 }
182
183 template <typename T>
184 inline
186 {
187 return (*this)->header();
188 }
189
190 template <typename T>
191 inline
193 {
194 return (*this)->header();
195 }
196
197 template <typename T>
198 inline
200 {
201 return (*this)->header();
202 }
203
204 template <typename T>
205 inline
206 std::vector<float> VolumeRef<T>::getVoxelSize() const
207 {
208 return (*this)->getVoxelSize();
209 }
210
211 template <typename T>
212 inline
213 void VolumeRef<T>::setVoxelSize( const std::vector<float> & vs )
214 {
215 (*this)->setVoxelSize( vs );
216 }
217
218 template <typename T>
219 inline
220 void VolumeRef<T>::setVoxelSize( float vx, float vy, float vz, float vt )
221 {
222 (*this)->setVoxelSize( vx, vy, vz, vt );
223 }
224
225 //==========================================================================
226 // ITERATORS
227 //==========================================================================
228 template <typename T>
229 inline
231 {
232 return (*this)->begin();
233 }
234
235 template <typename T>
236 inline
238 {
239 return (*this)->end();
240 }
241
242 template <typename T>
243 inline
245 {
246 return (*this)->begin();
247 }
248
249 template <typename T>
250 inline
252 {
253 return (*this)->end();
254 }
255
256 //==========================================================================
257 // ACCESSORS
258 //==========================================================================
259 template <typename T>
260 inline
261 const T& VolumeRef<T>::operator()( long x, long y, long z, long t ) const
262 {
263 return (**this)( x, y, z, t );
264 }
265
266 template <typename T>
267 inline
268 T& VolumeRef<T>::operator() ( long x, long y, long z, long t )
269 {
270 return (**this)( x, y, z, t );
271 }
272
273 template <typename T>
274 inline
275 const T& VolumeRef<T>::at( long x, long y, long z, long t ) const
276 {
277 return (*this)->at( x, y, z, t );
278 }
279
280 template <typename T>
281 inline
282 T& VolumeRef<T>::at( long x, long y, long z, long t )
283 {
284 return (*this)->at( x, y, z, t );
285 }
286
287 template <typename T>
288 inline
289 const T& VolumeRef<T>::operator() ( const Position4Di & position ) const
290 {
291 return (**this)(position);
292 }
293
294 template <typename T>
295 inline
297 {
298 return (**this)(position);
299 }
300
301 template <typename T>
302 inline
303 const T& VolumeRef<T>::at( const Position4Di & position ) const
304 {
305 return (*this)->at(position);
306 }
307
308 template <typename T>
309 inline
310 T& VolumeRef<T>::at( const Position4Di & position )
311 {
312 return (*this)->at(position);
313 }
314
315 template <typename T>
316 inline
317 const T& VolumeRef<T>::operator() ( const Position & position ) const
318 {
319 return (**this)(position);
320 }
321
322 template <typename T>
323 inline
324 T& VolumeRef<T>::operator() ( const Position & position )
325 {
326 return (**this)(position);
327 }
328
329 template <typename T>
330 inline
331 const T& VolumeRef<T>::at( const Position & position ) const
332 {
333 return (*this)->at(position);
334 }
335
336 template <typename T>
337 inline
338 T& VolumeRef<T>::at( const Position & position )
339 {
340 return (*this)->at(position);
341 }
342
343 //==========================================================================
344 // INIT / ALLOCATION
345 //==========================================================================
346 template <typename T>
347 inline
349 {
350 (*this)->initialize();
351 }
352
353 template <typename T>
354 inline
355 const AllocatorContext & VolumeRef<T>::allocatorContext() const
356 {
357 return (*this)->allocatorContext();
358 }
359
360 template <typename T>
361 inline
363 {
364 (*this)->allocate();
365 }
366
367 template <typename T>
368 inline
369 void VolumeRef<T>::reallocate( int sizeX, int sizeY, int sizeZ, int sizeT,
370 bool keepcontents,
371 const AllocatorContext& allocatorContext,
372 bool allocate )
373 {
374 (*this)->reallocate( sizeX, sizeY, sizeZ, sizeT,
375 keepcontents, allocatorContext, allocate );
376 }
377
378#if 0
379 template <typename T>
380 inline
381 void VolumeRef<T>::reallocate( const Position4Di & size, bool keepcontents,
382 const AllocatorContext& allocatorContext,
383 bool allocate )
384 {
385 (*this)->reallocate( size, keepcontents, allocatorContext, allocate );
386 }
387#endif
388
389
390 //==========================================================================
391 // COPY / VIEW
392 //==========================================================================
393
394 template <typename T>
395 inline
397 {
398 return (*this)->refVolume();
399 }
400
401 template <typename T>
402 inline
404 {
405 return (*this)->setRefVolume( refvol );
406 }
407
408 template <typename T>
409 inline
411 {
412 return (*this)->posInRefVolume();
413 }
414
415 template <typename T>
416 inline
418 {
419 return (*this)->setPosInRefVolume( pos );
420 }
421
422
423 template <typename T>
424 inline
426 return (*this)->getLevelsCount();
427 }
428
429 template <typename T>
430 inline
431 int VolumeRef<T>::refLevel(const int level) const {
432 return (*this)->refLevel(level);
433 }
434
435 template <typename T>
436 inline
438 return (*this)->refVolumeAtLevel(level);
439 }
440
441 template <typename T>
442 inline
444 const int level) const {
445 return (*this)->posInRefVolumeAtLevel(level);
446 }
447
448 template <typename T>
449 inline
450 std::vector<int> VolumeRef<T>::getBorders() const
451 {
452 return (*this)->getBorders();
453 }
454
455 template <typename T>
456 inline
457 std::vector<long> VolumeRef<T>::getStrides() const
458 {
459 return (*this)->getStrides();
460 }
461
462 template < typename T >
463 inline
465 {
466 (*this)->copyHeaderFrom( other );
467 }
468
469#endif // CARTO_VOLUME_AUTO_DEREFERENCE
470
471 //==========================================================================
472 // MAKE VIEW
473 //==========================================================================
474
475 template <typename T>
476 inline
478 {
479 return VolumeRef<T>( *this, pos, size );
480 }
481
482 template <typename T>
483 inline
484 const VolumeRef<T> VolumeRef<T>::view( const Position4Di & pos, const Position4Di & size ) const
485 {
486 return VolumeRef<T>( *this, pos, size );
487 }
488
489 template <typename T>
491 {
492 return Object::reference( obj->header() );
493 }
494
495 //==========================================================================
496 // STREAMS
497 //==========================================================================
498
499 template <typename T>
500 std::ostream & operator<< ( const carto::VolumeOStream & out,
501 const carto::rc_ptr<carto::Volume<T> > & volume )
502 {
503 out.ostream() << "VolumeRef" << std::flush;
504 if( !volume.get() ) {
505 out.ostream() << " of " << carto::DataTypeCode<T>::dataType()
506 << ": empty" << std::endl;
507 return out.ostream();
508 }
509 else
510 {
511 out.ostream() << ": " << std::flush;
512 return out << *(volume.get());
513 }
514 }
515
516 template <typename T>
517 std::ostream & operator<< ( std::ostream & out,
518 const carto::rc_ptr<carto::Volume<T> > & volume )
519 {
520 carto::VolumeOStream volumeout( out );
521 return volumeout << volume;
522 }
523
524 template <typename T>
525 inline
528 }
529
530} // namespace carto
531
532
533
534
535#endif // CARTODATA_VOLUME_VOLUMEREF_D_INLINE_H
std::string dataType()
Object reference(Object &value)
std::ostream & ostream() const
Convenient handle for a Volume - this is normally the entry point for all volumes handling.
Definition volumeref.h:60
virtual void reallocate(int sizeX=1, int sizeY=1, int sizeZ=1, int sizeT=1, bool keepcontents=false, const AllocatorContext &allocatorContext=AllocatorContext(), bool allocate=true)
const PropertySet & getPropertySet() const __attribute__((__deprecated__("use header() instead")))
int refLevel(const int level) const
std::vector< int > getBorders() const
Volume< T >::Position Position
Definition volumeref.h:92
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
std::vector< float > getVoxelSize() const
void setRefVolume(const rc_ptr< Volume< T > > &refvol)
virtual void copyHeaderFrom(const PropertySet &other)
Volume< T >::Position posInRefVolumeAtLevel(const int level) const
rc_ptr< Volume< T > > refVolume() const
rc_ptr< Volume< T > > refVolumeAtLevel(const int level) const
std::vector< int > getSize() const
const T & at(long x, long y=0, long z=0, long t=0) const
Volume< T >::iterator iterator
Definition volumeref.h:93
std::vector< long > getStrides() const
const PropertySet & header() const
const T & operator()(long x, long y=0, long z=0, long t=0) const
const AllocatorContext & allocatorContext() const
Volume< T >::const_iterator const_iterator
Definition volumeref.h:94
virtual void initialize()
Volume< T >::Position4Di Position4Di
Definition volumeref.h:91
void setPosInRefVolume(const Position4Di &pos)
const Position4Di posInRefVolume() const
VolumeRef< T > view(const Position4Di &pos, const Position4Di &size)
N-D Volume main class.
Definition volumebase.h:120
iterator begin()
Iterators returned here are the most "basic" (and fastest) iterators: they go from the first voxel li...
std::vector< int > Position
Definition volumebase.h:130
void setPosInRefVolume(const Position4Di &pos)
Set position in parent volume.
const Position & posInRefVolume() const
Get position in parent volume.
iterator end()
Position posInRefVolumeAtLevel(const int level) const
Get position relatively to parent volume at specified level.
const T & at(long x, long y=0, long z=0, long t=0) const
T * get() const
void displayRefVolumes(const Volume< T > &vol)
Display information about volumes hierarchy.
carto::Object getObjectHeader(Headered &h)
std::ostream & operator<<(std::ostream &out, const VoxelValue< T, C > &aa)