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