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