cartobase  5.0.5
voxelrgba_def.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 CARTOBASE_TYPE_RGBA_DEF_H
35 #define CARTOBASE_TYPE_RGBA_DEF_H
36 //--- cartobase --------------------------------------------------------------
37 #include <cartobase/type/types.h>
40 //--- system -----------------------------------------------------------------
41 //#define CARTO_DEBUG_RGB
42 #ifdef CARTO_DEBUG_RGB
43  #include <iostream>
44 #endif
45 //----------------------------------------------------------------------------
46 
47 /*****************************************************************************
48  * Since all methods are inline and for readability issues, declarations
49  * are contained in "_decl.h" file and definitions in "_def.h" file.
50  * You should include ".h" file which binds all necessary headers.
51  *
52  * Read/Write methods are defined in soma-io/utilities/asciidatasourcetraits.h
53  * so you must include this file to read or write voxels as ASCII.
54  ****************************************************************************/
55 
56 namespace carto {
57 
58  //=== CONSTRUCTORS =========================================================
59 
60  inline
62  : VoxelValue<uint8_t,4>( other )
63  {
64  #ifdef CARTO_DEBUG_RGB
65  std::cout << "RGBA:: Constructor( RGBA )" << std::endl;
66  #endif
67  }
68 
69  inline
71  {
72  #ifdef CARTO_DEBUG_RGB
73  std::cout << "RGBA:: Constructor( RGB )" << std::endl;
74  #endif
75  red() = other.red();
76  green() = other.green();
77  blue() = other.blue();
78  alpha() = 255;
79  }
80 
81  inline
83  : VoxelValue<uint8_t,4>( other )
84  {
85  #ifdef CARTO_DEBUG_RGB
86  std::cout << "RGBA:: Constructor( VV<4> )" << std::endl;
87  #endif
88  }
89 
90  inline
91  VoxelRGBA::VoxelRGBA( const uint8_t &r, const uint8_t &g,
92  const uint8_t &b, const uint8_t &a )
93  {
94  #ifdef CARTO_DEBUG_RGB
95  std::cout << "RGBA:: Constructor( r,g,b,a )" << std::endl;
96  #endif
97  red() = r;
98  green() = g;
99  blue() = b;
100  alpha() = a;
101  }
102 
103  inline
105  {
106  #ifdef CARTO_DEBUG_RGB
107  std::cout << "RGBA:: Destructor" << std::endl;
108  #endif
109  }
110 
111  //=== AFFECTATION ==========================================================
112 
113  inline
115  {
116  #ifdef CARTO_DEBUG_RGB
117  std::cout << "RGBA:: operator = ( RGBA )" << std::endl;
118  #endif
119  red() = other.red();
120  green() = other.green();
121  blue() = other.blue();
122  alpha() = other.alpha();
123  return *this;
124  }
125 
126  inline
128  {
129  #ifdef CARTO_DEBUG_RGB
130  std::cout << "RGBA:: operator = ( RGB )" << std::endl;
131  #endif
132  red() = other.red();
133  green() = other.green();
134  blue() = other.blue();
135  alpha() = 255;
136  return *this;
137  }
138 
139  inline
140  VoxelRGBA & VoxelRGBA::operator = ( const uint8_t & value )
141  {
142  #ifdef CARTO_DEBUG_RGB
143  std::cout << "RGBA:: operator = ( uint8_t )" << std::endl;
144  #endif
145  red() = value;
146  green() = value;
147  blue() = value;
148  alpha() = 255;
149  return *this;
150  }
151 
152  //=== OPERATORS ============================================================
153 
154  inline
156  {
157  #ifdef CARTO_DEBUG_RGB
158  std::cout << "RGBA:: operator += ( RGBA )" << std::endl;
159  #endif
160  if( other.alpha() == 0 ) {
161  if( alpha() == 0 ) {
162  red() = 0;
163  green() = 0;
164  blue() = 0;
165  } else {
166  // other is "0"
167  // do nothing
168  }
169  } else if( alpha() == 0 ) {
170  red() = other.red();
171  green() = other.green();
172  blue() = other.blue();
173  alpha() = other.alpha();
174  } else {
175  red() += other.red();
176  green() += other.green();
177  blue() += other.blue();
178  // keep greater alpha
179  if( alpha() < other.alpha() )
180  alpha() = other.alpha();
181  }
182  return *this;
183  }
184 
185  inline
187  {
188  #ifdef CARTO_DEBUG_RGB
189  std::cout << "RGBA:: operator += ( RGB )" << std::endl;
190  #endif
191  if( alpha() == 0 ) {
192  red() = other.red();
193  green() = other.green();
194  blue() = other.blue();
195  } else {
196  red() += other.red();
197  green() += other.green();
198  blue() += other.blue();
199  }
200  alpha() = 255;
201  return *this;
202  }
203 
204  inline
206  {
207  #ifdef CARTO_DEBUG_RGB
208  std::cout << "RGBA:: operator -= ( RGBA )" << std::endl;
209  #endif
210  if( other.alpha() == 0 ) {
211  if( alpha() == 0 ) {
212  red() = 0;
213  green() = 0;
214  blue() = 0;
215  } else {
216  // other is "0"
217  // do nothing
218  }
219  } else if( alpha() == 0 ) {
220  // this is "0"
221  // do nothing
222  } else {
223  red() -= other.red();
224  green() -= other.green();
225  blue() -= other.blue();
226  // keep greater alpha
227  if( alpha() < other.alpha() )
228  alpha() = other.alpha();
229  }
230  return *this;
231  }
232 
233  inline
235  {
236  #ifdef CARTO_DEBUG_RGB
237  std::cout << "RGBA:: operator -= ( RGB )" << std::endl;
238  #endif
239  if( alpha() == 0 ) {
240  // this is "0"
241  // do nothing
242  } else {
243  red() -= other.red();
244  green() -= other.green();
245  blue() -= other.blue();
246  }
247  alpha() = 255;
248  return *this;
249  }
250 
251  inline
252  VoxelRGBA & VoxelRGBA::operator += ( const uint8_t & value )
253  {
254  #ifdef CARTO_DEBUG_RGB
255  std::cout << "RGBA:: operator += ( uint8_t )" << std::endl;
256  #endif
257  if( alpha() == 0 ) {
258  red() = value;
259  green() = value;
260  blue() = value;
261  } else {
262  red() += value;
263  green() += value;
264  blue() += value;
265  }
266  alpha() = 255;
267  return *this;
268  }
269 
270  inline
271  VoxelRGBA & VoxelRGBA::operator -= ( const uint8_t & value )
272  {
273  #ifdef CARTO_DEBUG_RGB
274  std::cout << "RGBA:: operator -= ( uint8_t )" << std::endl;
275  #endif
276  if( alpha() == 0 ) {
277  red() = value;
278  green() = value;
279  blue() = value;
280  } else {
281  red() -= value;
282  green() -= value;
283  blue() -= value;
284  }
285  alpha() = 255;
286  return *this;
287  }
288 
289  inline
290  VoxelRGBA & VoxelRGBA::operator *= ( const uint8_t & value )
291  {
292  #ifdef CARTO_DEBUG_RGB
293  std::cout << "RGBA:: operator *= ( uint8_t )" << std::endl;
294  #endif
295  red() *= static_cast<uint8_t>( value );
296  green() *= static_cast<uint8_t>( value );
297  blue() *= static_cast<uint8_t>( value );
298  return *this;
299  }
300 
301  inline
302  VoxelRGBA & VoxelRGBA::operator *= ( const uint16_t & value )
303  {
304  #ifdef CARTO_DEBUG_RGB
305  std::cout << "RGBA:: operator *= ( uint16_t )" << std::endl;
306  #endif
307  red() *= static_cast<uint8_t>( value );
308  green() *= static_cast<uint8_t>( value );
309  blue() *= static_cast<uint8_t>( value );
310  return *this;
311  }
312 
313  inline
314  VoxelRGBA & VoxelRGBA::operator *= ( const uint32_t & value )
315  {
316  #ifdef CARTO_DEBUG_RGB
317  std::cout << "RGBA:: operator *= ( uint32_t )" << std::endl;
318  #endif
319  red() *= static_cast<uint8_t>( value );
320  green() *= static_cast<uint8_t>( value );
321  blue() *= static_cast<uint8_t>( value );
322  return *this;
323  }
324 
325  inline
326  VoxelRGBA & VoxelRGBA::operator *= ( const uint64_t & value )
327  {
328  #ifdef CARTO_DEBUG_RGB
329  std::cout << "RGBA:: operator *= ( uint64_t )" << std::endl;
330  #endif
331  red() *= static_cast<uint8_t>( value );
332  green() *= static_cast<uint8_t>( value );
333  blue() *= static_cast<uint8_t>( value );
334  return *this;
335  }
336 
337  inline
338  VoxelRGBA & VoxelRGBA::operator *= ( const float & value )
339  {
340  #ifdef CARTO_DEBUG_RGB
341  std::cout << "RGBA:: operator *= ( float )" << std::endl;
342  #endif
343  // not using *= operator to perform float operations
344  red() = static_cast<uint8_t>( red() * value );
345  green() = static_cast<uint8_t>( green() * value );
346  blue() = static_cast<uint8_t>( blue() * value );
347  return *this;
348  }
349 
350  inline
351  VoxelRGBA & VoxelRGBA::operator *= ( const double & value )
352  {
353  #ifdef CARTO_DEBUG_RGB
354  std::cout << "RGBA:: operator *= ( double )" << std::endl;
355  #endif
356  // not using *= operator to perform float operations
357  red() = static_cast<uint8_t>( red() * value );
358  green() = static_cast<uint8_t>( green() * value );
359  blue() = static_cast<uint8_t>( blue() * value );
360  return *this;
361  }
362 
363  inline
364  VoxelRGBA & VoxelRGBA::operator /= ( const uint8_t & value )
365  {
366  #ifdef CARTO_DEBUG_RGB
367  std::cout << "RGBA:: operator /= ( uint8_t )" << std::endl;
368  #endif
369  ASSERT( value != 0 );
370  red() /= static_cast<uint8_t>( value );
371  green() /= static_cast<uint8_t>( value );
372  blue() /= static_cast<uint8_t>( value );
373  return *this;
374  }
375 
376  inline
377  VoxelRGBA & VoxelRGBA::operator /= ( const uint16_t & value )
378  {
379  #ifdef CARTO_DEBUG_RGB
380  std::cout << "RGBA:: operator /= ( uint16_t )" << std::endl;
381  #endif
382  ASSERT( value != 0 );
383  red() /= static_cast<uint8_t>( value );
384  green() /= static_cast<uint8_t>( value );
385  blue() /= static_cast<uint8_t>( value );
386  return *this;
387  }
388 
389  inline
390  VoxelRGBA & VoxelRGBA::operator /= ( const uint32_t & value )
391  {
392  #ifdef CARTO_DEBUG_RGB
393  std::cout << "RGBA:: operator /= ( uint32_t )" << std::endl;
394  #endif
395  ASSERT( value != 0 );
396  red() /= static_cast<uint8_t>( value );
397  green() /= static_cast<uint8_t>( value );
398  blue() /= static_cast<uint8_t>( value );
399  return *this;
400  }
401 
402  inline
403  VoxelRGBA & VoxelRGBA::operator /= ( const uint64_t & value )
404  {
405  #ifdef CARTO_DEBUG_RGB
406  std::cout << "RGBA:: operator /= ( uint64_t )" << std::endl;
407  #endif
408  ASSERT( value != 0 );
409  red() /= static_cast<uint8_t>( value );
410  green() /= static_cast<uint8_t>( value );
411  blue() /= static_cast<uint8_t>( value );
412  return *this;
413  }
414 
415  inline
416  VoxelRGBA & VoxelRGBA::operator /= ( const float & value )
417  {
418  #ifdef CARTO_DEBUG_RGB
419  std::cout << "RGBA:: operator /= ( float )" << std::endl;
420  #endif
421  ASSERT( value != 0 );
422  // not using /= operator to perform float operations
423  red() = static_cast<uint8_t>( red() / value );
424  green() = static_cast<uint8_t>( green() / value );
425  blue() = static_cast<uint8_t>( blue() / value );
426  return *this;
427  }
428 
429  inline
430  VoxelRGBA & VoxelRGBA::operator /= ( const double & value )
431  {
432  #ifdef CARTO_DEBUG_RGB
433  std::cout << "RGBA:: operator /= ( double )" << std::endl;
434  #endif
435  ASSERT( value != 0 );
436  // not using /= operator to perform float operations
437  red() = static_cast<uint8_t>( red() / value );
438  green() = static_cast<uint8_t>( green() / value );
439  blue() = static_cast<uint8_t>( blue() / value );
440  return *this;
441  }
442 
443  //=== EXTERN OPERATORS =====================================================
444 
445  inline
446  VoxelRGBA operator + (const VoxelRGBA &aa, const VoxelRGBA &bb)
447  {
448  #ifdef CARTO_DEBUG_RGB
449  std::cout << "RGBA:: RGBA + RGBA" << std::endl;
450  #endif
451  VoxelRGBA result( aa );
452  return result += bb;
453  }
454 
455  inline
456  VoxelRGBA operator + (const VoxelRGBA &aa, const uint8_t &bb)
457  {
458  #ifdef CARTO_DEBUG_RGB
459  std::cout << "RGBA:: RGBA + uint8_t" << std::endl;
460  #endif
461  VoxelRGBA result( aa );
462  return result += bb;
463  }
464 
465  inline
466  VoxelRGBA operator + (const VoxelRGBA &aa, const uint16_t &bb)
467  {
468  #ifdef CARTO_DEBUG_RGB
469  std::cout << "RGBA:: RGBA + uint16_t" << std::endl;
470  #endif
471  VoxelRGBA result( aa );
472  return result += bb;
473  }
474 
475  inline
476  VoxelRGBA operator + (const VoxelRGBA &aa, const uint32_t &bb)
477  {
478  #ifdef CARTO_DEBUG_RGB
479  std::cout << "RGBA:: RGBA + uint32_t" << std::endl;
480  #endif
481  VoxelRGBA result( aa );
482  return result += bb;
483  }
484 
485  inline
486  VoxelRGBA operator + (const VoxelRGBA &aa, const uint64_t &bb)
487  {
488  #ifdef CARTO_DEBUG_RGB
489  std::cout << "RGBA:: RGBA + uint64_t" << std::endl;
490  #endif
491  VoxelRGBA result( aa );
492  return result += bb;
493  }
494 
495  inline
496  VoxelRGBA operator + (const VoxelRGBA &aa, const float &bb)
497  {
498  #ifdef CARTO_DEBUG_RGB
499  std::cout << "RGBA:: RGBA + float" << std::endl;
500  #endif
501  VoxelRGBA result( aa );
502  return result += static_cast<uint8_t>(bb);
503  }
504 
505  inline
506  VoxelRGBA operator + (const VoxelRGBA &aa, const double &bb)
507  {
508  #ifdef CARTO_DEBUG_RGB
509  std::cout << "RGBA:: RGBA + double" << std::endl;
510  #endif
511  VoxelRGBA result( aa );
512  return result += static_cast<uint8_t>(bb);
513  }
514 
515  inline
516  VoxelRGBA operator + (const uint8_t &aa, const VoxelRGBA &bb)
517  {
518  #ifdef CARTO_DEBUG_RGB
519  std::cout << "RGBA:: uint8_t + RGBA" << std::endl;
520  #endif
521  VoxelRGBA result( aa );
522  return result += bb;
523  }
524 
525  inline
526  VoxelRGBA operator + (const uint16_t &aa, const VoxelRGBA &bb)
527  {
528  #ifdef CARTO_DEBUG_RGB
529  std::cout << "RGBA:: uint16_t + RGBA" << std::endl;
530  #endif
531  VoxelRGBA result( aa );
532  return result += bb;
533  }
534 
535  inline
536  VoxelRGBA operator + (const uint32_t &aa, const VoxelRGBA &bb)
537  {
538  #ifdef CARTO_DEBUG_RGB
539  std::cout << "RGBA:: uint32_t + RGBA" << std::endl;
540  #endif
541  VoxelRGBA result( aa );
542  return result += bb;
543  }
544 
545  inline
546  VoxelRGBA operator + (const uint64_t &aa, const VoxelRGBA &bb)
547  {
548  #ifdef CARTO_DEBUG_RGB
549  std::cout << "RGBA:: uint64_t + RGBA" << std::endl;
550  #endif
551  VoxelRGBA result( aa );
552  return result += bb;
553  }
554 
555  inline
556  VoxelRGBA operator + (const float &aa, const VoxelRGBA &bb)
557  {
558  #ifdef CARTO_DEBUG_RGB
559  std::cout << "RGBA:: float + RGBA" << std::endl;
560  #endif
561  VoxelRGBA result( static_cast<uint8_t>(aa) );
562  return result += bb;
563  }
564 
565  inline
566  VoxelRGBA operator + (const double &aa, const VoxelRGBA &bb)
567  {
568  #ifdef CARTO_DEBUG_RGB
569  std::cout << "RGBA:: double + RGBA" << std::endl;
570  #endif
571  VoxelRGBA result( static_cast<uint8_t>(aa) );
572  return result += bb;
573  }
574 
575  inline
576  VoxelRGBA operator - (const VoxelRGBA &aa, const VoxelRGBA &bb)
577  {
578  #ifdef CARTO_DEBUG_RGB
579  std::cout << "RGBA:: RGBA - RGBA" << std::endl;
580  #endif
581  VoxelRGBA result( aa );
582  return result -= bb;
583  }
584 
585  inline
586  VoxelRGBA operator - (const VoxelRGBA &aa, const uint8_t &bb)
587  {
588  #ifdef CARTO_DEBUG_RGB
589  std::cout << "RGBA:: RGBA - uint8_t" << std::endl;
590  #endif
591  VoxelRGBA result( aa );
592  return result -= bb;
593  }
594 
595  inline
596  VoxelRGBA operator - (const VoxelRGBA &aa, const uint16_t &bb)
597  {
598  #ifdef CARTO_DEBUG_RGB
599  std::cout << "RGBA:: RGBA - uint16_t" << std::endl;
600  #endif
601  VoxelRGBA result( aa );
602  return result -= bb;
603  }
604 
605  inline
606  VoxelRGBA operator - (const VoxelRGBA &aa, const uint32_t &bb)
607  {
608  #ifdef CARTO_DEBUG_RGB
609  std::cout << "RGBA:: RGBA - uint32_t" << std::endl;
610  #endif
611  VoxelRGBA result( aa );
612  return result -= bb;
613  }
614 
615  inline
616  VoxelRGBA operator - (const VoxelRGBA &aa, const uint64_t &bb)
617  {
618  #ifdef CARTO_DEBUG_RGB
619  std::cout << "RGBA:: RGBA - uint64_t" << std::endl;
620  #endif
621  VoxelRGBA result( aa );
622  return result -= bb;
623  }
624 
625  inline
626  VoxelRGBA operator - (const VoxelRGBA &aa, const float &bb)
627  {
628  #ifdef CARTO_DEBUG_RGB
629  std::cout << "RGBA:: RGBA - float" << std::endl;
630  #endif
631  VoxelRGBA result( aa );
632  return result -= static_cast<uint8_t>(bb);
633  }
634 
635  inline
636  VoxelRGBA operator - (const VoxelRGBA &aa, const double &bb)
637  {
638  #ifdef CARTO_DEBUG_RGB
639  std::cout << "RGBA:: RGBA - double" << std::endl;
640  #endif
641  VoxelRGBA result( aa );
642  return result -= static_cast<uint8_t>(bb);
643  }
644 
645  inline
646  VoxelRGBA operator - (const uint8_t &aa, const VoxelRGBA &bb)
647  {
648  #ifdef CARTO_DEBUG_RGB
649  std::cout << "RGBA:: uint8_t - RGBA" << std::endl;
650  #endif
651  VoxelRGBA result( aa );
652  return result -= bb;
653  }
654 
655  inline
656  VoxelRGBA operator - (const uint16_t &aa, const VoxelRGBA &bb)
657  {
658  #ifdef CARTO_DEBUG_RGB
659  std::cout << "RGBA:: uint16_t - RGBA" << std::endl;
660  #endif
661  VoxelRGBA result( aa );
662  return result -= bb;
663  }
664 
665  inline
666  VoxelRGBA operator - (const uint32_t &aa, const VoxelRGBA &bb)
667  {
668  #ifdef CARTO_DEBUG_RGB
669  std::cout << "RGBA:: uint32_t - RGBA" << std::endl;
670  #endif
671  VoxelRGBA result( aa );
672  return result -= bb;
673  }
674 
675  inline
676  VoxelRGBA operator - (const uint64_t &aa, const VoxelRGBA &bb)
677  {
678  #ifdef CARTO_DEBUG_RGB
679  std::cout << "RGBA:: uint64_t - RGBA" << std::endl;
680  #endif
681  VoxelRGBA result( aa );
682  return result -= bb;
683  }
684 
685  inline
686  VoxelRGBA operator - (const float &aa, const VoxelRGBA &bb)
687  {
688  #ifdef CARTO_DEBUG_RGB
689  std::cout << "RGBA:: float - RGBA" << std::endl;
690  #endif
691  VoxelRGBA result( static_cast<uint8_t>(aa) );
692  return result -= bb;
693  }
694 
695  inline
696  VoxelRGBA operator - (const double &aa, const VoxelRGBA &bb)
697  {
698  #ifdef CARTO_DEBUG_RGB
699  std::cout << "RGBA:: double - RGBA" << std::endl;
700  #endif
701  VoxelRGBA result( static_cast<uint8_t>(aa) );
702  return result -= bb;
703  }
704 
705  inline
706  VoxelRGBA operator * (const VoxelRGBA &aa, const uint8_t &bb)
707  {
708  #ifdef CARTO_DEBUG_RGB
709  std::cout << "RGBA:: RGBA * uint8_t" << std::endl;
710  #endif
711  VoxelRGBA result( aa );
712  return result *= bb;
713  }
714 
715  inline
716  VoxelRGBA operator * (const VoxelRGBA &aa, const uint16_t &bb)
717  {
718  #ifdef CARTO_DEBUG_RGB
719  std::cout << "RGBA:: RGBA * uint16_t" << std::endl;
720  #endif
721  VoxelRGBA result( aa );
722  return result *= bb;
723  }
724 
725  inline
726  VoxelRGBA operator * (const VoxelRGBA &aa, const uint32_t &bb)
727  {
728  #ifdef CARTO_DEBUG_RGB
729  std::cout << "RGBA:: RGBA * uint32_t" << std::endl;
730  #endif
731  VoxelRGBA result( aa );
732  return result *= bb;
733  }
734 
735  inline
736  VoxelRGBA operator * (const VoxelRGBA &aa, const uint64_t &bb)
737  {
738  #ifdef CARTO_DEBUG_RGB
739  std::cout << "RGBA:: RGBA * uint64_t" << std::endl;
740  #endif
741  VoxelRGBA result( aa );
742  return result *= bb;
743  }
744 
745  inline
746  VoxelRGBA operator * (const VoxelRGBA &aa, const float &bb)
747  {
748  #ifdef CARTO_DEBUG_RGB
749  std::cout << "RGBA:: RGBA * float" << std::endl;
750  #endif
751  VoxelRGBA result( aa );
752  return result *= bb;
753  }
754 
755  inline
756  VoxelRGBA operator * (const VoxelRGBA &aa, const double &bb)
757  {
758  #ifdef CARTO_DEBUG_RGB
759  std::cout << "RGBA:: RGBA * double" << std::endl;
760  #endif
761  VoxelRGBA result( aa );
762  return result *= bb;
763  }
764 
765  inline
766  VoxelRGBA operator * (const uint8_t &aa, const VoxelRGBA &bb)
767  {
768  #ifdef CARTO_DEBUG_RGB
769  std::cout << "RGBA:: uint8_t * RGBA" << std::endl;
770  #endif
771  VoxelRGBA result( bb );
772  return result *= aa;
773  }
774 
775  inline
776  VoxelRGBA operator * (const uint16_t &aa, const VoxelRGBA &bb)
777  {
778  #ifdef CARTO_DEBUG_RGB
779  std::cout << "RGBA:: uint16_t * RGBA" << std::endl;
780  #endif
781  VoxelRGBA result( bb );
782  return result *= aa;
783  }
784 
785  inline
786  VoxelRGBA operator * (const uint32_t &aa, const VoxelRGBA &bb)
787  {
788  #ifdef CARTO_DEBUG_RGB
789  std::cout << "RGBA:: uint32_t * RGBA" << std::endl;
790  #endif
791  VoxelRGBA result( bb );
792  return result *= aa;
793  }
794 
795  inline
796  VoxelRGBA operator * (const uint64_t &aa, const VoxelRGBA &bb)
797  {
798  #ifdef CARTO_DEBUG_RGB
799  std::cout << "RGBA:: uint64_t * RGBA" << std::endl;
800  #endif
801  VoxelRGBA result( bb );
802  return result *= aa;
803  }
804 
805  inline
806  VoxelRGBA operator * (const float &aa, const VoxelRGBA &bb)
807  {
808  #ifdef CARTO_DEBUG_RGB
809  std::cout << "RGBA:: float * RGBA" << std::endl;
810  #endif
811  VoxelRGBA result( bb );
812  return result *= aa;
813  }
814 
815  inline
816  VoxelRGBA operator * (const double &aa, const VoxelRGBA &bb)
817  {
818  #ifdef CARTO_DEBUG_RGB
819  std::cout << "RGBA:: double * RGBA" << std::endl;
820  #endif
821  VoxelRGBA result( bb );
822  return result *= aa;
823  }
824 
825  inline
826  VoxelRGBA operator / (const VoxelRGBA &aa, const uint8_t &bb)
827  {
828  #ifdef CARTO_DEBUG_RGB
829  std::cout << "RGBA:: RGBA / uint8_t" << std::endl;
830  #endif
831  VoxelRGBA result( aa );
832  return result /= bb;
833  }
834 
835  inline
836  VoxelRGBA operator / (const VoxelRGBA &aa, const uint16_t &bb)
837  {
838  #ifdef CARTO_DEBUG_RGB
839  std::cout << "RGBA:: RGBA / uint16_t" << std::endl;
840  #endif
841  VoxelRGBA result( aa );
842  return result /= bb;
843  }
844 
845  inline
846  VoxelRGBA operator / (const VoxelRGBA &aa, const uint32_t &bb)
847  {
848  #ifdef CARTO_DEBUG_RGB
849  std::cout << "RGBA:: RGBA / uint32_t" << std::endl;
850  #endif
851  VoxelRGBA result( aa );
852  return result /= bb;
853  }
854 
855  inline
856  VoxelRGBA operator / (const VoxelRGBA &aa, const uint64_t &bb)
857  {
858  #ifdef CARTO_DEBUG_RGB
859  std::cout << "RGBA:: RGBA / uint64_t" << std::endl;
860  #endif
861  VoxelRGBA result( aa );
862  return result /= bb;
863  }
864 
865  inline
866  VoxelRGBA operator / (const VoxelRGBA &aa, const float &bb)
867  {
868  #ifdef CARTO_DEBUG_RGB
869  std::cout << "RGBA:: RGBA / float" << std::endl;
870  #endif
871  VoxelRGBA result( aa );
872  return result /= bb;
873  }
874 
875  inline
876  VoxelRGBA operator / (const VoxelRGBA &aa, const double &bb)
877  {
878  #ifdef CARTO_DEBUG_RGB
879  std::cout << "RGBA:: RGBA / double" << std::endl;
880  #endif
881  VoxelRGBA result( aa );
882  return result /= bb;
883  }
884 
885  //=== LONG INT OPERATORS ===================================================
886 
887  inline
888  VoxelRGBA & VoxelRGBA::operator *= ( const long & value )
889  {
890  #ifdef CARTO_DEBUG_RGB
891  std::cout << "RGBA:: operator *= ( long )" << std::endl;
892  #endif
893  red() *= static_cast<uint8_t>( value );
894  green() *= static_cast<uint8_t>( value );
895  blue() *= static_cast<uint8_t>( value );
896  return *this;
897  }
898 
899  inline
900  VoxelRGBA & VoxelRGBA::operator /= ( const long & value )
901  {
902  #ifdef CARTO_DEBUG_RGB
903  std::cout << "RGBA:: operator /= ( long )" << std::endl;
904  #endif
905  ASSERT( value != 0 );
906  red() /= static_cast<uint8_t>( value );
907  green() /= static_cast<uint8_t>( value );
908  blue() /= static_cast<uint8_t>( value );
909  return *this;
910  }
911 
912  inline
913  VoxelRGBA operator * (const VoxelRGBA &aa, const long &bb)
914  {
915  #ifdef CARTO_DEBUG_RGB
916  std::cout << "RGBA:: RGBA * long" << std::endl;
917  #endif
918  VoxelRGBA result( aa );
919  return result *= bb;
920  }
921 
922  inline
923  VoxelRGBA operator * (const long &aa, const VoxelRGBA &bb)
924  {
925  #ifdef CARTO_DEBUG_RGB
926  std::cout << "RGBA:: long * RGBA" << std::endl;
927  #endif
928  VoxelRGBA result( bb );
929  return result *= aa;
930  }
931 
932  inline
933  VoxelRGBA operator / (const VoxelRGBA &aa, const long &bb)
934  {
935  #ifdef CARTO_DEBUG_RGB
936  std::cout << "RGBA:: RGBA / long" << std::endl;
937  #endif
938  VoxelRGBA result( aa );
939  return result /= bb;
940  }
941 
942 }
943 
944 #endif
RGBA Value.
VoxelRGB operator/(const VoxelRGB &aa, const uint8_t &bb)
Definition: voxelrgb_def.h:757
const uint8_t & blue() const
VoxelRGBA & operator*=(const uint8_t &value)
const uint8_t & red() const
VoxelRGB operator+(const VoxelRGB &aa, const VoxelRGB &bb)
Definition: voxelrgb_def.h:377
Base class for any multichannel data (RGB, RGBA, HSV, ...)
Definition: voxelvalue.h:58
VoxelRGB operator*(const VoxelRGB &aa, const uint8_t &bb)
Definition: voxelrgb_def.h:637
RGB Value.
Definition: voxelrgb_decl.h:71
VoxelRGBA & operator=(const VoxelRGBA &other)
VoxelRGBA & operator-=(const VoxelRGBA &other)
const uint8_t & alpha() const
VoxelRGBA & operator+=(const VoxelRGBA &other)
VoxelRGB operator-(const VoxelRGB &aa, const VoxelRGB &bb)
Definition: voxelrgb_def.h:507
const uint8_t & green() const
VoxelRGBA(const VoxelRGBA &other)
Definition: voxelrgba_def.h:61
const uint8_t & blue() const
#define ASSERT(EX)
Definition: assert.h:81
VoxelRGBA & operator/=(const uint8_t &value)
const uint8_t & green() const
const uint8_t & red() const