cartodata  5.1.2
volumebase_d_operators.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_VOLUMEBASE_D_OPERATORS_H
35 #define CARTODATA_VOLUME_VOLUMEBASE_D_OPERATORS_H
36 
37 
38 //--- cartodata --------------------------------------------------------------
41 //----------------------------------------------------------------------------
42 
43 // Methods that need volumeutil are defined here
44 
45 // Extern operators should be defined inside the library namespace because of
46 // Koenig's lookup:
47 // - https://en.wikipedia.org/wiki/Argument-dependent_name_lookup
48 namespace carto {
49 
50  namespace volumebaseinternal {
51  // Since non template methods risk being instantiated even if
52  // they are not actually called, it is necessary to enable them only
53  // when we are sure they won't cause a compilation error.
54  // This is the aim of this helper.
55  // all(), any(), min(), max(), sum() are concerned
56  template <typename T, bool is_scalar = DataTypeTraits<T>::is_scalar>
58  {
59  static T min( const Volume<T> & )
60  {
61  throw std::logic_error( "Member function min() is only enabled for "
62  "volumes of scalar. Try to use the non-member function "
63  "carto::min(Volume<T>) instead." );
64  }
65 
66  static T max( const Volume<T> & )
67  {
68  throw std::logic_error( "Member function max() is only enabled for "
69  "volumes of scalar. Try to use the non-member function "
70  "carto::max(Volume<T>) instead." );
71  }
72 
73  static typename DataTypeTraits<T>::LongType
74  sum( const Volume<T> & )
75  {
76  throw std::logic_error( "Member function sum() is only enabled for "
77  "volumes of scalar. Try to use the non-member function "
78  "carto::sum(Volume<T>) instead." );
79  }
80 
81  };
82 
83  template <typename T, bool has_bool_conversion = DataTypeTraits<T>::has_bool_conversion>
85  {
86  static bool all( const Volume<T> & )
87  {
88  throw std::logic_error( "Member function all() is only enabled for "
89  "volumes of types that support boolean conversion. Try to use the "
90  "non-member function carto::all(Volume<T>) instead." );
91  }
92 
93  static bool any( const Volume<T> & )
94  {
95  throw std::logic_error( "Member function any() is only enabled for "
96  "volumes of that support boolean conversion. Try to use the "
97  "non-member function carto::any(Volume<T>) instead." );
98  }
99  };
100 
101 
102  template <typename T>
103  struct select_is_scalar<T, true>
104  {
105  static T min( const Volume<T> & vol )
106  {
107  return carto::min(vol);
108  }
109 
110  static T max( const Volume<T> & vol )
111  {
112  return carto::max(vol);
113  }
114 
115  static typename DataTypeTraits<T>::LongType
116  sum( const Volume<T> & vol )
117  {
118  return carto::sum(vol);
119  }
120 
121  };
122 
123  template <typename T>
125  {
126  static bool all( const Volume<T> & vol )
127  {
128  return carto::all(vol);
129  }
130 
131  static bool any( const Volume<T> & vol )
132  {
133  return carto::any(vol);
134  }
135  };
136  }
137 
138  //==========================================================================
139  // BOOLEANS/MIN/MAX...
140  //==========================================================================
141  template <typename T>
142  inline
143  bool Volume<T>::all() const
144  {
146  }
147 
148  template <typename T>
149  inline
150  bool Volume<T>::any() const
151  {
153  }
154 
155  template <typename T>
156  inline
157  Volume<T>::operator bool() const
158  {
160  }
161 
162  template <typename T>
163  inline
164  T Volume<T>::min() const
165  {
167  }
168 
169  template <typename T>
170  inline
171  T Volume<T>::max() const
172  {
174  }
175 
176  template <typename T>
177  inline
179  {
180  //return ::carto::sum( *this );
182  }
183 
184 
185  //==========================================================================
186  // FILL / REPLACE
187  //==========================================================================
188 
189  template <typename T>
190  inline
191  void Volume<T>::fill( const T & value )
192  {
193  volumeutil::selfApply( *this, std::bind2nd( volumeutil::select_right<T>(), value ) );
194  }
195 
196  template <typename T>
197  inline
198  Volume<T> & Volume<T>::operator= ( const T & value )
199  {
200  this->fill( value );
201  return *this;
202  }
203 
205  template <typename T>
206  inline
207  void Volume<T>::fillBorder( const T & value )
208  {
209  rc_ptr<Volume<T> > ref = refVolume();
210  if( !ref )
211  return;
212  typename Volume<T>::Position pos = posInRefVolume();
213  std::vector<int> sz = ref->getSize();
214  std::vector<int> vsz = this->getSize();
215  int dim;
216  int nd = sz.size();
217  int vnd = vsz.size();
218  int np = pos.size();
219  std::vector<int> dmin( nd, 0 ), dmax( nd, 0 );
220  std::vector<int> ppos( nd, 0 );
221  std::vector<bool> is_inside( nd, true );
222  int i;
223 
224  for( dim=nd - 1; dim>=0; --dim )
225  {
226  if( dim < vnd )
227  {
228  if( dim < np )
229  dmin[dim] = pos[dim];
230  else
231  dmin[dim] = 0;
232  dmax[dim] = vsz[dim] + dmin[dim];
233  }
234  else
235  {
236  dmin[dim] = 0;
237  dmax[dim] = sz[dim];
238  }
239  ppos[dim] = 0;
240  is_inside[dim] = (dmin[dim] == 0 );
241  if( dim < nd - 1 )
242  is_inside[dim] = is_inside[dim] && is_inside[dim + 1];
243  }
244 
245  while( true )
246  {
247  // fill one line along dim0
248  if( is_inside[1] )
249  {
250  for( i=0; i<dmin[0]; ++i )
251  {
252  ppos[0] = i;
253  ref->at( ppos ) = value;
254  }
255  for( i=dmax[0]; i<sz[0]; ++i )
256  {
257  ppos[0] = i;
258  ref->at( ppos ) = value;
259  }
260  }
261  else
262  {
263  for( i=0; i<sz[0]; ++i )
264  {
265  ppos[0] = i;
266  ref->at( ppos ) = value;
267  }
268  }
269  // increment line
270  ++ppos[1];
271  dim = 1;
272  while( ppos[dim] >= sz[dim] )
273  {
274  ppos[dim] = 0;
275  ++dim;
276  if( dim >= nd )
277  break;
278  ++ppos[dim];
279  }
280  if( dim >= nd )
281  break;
282  // check if we are inside the view
283  for( ; dim > 0; --dim )
284  {
285  is_inside[dim] = ( dim < nd - 1 ? is_inside[dim + 1] : true );
286  is_inside[dim] = is_inside[dim] && ( ppos[dim] >= dmin[dim] )
287  && ( ppos[dim] < dmax[dim] );
288  }
289  }
290  }
291 
292  //==========================================================================
293  // COPY
294  //==========================================================================
295 
296  template <typename T>
297  inline
299  {
300  return ::carto::copy<T,T>( *this );
301  }
302 
303  template <typename T>
304  template <typename OUTP>
305  inline
307  {
308  return ::carto::copy<OUTP,T>( *this );
309  }
310 
311  template <typename T>
312  inline
314  {
315  return ::carto::deepcopy<T,T>( *this );
316  }
317 
318  template <typename T>
319  template <typename OUTP>
320  inline
322  {
323  return ::carto::deepcopy<OUTP,T>( *this );
324  }
325 
326  template <typename T>
327  inline
329  {
330  return ::carto::copyStructure<T,T>( *this );
331  }
332 
333  template <typename T>
334  template <typename OUTP>
335  inline
337  {
338  return ::carto::copyStructure<OUTP,T>( *this );
339  }
340 
341  template <typename T>
342  template <typename OUTP>
343  inline
345  {
346  return ::carto::deepcopy<OUTP,T>( *this );
347  }
348 
349  //============================================================================
350  // OPERATORS : COMPARISONS
351  //============================================================================
352 
353  //--- Volume [op] Scalar -----------------------------------------------------
354 
355  template <typename T, typename U>
356  inline
357  carto::Volume<bool> operator== ( const carto::Volume<T> & vol, const U & value )
358  {
359  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
360  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::equal_to<T,U>(), value ) );
361  }
362 
363  template <typename T, typename U>
364  inline
365  carto::Volume<bool> operator!= ( const carto::Volume<T> & vol, const U & value )
366  {
367  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
368  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::not_equal_to<T,U>(), value ) );
369  }
370 
371  template <typename T, typename U>
372  inline
373  carto::Volume<bool> operator>= ( const carto::Volume<T> & vol, const U & value )
374  {
375  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
376  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::greater_equal<T,U>(), value ) );
377  }
378 
379  template <typename T, typename U>
380  inline
381  carto::Volume<bool> operator<= ( const carto::Volume<T> & vol, const U & value )
382  {
383  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
384  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::less_equal<T,U>(), value ) );
385  }
386 
387  template <typename T, typename U>
388  inline
389  carto::Volume<bool> operator> ( const carto::Volume<T> & vol, const U & value )
390  {
391  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
392  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::greater<T,U>(), value ) );
393  }
394 
395  template <typename T, typename U>
396  inline
397  carto::Volume<bool> operator< ( const carto::Volume<T> & vol, const U & value )
398  {
399  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
400  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::less<T,U>(), value ) );
401  }
402 
403  //--- Scalar [op] Volume -----------------------------------------------------
404 
405  template <typename T, typename U>
406  inline
407  carto::Volume<bool> operator== ( const U & value, const carto::Volume<T> & vol )
408  {
409  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
410  return carto::volumeutil::applyTowards( vol, output, std::bind1st( carto::volumeutil::equal_to<U,T>(), value ) );
411  }
412 
413  template <typename T, typename U>
414  inline
415  carto::Volume<bool> operator!= ( const U & value, const carto::Volume<T> & vol )
416  {
417  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
418  return carto::volumeutil::applyTowards( vol, output, std::bind1st( carto::volumeutil::not_equal_to<U,T>(), value ) );
419  }
420 
421  template <typename T, typename U>
422  inline
423  carto::Volume<bool> operator>= ( const U & value, const carto::Volume<T> & vol )
424  {
425  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
426  return carto::volumeutil::applyTowards( vol, output, std::bind1st( carto::volumeutil::greater_equal<U,T>(), value ) );
427  }
428 
429  template <typename T, typename U>
430  inline
431  carto::Volume<bool> operator<= ( const U & value, const carto::Volume<T> & vol )
432  {
433  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
434  return carto::volumeutil::applyTowards( vol, output, std::bind1st( carto::volumeutil::less_equal<U,T>(), value ) );
435  }
436 
437  template <typename T, typename U>
438  inline
439  carto::Volume<bool> operator> ( const U & value, const carto::Volume<T> & vol )
440  {
441  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
442  return carto::volumeutil::applyTowards( vol, output, std::bind1st( carto::volumeutil::greater<U,T>(), value ) );
443  }
444 
445  template <typename T, typename U>
446  inline
447  carto::Volume<bool> operator< ( const U & value, const carto::Volume<T> & vol )
448  {
449  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
450  return carto::volumeutil::applyTowards( vol, output, std::bind1st( carto::volumeutil::less<U,T>(), value ) );
451  }
452 
453  //--- Volume [op] Volume -----------------------------------------------------
454 
455  template <typename T, typename U>
456  inline
458  {
459  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
461  }
462 
463  template <typename T, typename U>
464  inline
466  {
467  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
469  }
470 
471  template <typename T, typename U>
472  inline
474  {
475  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
477  }
478 
479  template <typename T, typename U>
480  inline
482  {
483  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
485  }
486 
487  template <typename T, typename U>
488  inline
490  {
491  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
493  }
494 
495  template <typename T, typename U>
496  inline
498  {
499  carto::Volume<bool> output = carto::copyStructure<bool, T>( vol );
500  return carto::volumeutil::applyTowards( vol, other, output, carto::volumeutil::less<T,U>() );
501  }
502 
503  //============================================================================
504  // OPERATORS : ARITHMETICS
505  //============================================================================
506 
507  //--- [op] Volume ------------------------------------------------------------
508 
509  template <typename T>
510  inline
512  {
514  }
515 
516  template <typename T>
517  inline
519  {
521  }
522 
523  template <typename T>
524  inline
526  {
527  carto::Volume<bool> output = carto::copyStructure<bool,T>( vol );
529  }
530 
531  //--- Volume [op] Scalar -----------------------------------------------------
532 
533  template <typename T, typename U>
534  inline
536  operator+ ( const carto::Volume<T> & vol, const U & value )
537  {
538  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::plus<T,U>(), value ) );
539  }
540 
541  template <typename T, typename U>
542  inline
544  operator- ( const carto::Volume<T> & vol, const U & value )
545  {
546  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::minus<T,U>(), value ) );
547  }
548 
549  template <typename T, typename U>
550  inline
552  operator* ( const carto::Volume<T> & vol, const U & value )
553  {
554  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::multiplies<T,U>(), value ) );
555  }
556 
557  template <typename T, typename U>
558  inline
560  operator/ ( const carto::Volume<T> & vol, const U & value )
561  {
562  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::divides<T,U>(), value ) );
563  }
564 
565  template <typename T, typename U>
566  inline
568  operator% ( const carto::Volume<T> & vol, const U & value )
569  {
570  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::modulus<T,U>(), value ) );
571  }
572 
573  template <typename T, typename U>
574  inline
576  operator& ( const carto::Volume<T> & vol, const U & value )
577  {
578  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::bitwise_and<T,U>(), value ) );
579  }
580 
581  template <typename T, typename U>
582  inline
584  operator| ( const carto::Volume<T> & vol, const U & value )
585  {
586  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::bitwise_or<T,U>(), value ) );
587  }
588 
589  template <typename T, typename U>
590  inline
592  operator^ ( const carto::Volume<T> & vol, const U & value )
593  {
594  return carto::volumeutil::apply( vol, std::bind2nd( carto::volumeutil::bitwise_xor<T,U>(), value ) );
595  }
596 
597  template <typename T, typename U>
598  inline
599  carto::Volume<bool> operator&& ( const carto::Volume<T> & vol, const U & value )
600  {
601  carto::Volume<bool> output = carto::copyStructure<bool,T>( vol );
602  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::logical_and<T,U>(), value ) );
603  }
604 
605  template <typename T, typename U>
606  inline
607  carto::Volume<bool> operator|| ( const carto::Volume<T> & vol, const U & value )
608  {
609  carto::Volume<bool> output = carto::copyStructure<bool,T>( vol );
610  return carto::volumeutil::applyTowards( vol, output, std::bind2nd( carto::volumeutil::logical_or<T,U>(), value ) );
611  }
612 
613  //--- Scalar [op] Volume -----------------------------------------------------
614 
615  template <typename T, typename U>
616  inline
618  operator+ ( const U & value, const carto::Volume<T> & vol )
619  {
620  return carto::volumeutil::apply( vol, std::bind1st( carto::volumeutil::plus<U,T>(), value ) );
621  }
622 
623  template <typename T, typename U>
624  inline
626  operator- ( const U & value, const carto::Volume<T> & vol )
627  {
628  return carto::volumeutil::apply( vol, std::bind1st( carto::volumeutil::minus<U,T>(), value ) );
629  }
630 
631  template <typename T, typename U>
632  inline
634  operator* ( const U & value, const carto::Volume<T> & vol )
635  {
636  return carto::volumeutil::apply( vol, std::bind1st( carto::volumeutil::multiplies<U,T>(), value ) );
637  }
638 
639  template <typename T, typename U>
640  inline
642  operator/ ( const U & value, const carto::Volume<T> & vol )
643  {
644  return carto::volumeutil::apply( vol, std::bind1st( carto::volumeutil::divides<U,T>(), value ) );
645  }
646 
647  //--- Volume [op] Volume -----------------------------------------------------
648 
649  template <typename T, typename U>
650  inline
652  operator+ ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
653  {
655  }
656 
657  template <typename T, typename U>
658  inline
660  operator- ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
661  {
663  }
664 
665  template <typename T, typename U>
666  inline
668  operator* ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
669  {
671  }
672 
673  template <typename T, typename U>
674  inline
676  operator/ ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
677  {
679  }
680 
681  template <typename T, typename U>
682  inline
684  operator% ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
685  {
687  }
688 
689  template <typename T, typename U>
690  inline
692  operator& ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
693  {
695  }
696 
697  template <typename T, typename U>
698  inline
700  operator| ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
701  {
703  }
704 
705  template <typename T, typename U>
706  inline
708  operator^ ( const carto::Volume<T> & vol, const carto::Volume<U> & other )
709  {
711  }
712 
713  template <typename T, typename U>
714  inline
716  {
717  carto::Volume<bool> output = carto::copyStructure<bool,T>( vol );
719  }
720 
721  template <typename T, typename U>
722  inline
724  {
725  carto::Volume<bool> output = carto::copyStructure<bool,T>( vol );
727  }
728 
729  //============================================================================
730  // OPERATORS: ARITHMETIC MODIFIERS
731  //============================================================================
732 
733  //--- Volume [op]= Scalar ----------------------------------------------------
734 
735  template <typename T, typename U>
736  inline
737  carto::Volume<T> & operator+= ( carto::Volume<T> & vol, const U & value )
738  {
739  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::plus<T,U>(), value ) );
740  }
741 
742  template <typename T, typename U>
743  inline
744  carto::Volume<T> & operator-= ( carto::Volume<T> & vol, const U & value )
745  {
746  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::minus<T,U>(), value ) );
747  }
748 
749  template <typename T, typename U>
750  inline
751  carto::Volume<T> & operator*= ( carto::Volume<T> & vol, const U & value )
752  {
753  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::multiplies<T,U>(), value ) );
754  }
755 
756  template <typename T, typename U>
757  inline
758  carto::Volume<T> & operator/= ( carto::Volume<T> & vol, const U & value )
759  {
760  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::divides<T,U>(), value ) );
761  }
762 
763  template <typename T, typename U>
764  inline
765  carto::Volume<T> & operator%= ( carto::Volume<T> & vol, const U & value )
766  {
767  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::modulus<T,U>(), value ) );
768  }
769 
770  template <typename T, typename U>
771  inline
772  carto::Volume<T> & operator&= ( carto::Volume<T> & vol, const U & value )
773  {
774  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::bitwise_and<T,U>(), value ) );
775  }
776 
777  template <typename T, typename U>
778  inline
779  carto::Volume<T> & operator|= ( carto::Volume<T> & vol, const U & value )
780  {
781  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::bitwise_or<T,U>(), value ) );
782  }
783 
784  template <typename T, typename U>
785  inline
786  carto::Volume<T> & operator^= ( carto::Volume<T> & vol, const U & value )
787  {
788  return carto::volumeutil::selfApply( vol, std::bind2nd( carto::volumeutil::bitwise_xor<T,U>(), value ) );
789  }
790 
791  //--- Volume [op]= Volume ----------------------------------------------------
792 
793  template <typename T, typename U>
794  inline
796  {
798  }
799 
800  template <typename T, typename U>
801  inline
803  {
805  }
806 
807  template <typename T, typename U>
808  inline
810  {
812  }
813 
814  template <typename T, typename U>
815  inline
817  {
819  }
820 
821  template <typename T, typename U>
822  inline
824  {
826  }
827 
828  template <typename T, typename U>
829  inline
831  {
833  }
834 
835  template <typename T, typename U>
836  inline
838  {
840  }
841 
842  template <typename T, typename U>
843  inline
845  {
847  }
848 
849  //============================================================================
850  // INCREMENTS
851  //============================================================================
852 
853  template <typename T>
854  inline
856  {
857  carto::Volume<T> output = vol.deepcopy();
858  ++vol;
859  return output;
860  }
861 
862  template <typename T>
863  inline
865  {
867  }
868 
869  template <typename T>
870  inline
872  {
873  carto::Volume<T> output = vol.deepcopy();
874  --vol;
875  return output;
876  }
877 
878  template <typename T>
879  inline
881  {
883  }
884 
885 } // namespace carto
886 
887 #endif // CARTODATA_VOLUME_VOLUMEBASE_D_OPERATORS_H
N-D Volume main class.
Definition: volumebase.h:119
Volume< T > copyStructure() const
Copy the full data structure without copying the actual data.
std::vector< int > Position
Definition: volumebase.h:128
bool all() const
True if all values compare to true.
Volume< T > deepcopy() const
Copy the full data structure.
Volume< T > copy() const
Create a volume of same dimension and copy the data.
Volume< T > & operator=(const Volume< T > &other)
Definition: volumebase_d.h:739
bool any() const
True if at least one value compares to true.
DataTypeTraits< T >::LongType sum() const
To avoid overflow, the biggest possible type (intmax_t, uintmax_t, double...) is used for computation...
void fill(const T &value)
Fills the volume with a given value.
void fillBorder(const T &value)
Fill border with a constant value.
Volume< OUTP > & applyTowards(const Volume< T > &vol, Volume< OUTP > &dst, UnaryFunction func)
Apply a function to all the elements of a volume (already allocated output version)
Definition: volumeutil.h:603
Volume< T > & selfApply(Volume< T > &vol, UnaryFunction func)
Apply a function to all the elements of a volume (in place version)
Definition: volumeutil.h:567
Volume< typename UnaryFunction::result_type > apply(const Volume< T > &vol, UnaryFunction func)
Apply a function to all the elements of a volume (create output version)
Definition: volumeutil.h:518
carto::Volume< T > & operator*=(carto::Volume< T > &vol, const U &value)
carto::Volume< T > & operator^=(carto::Volume< T > &vol, const U &value)
bool any(const Volume< T > &vol)
Returns true if at least one value compares to true.
Definition: volumeutil.h:1218
carto::Volume< bool > operator&&(const carto::Volume< T > &vol, const U &value)
carto::Volume< T > & operator/=(carto::Volume< T > &vol, const U &value)
carto::Volume< bool > operator>=(const carto::Volume< T > &vol, const U &value)
carto::Volume< bool > operator!=(const carto::Volume< T > &vol, const U &value)
VoxelRGB operator/(const VoxelRGB &aa, const uint8_t &bb)
carto::Volume< bool > operator<=(const carto::Volume< T > &vol, const U &value)
VoxelRGB operator+(const VoxelRGB &aa, const VoxelRGB &bb)
T min(const Volume< T > &vol)
Returns the minimum value of the volume.
Definition: volumeutil.h:1133
T max(const Volume< T > &vol)
Returns the maximum value of the volume.
Definition: volumeutil.h:1153
carto::Volume< bool > operator<(const carto::Volume< T > &vol, const U &value)
DataTypeTraits< T >::LongType sum(const Volume< T > &vol)
Returns the sum of the volume values.
Definition: volumeutil.h:1173
VoxelRGB operator-(const VoxelRGB &aa, const VoxelRGB &bb)
carto::Volume< bool > operator!(const carto::Volume< T > &vol)
bool all(const Volume< T > &vol)
Returns true if all values compare to true.
Definition: volumeutil.h:1204
carto::Volume< T > & operator|=(carto::Volume< T > &vol, const U &value)
carto::Volume< typename carto::volumeutil::modulus< T, U >::result_type > operator%(const carto::Volume< T > &vol, const U &value)
VoxelRGB operator*(const VoxelRGB &aa, const uint8_t &bb)
carto::Volume< typename carto::volumeutil::bitwise_and< T, U >::result_type > operator&(const carto::Volume< T > &vol, const U &value)
carto::Volume< T > & operator&=(carto::Volume< T > &vol, const U &value)
carto::Volume< typename carto::volumeutil::bitwise_xor< T, U >::result_type > operator^(const carto::Volume< T > &vol, const U &value)
carto::Volume< typename carto::volumeutil::bitwise_or< T, U >::result_type > operator|(const carto::Volume< T > &vol, const U &value)
carto::Volume< T > operator~(const carto::Volume< T > &vol)
carto::Volume< T > & operator%=(carto::Volume< T > &vol, const U &value)
carto::Volume< bool > operator>(const carto::Volume< T > &vol, const U &value)
carto::Volume< T > & operator-=(carto::Volume< T > &vol, const U &value)
carto::Volume< bool > operator||(const carto::Volume< T > &vol, const U &value)
carto::Volume< bool > operator==(const carto::Volume< T > &vol, const U &value)
carto::Volume< T > operator++(carto::Volume< T > &vol, int)
carto::Volume< T > operator--(carto::Volume< T > &vol, int)
carto::Volume< T > & operator+=(carto::Volume< T > &vol, const U &value)
static DataTypeTraits< T >::LongType sum(const Volume< T > &vol)
static DataTypeTraits< T >::LongType sum(const Volume< T > &)