cartodata 6.0.0
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 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 template <typename T>
208 inline
209 void VolumeRef<T>::setVoxelSize( const std::vector<float> & vs )
210 {
211 (*this)->setVoxelSize( vs );
212 }
213
214 template <typename T>
215 inline
216 void VolumeRef<T>::setVoxelSize( float vx, float vy, float vz, float vt )
217 {
218 (*this)->setVoxelSize( vx, vy, vz, vt );
219 }
220
221 //==========================================================================
222 // ITERATORS
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 template <typename T>
239 inline
241 {
242 return (*this)->begin();
243 }
244
245 template <typename T>
246 inline
248 {
249 return (*this)->end();
250 }
251
252 //==========================================================================
253 // ACCESSORS
254 //==========================================================================
255 template <typename T>
256 inline
257 const T& VolumeRef<T>::operator()( long x, long y, long z, long t ) const
258 {
259 return (**this)( x, y, z, t );
260 }
261
262 template <typename T>
263 inline
264 T& VolumeRef<T>::operator() ( long x, long y, long z, long t )
265 {
266 return (**this)( x, y, z, t );
267 }
268
269 template <typename T>
270 inline
271 const T& VolumeRef<T>::at( long x, long y, long z, long t ) const
272 {
273 return (*this)->at( x, y, z, t );
274 }
275
276 template <typename T>
277 inline
278 T& VolumeRef<T>::at( long x, long y, long z, long t )
279 {
280 return (*this)->at( x, y, z, t );
281 }
282
283 template <typename T>
284 inline
285 const T& VolumeRef<T>::operator() ( const Position4Di & position ) const
286 {
287 return (**this)(position);
288 }
289
290 template <typename T>
291 inline
293 {
294 return (**this)(position);
295 }
296
297 template <typename T>
298 inline
299 const T& VolumeRef<T>::at( const Position4Di & position ) const
300 {
301 return (*this)->at(position);
302 }
303
304 template <typename T>
305 inline
306 T& VolumeRef<T>::at( const Position4Di & position )
307 {
308 return (*this)->at(position);
309 }
310
311 template <typename T>
312 inline
313 const T& VolumeRef<T>::operator() ( const Position & position ) const
314 {
315 return (**this)(position);
316 }
317
318 template <typename T>
319 inline
320 T& VolumeRef<T>::operator() ( const Position & position )
321 {
322 return (**this)(position);
323 }
324
325 template <typename T>
326 inline
327 const T& VolumeRef<T>::at( const Position & position ) const
328 {
329 return (*this)->at(position);
330 }
331
332 template <typename T>
333 inline
334 T& VolumeRef<T>::at( const Position & position )
335 {
336 return (*this)->at(position);
337 }
338
339 //==========================================================================
340 // INIT / ALLOCATION
341 //==========================================================================
342 template <typename T>
343 inline
345 {
346 (*this)->initialize();
347 }
348
349 template <typename T>
350 inline
351 const AllocatorContext & VolumeRef<T>::allocatorContext() const
352 {
353 return (*this)->allocatorContext();
354 }
355
356 template <typename T>
357 inline
359 {
360 (*this)->allocate();
361 }
362
363 template <typename T>
364 inline
365 void VolumeRef<T>::reallocate( int sizeX, int sizeY, int sizeZ, int sizeT,
366 bool keepcontents,
367 const AllocatorContext& allocatorContext,
368 bool allocate )
369 {
370 (*this)->reallocate( sizeX, sizeY, sizeZ, sizeT,
371 keepcontents, allocatorContext, allocate );
372 }
373
374#if 0
375 template <typename T>
376 inline
377 void VolumeRef<T>::reallocate( const Position4Di & size, bool keepcontents,
378 const AllocatorContext& allocatorContext,
379 bool allocate )
380 {
381 (*this)->reallocate( size, keepcontents, allocatorContext, allocate );
382 }
383#endif
384
385
386 //==========================================================================
387 // COPY / VIEW
388 //==========================================================================
389
390 template <typename T>
391 inline
393 {
394 return (*this)->refVolume();
395 }
396
397 template <typename T>
398 inline
400 {
401 return (*this)->setRefVolume( refvol );
402 }
403
404 template <typename T>
405 inline
407 {
408 return (*this)->posInRefVolume();
409 }
410
411 template <typename T>
412 inline
414 {
415 return (*this)->setPosInRefVolume( pos );
416 }
417
418
419 template <typename T>
420 inline
422 return (*this)->getLevelsCount();
423 }
424
425 template <typename T>
426 inline
427 int VolumeRef<T>::refLevel(const int level) const {
428 return (*this)->refLevel(level);
429 }
430
431 template <typename T>
432 inline
434 return (*this)->refVolumeAtLevel(level);
435 }
436
437 template <typename T>
438 inline
440 const int level) const {
441 return (*this)->posInRefVolumeAtLevel(level);
442 }
443
444 template <typename T>
445 inline
446 std::vector<int> VolumeRef<T>::getBorders() const
447 {
448 return (*this)->getBorders();
449 }
450
451 template <typename T>
452 inline
453 std::vector<long> VolumeRef<T>::getStrides() const
454 {
455 return (*this)->getStrides();
456 }
457
458 template < typename T >
459 inline
461 {
462 (*this)->copyHeaderFrom( other );
463 }
464
465#endif // CARTO_VOLUME_AUTO_DEREFERENCE
466
467 //==========================================================================
468 // MAKE VIEW
469 //==========================================================================
470
471 template <typename T>
472 inline
474 {
475 return VolumeRef<T>( *this, pos, size );
476 }
477
478 template <typename T>
479 inline
480 const VolumeRef<T> VolumeRef<T>::view( const Position4Di & pos, const Position4Di & size ) const
481 {
482 return VolumeRef<T>( *this, pos, size );
483 }
484
485 template <typename T>
487 {
488 return Object::reference( obj->header() );
489 }
490
491 //==========================================================================
492 // STREAMS
493 //==========================================================================
494
495 template <typename T>
496 std::ostream & operator<< ( const carto::VolumeOStream & out,
497 const carto::rc_ptr<carto::Volume<T> > & volume )
498 {
499 out.ostream() << "VolumeRef" << std::flush;
500 if( !volume.get() ) {
501 out.ostream() << " of " << carto::DataTypeCode<T>::dataType()
502 << ": empty" << std::endl;
503 return out.ostream();
504 }
505 else
506 {
507 out.ostream() << ": " << std::flush;
508 return out << *(volume.get());
509 }
510 }
511
512 template <typename T>
513 std::ostream & operator<< ( std::ostream & out,
514 const carto::rc_ptr<carto::Volume<T> > & volume )
515 {
516 carto::VolumeOStream volumeout( out );
517 return volumeout << volume;
518 }
519
520 template <typename T>
521 inline
524 }
525
526} // namespace carto
527
528
529
530
531#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)