ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkPixelTraits.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkPixelTraits_h
29 #define __itkPixelTraits_h
30 
31 #include "itkMacro.h"
32 
33 namespace itk
34 {
44 template< class TPixelType >
46 {
47 public:
49  itkStaticConstMacro(Dimension, unsigned int, TPixelType::Length);
50 
52  typedef typename TPixelType::ValueType ValueType;
53 };
54 
61 template< >
62 class PixelTraits< bool >
63 {
64 public:
65  itkStaticConstMacro(Dimension, unsigned int, 1);
66  typedef bool ValueType;
67 };
68 
69 template< >
70 class PixelTraits< char >
71 {
72 public:
73  itkStaticConstMacro(Dimension, unsigned int, 1);
74  typedef char ValueType;
75 };
76 
77 template< >
78 class PixelTraits< signed char >
79 {
80 public:
81  itkStaticConstMacro(Dimension, unsigned int, 1);
82  typedef char ValueType;
83 };
84 
85 template< >
86 class PixelTraits< unsigned char >
87 {
88 public:
89  itkStaticConstMacro(Dimension, unsigned int, 1);
90  typedef unsigned char ValueType;
91 };
92 
93 template< >
94 class PixelTraits< short >
95 {
96 public:
97  itkStaticConstMacro(Dimension, unsigned int, 1);
98  typedef short ValueType;
99 };
100 
101 template< >
102 class PixelTraits< unsigned short >
103 {
104 public:
105  itkStaticConstMacro(Dimension, unsigned int, 1);
106  typedef unsigned short ValueType;
107 };
108 
109 template< >
110 class PixelTraits< int >
111 {
112 public:
113  itkStaticConstMacro(Dimension, unsigned int, 1);
114  typedef int ValueType;
115 };
116 
117 template< >
118 class PixelTraits< unsigned int >
119 {
120 public:
121  itkStaticConstMacro(Dimension, unsigned int, 1);
122  typedef unsigned int ValueType;
123 };
124 
125 template< >
126 class PixelTraits< long >
127 {
128 public:
129  itkStaticConstMacro(Dimension, unsigned int, 1);
130  typedef long ValueType;
131 };
132 
133 template< >
134 class PixelTraits< unsigned long >
135 {
136 public:
137  itkStaticConstMacro(Dimension, unsigned int, 1);
138  typedef unsigned long ValueType;
139 };
140 
141 template< >
142 class PixelTraits< float >
143 {
144 public:
145  itkStaticConstMacro(Dimension, unsigned int, 1);
146  typedef float ValueType;
147 };
148 
149 template< >
150 class PixelTraits< double >
151 {
152 public:
153  itkStaticConstMacro(Dimension, unsigned int, 1);
154  typedef double ValueType;
155 };
156 
177 template< class TValueType1, class TValueType2 >
179 {
180 public:
181  typedef TValueType1 ValueType;
182 };
183 
190 template< >
191 class JoinTraits< bool, bool >
192 {
193 public:
194  typedef bool ValueType;
195 };
196 
197 template< >
198 class JoinTraits< bool, char >
199 {
200 public:
201  typedef char ValueType;
202 };
203 
204 template< >
205 class JoinTraits< bool, unsigned char >
206 {
207 public:
208  typedef unsigned char ValueType;
209 };
210 
211 template< >
212 class JoinTraits< bool, short >
213 {
214 public:
215  typedef short ValueType;
216 };
217 
218 template< >
219 class JoinTraits< bool, unsigned short >
220 {
221 public:
222  typedef unsigned short ValueType;
223 };
224 
225 template< >
226 class JoinTraits< bool, int >
227 {
228 public:
229  typedef int ValueType;
230 };
231 
232 template< >
233 class JoinTraits< bool, unsigned int >
234 {
235 public:
236  typedef unsigned int ValueType;
237 };
238 
239 template< >
240 class JoinTraits< bool, long >
241 {
242 public:
243  typedef long ValueType;
244 };
245 
246 template< >
247 class JoinTraits< bool, unsigned long >
248 {
249 public:
250  typedef unsigned long ValueType;
251 };
252 
253 template< >
254 class JoinTraits< bool, float >
255 {
256 public:
257  typedef float ValueType;
258 };
259 
260 template< >
261 class JoinTraits< bool, double >
262 {
263 public:
264  typedef double ValueType;
265 };
266 
271 template< >
272 class JoinTraits< char, bool >
273 {
274 public:
275  typedef char ValueType;
276 };
277 
278 template< >
279 class JoinTraits< char, char >
280 {
281 public:
282  typedef char ValueType;
283 };
284 
285 template< >
286 class JoinTraits< char, unsigned char >
287 {
288 public:
289  typedef short ValueType;
290 };
291 
292 template< >
293 class JoinTraits< char, short >
294 {
295 public:
296  typedef short ValueType;
297 };
298 
299 template< >
300 class JoinTraits< char, unsigned short >
301 {
302 public:
303  typedef int ValueType;
304 };
305 
306 template< >
307 class JoinTraits< char, int >
308 {
309 public:
310  typedef int ValueType;
311 };
312 
313 template< >
314 class JoinTraits< char, unsigned int >
315 {
316 public:
317  // unsigned int & unsigned long may be the same size, so promote to float
318  typedef float ValueType;
319 };
320 
321 template< >
322 class JoinTraits< char, long >
323 {
324 public:
325  typedef long ValueType;
326 };
327 
328 template< >
329 class JoinTraits< char, unsigned long >
330 {
331 public:
332  typedef float ValueType;
333 };
334 
335 template< >
336 class JoinTraits< char, float >
337 {
338 public:
339  typedef float ValueType;
340 };
341 
342 template< >
343 class JoinTraits< char, double >
344 {
345 public:
346  typedef double ValueType;
347 };
348 
353 template< >
354 class JoinTraits< unsigned char, bool >
355 {
356 public:
357  typedef unsigned char ValueType;
358 };
359 
360 template< >
361 class JoinTraits< unsigned char, char >
362 {
363 public:
364  typedef short ValueType;
365 };
366 
367 template< >
368 class JoinTraits< unsigned char, unsigned char >
369 {
370 public:
371  typedef unsigned char ValueType;
372 };
373 
374 template< >
375 class JoinTraits< unsigned char, short >
376 {
377 public:
378  typedef short ValueType;
379 };
380 
381 template< >
382 class JoinTraits< unsigned char, unsigned short >
383 {
384 public:
385  typedef unsigned short ValueType;
386 };
387 
388 template< >
389 class JoinTraits< unsigned char, int >
390 {
391 public:
392  typedef int ValueType;
393 };
394 
395 template< >
396 class JoinTraits< unsigned char, unsigned int >
397 {
398 public:
399  typedef unsigned int ValueType;
400 };
401 
402 template< >
403 class JoinTraits< unsigned char, long >
404 {
405 public:
406  typedef long ValueType;
407 };
408 
409 template< >
410 class JoinTraits< unsigned char, unsigned long >
411 {
412 public:
413  typedef unsigned long ValueType;
414 };
415 
416 template< >
417 class JoinTraits< unsigned char, float >
418 {
419 public:
420  typedef float ValueType;
421 };
422 
423 template< >
424 class JoinTraits< unsigned char, double >
425 {
426 public:
427  typedef double ValueType;
428 };
429 
434 template< >
435 class JoinTraits< short, bool >
436 {
437 public:
438  typedef short ValueType;
439 };
440 
441 template< >
442 class JoinTraits< short, char >
443 {
444 public:
445  typedef short ValueType;
446 };
447 
448 template< >
449 class JoinTraits< short, unsigned char >
450 {
451 public:
452  typedef short ValueType;
453 };
454 
455 template< >
456 class JoinTraits< short, short >
457 {
458 public:
459  typedef short ValueType;
460 };
461 
462 template< >
463 class JoinTraits< short, unsigned short >
464 {
465 public:
466  typedef int ValueType;
467 };
468 
469 template< >
470 class JoinTraits< short, int >
471 {
472 public:
473  typedef int ValueType;
474 };
475 
476 template< >
477 class JoinTraits< short, unsigned int >
478 {
479 public:
480  // unsigned int & unsigned long may be the same size, so promote to float
481  typedef float ValueType;
482 };
483 
484 template< >
485 class JoinTraits< short, long >
486 {
487 public:
488  typedef long ValueType;
489 };
490 
491 template< >
492 class JoinTraits< short, unsigned long >
493 {
494 public:
495  typedef float ValueType;
496 };
497 
498 template< >
499 class JoinTraits< short, float >
500 {
501 public:
502  typedef float ValueType;
503 };
504 
505 template< >
506 class JoinTraits< short, double >
507 {
508 public:
509  typedef double ValueType;
510 };
511 
516 template< >
517 class JoinTraits< unsigned short, bool >
518 {
519 public:
520  typedef unsigned short ValueType;
521 };
522 
523 template< >
524 class JoinTraits< unsigned short, char >
525 {
526 public:
527  typedef int ValueType;
528 };
529 
530 template< >
531 class JoinTraits< unsigned short, unsigned char >
532 {
533 public:
534  typedef unsigned short ValueType;
535 };
536 
537 template< >
538 class JoinTraits< unsigned short, short >
539 {
540 public:
541  typedef int ValueType;
542 };
543 
544 template< >
545 class JoinTraits< unsigned short, unsigned short >
546 {
547 public:
548  typedef unsigned short ValueType;
549 };
550 
551 template< >
552 class JoinTraits< unsigned short, int >
553 {
554 public:
555  typedef int ValueType;
556 };
557 
558 template< >
559 class JoinTraits< unsigned short, unsigned int >
560 {
561 public:
562  typedef unsigned int ValueType;
563 };
564 
565 template< >
566 class JoinTraits< unsigned short, long >
567 {
568 public:
569  typedef long ValueType;
570 };
571 
572 template< >
573 class JoinTraits< unsigned short, unsigned long >
574 {
575 public:
576  typedef unsigned long ValueType;
577 };
578 
579 template< >
580 class JoinTraits< unsigned short, float >
581 {
582 public:
583  typedef float ValueType;
584 };
585 
586 template< >
587 class JoinTraits< unsigned short, double >
588 {
589 public:
590  typedef double ValueType;
591 };
592 
597 template< >
598 class JoinTraits< int, bool >
599 {
600 public:
601  typedef int ValueType;
602 };
603 
604 template< >
605 class JoinTraits< int, char >
606 {
607 public:
608  typedef int ValueType;
609 };
610 
611 template< >
612 class JoinTraits< int, unsigned char >
613 {
614 public:
615  typedef int ValueType;
616 };
617 
618 template< >
619 class JoinTraits< int, short >
620 {
621 public:
622  typedef int ValueType;
623 };
624 
625 template< >
626 class JoinTraits< int, unsigned short >
627 {
628 public:
629  typedef int ValueType;
630 };
631 
632 template< >
633 class JoinTraits< int, int >
634 {
635 public:
636  typedef int ValueType;
637 };
638 
639 template< >
640 class JoinTraits< int, unsigned int >
641 {
642 public:
643  // unsigned int & unsigned long may be the same size, so promote to float
644  typedef float ValueType;
645 };
646 
647 template< >
648 class JoinTraits< int, long >
649 {
650 public:
651  typedef long ValueType;
652 };
653 
654 template< >
655 class JoinTraits< int, unsigned long >
656 {
657 public:
658  typedef float ValueType;
659 };
660 
661 template< >
662 class JoinTraits< int, float >
663 {
664 public:
665  typedef float ValueType;
666 };
667 
668 template< >
669 class JoinTraits< int, double >
670 {
671 public:
672  typedef double ValueType;
673 };
674 
679 template< >
680 class JoinTraits< unsigned int, bool >
681 {
682 public:
683  typedef unsigned int ValueType;
684 };
685 
686 template< >
687 class JoinTraits< unsigned int, char >
688 {
689 public:
690  // unsigned int & unsigned long may be the same size, so promote to float
691  typedef float ValueType;
692 };
693 
694 template< >
695 class JoinTraits< unsigned int, unsigned char >
696 {
697 public:
698  typedef unsigned int ValueType;
699 };
700 
701 template< >
702 class JoinTraits< unsigned int, short >
703 {
704 public:
705  // unsigned int & unsigned long may be the same size, so promote to float
706  typedef float ValueType;
707 };
708 
709 template< >
710 class JoinTraits< unsigned int, unsigned short >
711 {
712 public:
713  typedef unsigned int ValueType;
714 };
715 
716 template< >
717 class JoinTraits< unsigned int, int >
718 {
719 public:
720  // unsigned int & unsigned long may be the same size, so promote to float
721  typedef float ValueType;
722 };
723 
724 template< >
725 class JoinTraits< unsigned int, unsigned int >
726 {
727 public:
728  typedef unsigned int ValueType;
729 };
730 
731 template< >
732 class JoinTraits< unsigned int, long >
733 {
734 public:
735  typedef float ValueType;
736 };
737 
738 template< >
739 class JoinTraits< unsigned int, unsigned long >
740 {
741 public:
742  typedef unsigned long ValueType;
743 };
744 
745 template< >
746 class JoinTraits< unsigned int, float >
747 {
748 public:
749  typedef float ValueType;
750 };
751 
752 template< >
753 class JoinTraits< unsigned int, double >
754 {
755 public:
756  typedef double ValueType;
757 };
758 
763 template< >
764 class JoinTraits< long, bool >
765 {
766 public:
767  typedef long ValueType;
768 };
769 
770 template< >
771 class JoinTraits< long, char >
772 {
773 public:
774  typedef long ValueType;
775 };
776 
777 template< >
778 class JoinTraits< long, unsigned char >
779 {
780 public:
781  typedef long ValueType;
782 };
783 
784 template< >
785 class JoinTraits< long, short >
786 {
787 public:
788  typedef long ValueType;
789 };
790 
791 template< >
792 class JoinTraits< long, unsigned short >
793 {
794 public:
795  typedef long ValueType;
796 };
797 
798 template< >
799 class JoinTraits< long, int >
800 {
801 public:
802  typedef long ValueType;
803 };
804 
805 template< >
806 class JoinTraits< long, unsigned int >
807 {
808 public:
809  typedef float ValueType;
810 };
811 
812 template< >
813 class JoinTraits< long, long >
814 {
815 public:
816  typedef long ValueType;
817 };
818 
819 template< >
820 class JoinTraits< long, unsigned long >
821 {
822 public:
823  typedef float ValueType;
824 };
825 
826 template< >
827 class JoinTraits< long, float >
828 {
829 public:
830  typedef float ValueType;
831 };
832 
833 template< >
834 class JoinTraits< long, double >
835 {
836 public:
837  typedef double ValueType;
838 };
839 
844 template< >
845 class JoinTraits< unsigned long, bool >
846 {
847 public:
848  typedef unsigned long ValueType;
849 };
850 
851 template< >
852 class JoinTraits< unsigned long, char >
853 {
854 public:
855  typedef float ValueType;
856 };
857 
858 template< >
859 class JoinTraits< unsigned long, unsigned char >
860 {
861 public:
862  typedef unsigned long ValueType;
863 };
864 
865 template< >
866 class JoinTraits< unsigned long, short >
867 {
868 public:
869  typedef float ValueType;
870 };
871 
872 template< >
873 class JoinTraits< unsigned long, unsigned short >
874 {
875 public:
876  typedef unsigned long ValueType;
877 };
878 
879 template< >
880 class JoinTraits< unsigned long, int >
881 {
882 public:
883  typedef float ValueType;
884 };
885 
886 template< >
887 class JoinTraits< unsigned long, unsigned int >
888 {
889 public:
890  typedef unsigned long ValueType;
891 };
892 
893 template< >
894 class JoinTraits< unsigned long, long >
895 {
896 public:
897  typedef float ValueType;
898 };
899 
900 template< >
901 class JoinTraits< unsigned long, unsigned long >
902 {
903 public:
904  typedef unsigned long ValueType;
905 };
906 
907 template< >
908 class JoinTraits< unsigned long, float >
909 {
910 public:
911  typedef float ValueType;
912 };
913 
914 template< >
915 class JoinTraits< unsigned long, double >
916 {
917 public:
918  typedef double ValueType;
919 };
920 
925 template< >
926 class JoinTraits< float, bool >
927 {
928 public:
929  typedef float ValueType;
930 };
931 
932 template< >
933 class JoinTraits< float, char >
934 {
935 public:
936  typedef float ValueType;
937 };
938 
939 template< >
940 class JoinTraits< float, unsigned char >
941 {
942 public:
943  typedef float ValueType;
944 };
945 
946 template< >
947 class JoinTraits< float, short >
948 {
949 public:
950  typedef float ValueType;
951 };
952 
953 template< >
954 class JoinTraits< float, unsigned short >
955 {
956 public:
957  typedef float ValueType;
958 };
959 
960 template< >
961 class JoinTraits< float, int >
962 {
963 public:
964  typedef float ValueType;
965 };
966 
967 template< >
968 class JoinTraits< float, unsigned int >
969 {
970 public:
971  typedef float ValueType;
972 };
973 
974 template< >
975 class JoinTraits< float, long >
976 {
977 public:
978  typedef float ValueType;
979 };
980 
981 template< >
982 class JoinTraits< float, unsigned long >
983 {
984 public:
985  typedef float ValueType;
986 };
987 
988 template< >
989 class JoinTraits< float, float >
990 {
991 public:
992  typedef float ValueType;
993 };
994 
995 template< >
996 class JoinTraits< float, double >
997 {
998 public:
999  typedef double ValueType;
1000 };
1001 
1006 template< >
1007 class JoinTraits< double, bool >
1008 {
1009 public:
1010  typedef double ValueType;
1011 };
1012 
1013 template< >
1014 class JoinTraits< double, char >
1015 {
1016 public:
1017  typedef double ValueType;
1018 };
1019 
1020 template< >
1021 class JoinTraits< double, unsigned char >
1022 {
1023 public:
1024  typedef double ValueType;
1025 };
1026 
1027 template< >
1028 class JoinTraits< double, short >
1029 {
1030 public:
1031  typedef double ValueType;
1032 };
1033 
1034 template< >
1035 class JoinTraits< double, unsigned short >
1036 {
1037 public:
1038  typedef double ValueType;
1039 };
1040 
1041 template< >
1042 class JoinTraits< double, int >
1043 {
1044 public:
1045  typedef double ValueType;
1046 };
1047 
1048 template< >
1049 class JoinTraits< double, unsigned int >
1050 {
1051 public:
1052  typedef double ValueType;
1053 };
1054 
1055 template< >
1056 class JoinTraits< double, long >
1057 {
1058 public:
1059  typedef double ValueType;
1060 };
1061 
1062 template< >
1063 class JoinTraits< double, unsigned long >
1064 {
1065 public:
1066  typedef double ValueType;
1067 };
1068 
1069 template< >
1070 class JoinTraits< double, float >
1071 {
1072 public:
1073  typedef double ValueType;
1074 };
1075 
1076 template< >
1077 class JoinTraits< double, double >
1078 {
1079 public:
1080  typedef double ValueType;
1081 };
1082 
1085 } // end namespace itk
1086 
1087 #endif // __itkPixelTraits_h
1088