ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkPixelTraits.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkPixelTraits_h
00029 #define __itkPixelTraits_h
00030 
00031 #include "itkMacro.h"
00032 
00033 namespace itk
00034 {
00044 template< class TPixelType >
00045 class PixelTraits
00046 {
00047 public:
00049   itkStaticConstMacro(Dimension, unsigned int, TPixelType::Length);
00050 
00052   typedef typename TPixelType::ValueType ValueType;
00053 };
00054 
00061 template< >
00062 class PixelTraits< bool >
00063 {
00064 public:
00065   itkStaticConstMacro(Dimension, unsigned int, 1);
00066   typedef bool ValueType;
00067 };
00068 
00069 template< >
00070 class PixelTraits< char >
00071 {
00072 public:
00073   itkStaticConstMacro(Dimension, unsigned int, 1);
00074   typedef char ValueType;
00075 };
00076 
00077 template< >
00078 class PixelTraits< signed char >
00079 {
00080 public:
00081   itkStaticConstMacro(Dimension, unsigned int, 1);
00082   typedef char ValueType;
00083 };
00084 
00085 template< >
00086 class PixelTraits< unsigned char >
00087 {
00088 public:
00089   itkStaticConstMacro(Dimension, unsigned int, 1);
00090   typedef unsigned char ValueType;
00091 };
00092 
00093 template< >
00094 class PixelTraits< short >
00095 {
00096 public:
00097   itkStaticConstMacro(Dimension, unsigned int, 1);
00098   typedef short ValueType;
00099 };
00100 
00101 template< >
00102 class PixelTraits< unsigned short >
00103 {
00104 public:
00105   itkStaticConstMacro(Dimension, unsigned int, 1);
00106   typedef unsigned short ValueType;
00107 };
00108 
00109 template< >
00110 class PixelTraits< int >
00111 {
00112 public:
00113   itkStaticConstMacro(Dimension, unsigned int, 1);
00114   typedef int ValueType;
00115 };
00116 
00117 template< >
00118 class PixelTraits< unsigned int >
00119 {
00120 public:
00121   itkStaticConstMacro(Dimension, unsigned int, 1);
00122   typedef unsigned int ValueType;
00123 };
00124 
00125 template< >
00126 class PixelTraits< long >
00127 {
00128 public:
00129   itkStaticConstMacro(Dimension, unsigned int, 1);
00130   typedef long ValueType;
00131 };
00132 
00133 template< >
00134 class PixelTraits< unsigned long >
00135 {
00136 public:
00137   itkStaticConstMacro(Dimension, unsigned int, 1);
00138   typedef unsigned long ValueType;
00139 };
00140 
00141 template< >
00142 class PixelTraits< float >
00143 {
00144 public:
00145   itkStaticConstMacro(Dimension, unsigned int, 1);
00146   typedef float ValueType;
00147 };
00148 
00149 template< >
00150 class PixelTraits< double >
00151 {
00152 public:
00153   itkStaticConstMacro(Dimension, unsigned int, 1);
00154   typedef double ValueType;
00155 };
00156 
00177 template< class TValueType1, class TValueType2 >
00178 class JoinTraits
00179 {
00180 public:
00181   typedef TValueType1 ValueType;
00182 };
00183 
00190 template< >
00191 class JoinTraits< bool, bool >
00192 {
00193 public:
00194   typedef bool ValueType;
00195 };
00196 
00197 template< >
00198 class JoinTraits< bool, char >
00199 {
00200 public:
00201   typedef char ValueType;
00202 };
00203 
00204 template< >
00205 class JoinTraits< bool, unsigned char >
00206 {
00207 public:
00208   typedef unsigned char ValueType;
00209 };
00210 
00211 template< >
00212 class JoinTraits< bool, short >
00213 {
00214 public:
00215   typedef short ValueType;
00216 };
00217 
00218 template< >
00219 class JoinTraits< bool, unsigned short >
00220 {
00221 public:
00222   typedef unsigned short ValueType;
00223 };
00224 
00225 template< >
00226 class JoinTraits< bool, int >
00227 {
00228 public:
00229   typedef int ValueType;
00230 };
00231 
00232 template< >
00233 class JoinTraits< bool, unsigned int >
00234 {
00235 public:
00236   typedef unsigned int ValueType;
00237 };
00238 
00239 template< >
00240 class JoinTraits< bool, long >
00241 {
00242 public:
00243   typedef long ValueType;
00244 };
00245 
00246 template< >
00247 class JoinTraits< bool, unsigned long >
00248 {
00249 public:
00250   typedef unsigned long ValueType;
00251 };
00252 
00253 template< >
00254 class JoinTraits< bool, float >
00255 {
00256 public:
00257   typedef float ValueType;
00258 };
00259 
00260 template< >
00261 class JoinTraits< bool, double >
00262 {
00263 public:
00264   typedef double ValueType;
00265 };
00266 
00271 template< >
00272 class JoinTraits< char, bool >
00273 {
00274 public:
00275   typedef char ValueType;
00276 };
00277 
00278 template< >
00279 class JoinTraits< char, char >
00280 {
00281 public:
00282   typedef char ValueType;
00283 };
00284 
00285 template< >
00286 class JoinTraits< char, unsigned char >
00287 {
00288 public:
00289   typedef short ValueType;
00290 };
00291 
00292 template< >
00293 class JoinTraits< char, short >
00294 {
00295 public:
00296   typedef short ValueType;
00297 };
00298 
00299 template< >
00300 class JoinTraits< char, unsigned short >
00301 {
00302 public:
00303   typedef int ValueType;
00304 };
00305 
00306 template< >
00307 class JoinTraits< char, int >
00308 {
00309 public:
00310   typedef int ValueType;
00311 };
00312 
00313 template< >
00314 class JoinTraits< char, unsigned int >
00315 {
00316 public:
00317   // unsigned int & unsigned long may be the same size, so promote to float
00318   typedef float ValueType;
00319 };
00320 
00321 template< >
00322 class JoinTraits< char, long >
00323 {
00324 public:
00325   typedef long ValueType;
00326 };
00327 
00328 template< >
00329 class JoinTraits< char, unsigned long >
00330 {
00331 public:
00332   typedef float ValueType;
00333 };
00334 
00335 template< >
00336 class JoinTraits< char, float >
00337 {
00338 public:
00339   typedef float ValueType;
00340 };
00341 
00342 template< >
00343 class JoinTraits< char, double >
00344 {
00345 public:
00346   typedef double ValueType;
00347 };
00348 
00353 template< >
00354 class JoinTraits< unsigned char, bool >
00355 {
00356 public:
00357   typedef unsigned char ValueType;
00358 };
00359 
00360 template< >
00361 class JoinTraits< unsigned char, char >
00362 {
00363 public:
00364   typedef short ValueType;
00365 };
00366 
00367 template< >
00368 class JoinTraits< unsigned char, unsigned char >
00369 {
00370 public:
00371   typedef unsigned char ValueType;
00372 };
00373 
00374 template< >
00375 class JoinTraits< unsigned char, short >
00376 {
00377 public:
00378   typedef short ValueType;
00379 };
00380 
00381 template< >
00382 class JoinTraits< unsigned char, unsigned short >
00383 {
00384 public:
00385   typedef unsigned short ValueType;
00386 };
00387 
00388 template< >
00389 class JoinTraits< unsigned char, int >
00390 {
00391 public:
00392   typedef int ValueType;
00393 };
00394 
00395 template< >
00396 class JoinTraits< unsigned char, unsigned int >
00397 {
00398 public:
00399   typedef unsigned int ValueType;
00400 };
00401 
00402 template< >
00403 class JoinTraits< unsigned char, long >
00404 {
00405 public:
00406   typedef long ValueType;
00407 };
00408 
00409 template< >
00410 class JoinTraits< unsigned char, unsigned long >
00411 {
00412 public:
00413   typedef unsigned long ValueType;
00414 };
00415 
00416 template< >
00417 class JoinTraits< unsigned char, float >
00418 {
00419 public:
00420   typedef float ValueType;
00421 };
00422 
00423 template< >
00424 class JoinTraits< unsigned char, double >
00425 {
00426 public:
00427   typedef double ValueType;
00428 };
00429 
00434 template< >
00435 class JoinTraits< short, bool >
00436 {
00437 public:
00438   typedef short ValueType;
00439 };
00440 
00441 template< >
00442 class JoinTraits< short, char >
00443 {
00444 public:
00445   typedef short ValueType;
00446 };
00447 
00448 template< >
00449 class JoinTraits< short, unsigned char >
00450 {
00451 public:
00452   typedef short ValueType;
00453 };
00454 
00455 template< >
00456 class JoinTraits< short, short >
00457 {
00458 public:
00459   typedef short ValueType;
00460 };
00461 
00462 template< >
00463 class JoinTraits< short, unsigned short >
00464 {
00465 public:
00466   typedef int ValueType;
00467 };
00468 
00469 template< >
00470 class JoinTraits< short, int >
00471 {
00472 public:
00473   typedef int ValueType;
00474 };
00475 
00476 template< >
00477 class JoinTraits< short, unsigned int >
00478 {
00479 public:
00480   // unsigned int & unsigned long may be the same size, so promote to float
00481   typedef float ValueType;
00482 };
00483 
00484 template< >
00485 class JoinTraits< short, long >
00486 {
00487 public:
00488   typedef long ValueType;
00489 };
00490 
00491 template< >
00492 class JoinTraits< short, unsigned long >
00493 {
00494 public:
00495   typedef float ValueType;
00496 };
00497 
00498 template< >
00499 class JoinTraits< short, float >
00500 {
00501 public:
00502   typedef float ValueType;
00503 };
00504 
00505 template< >
00506 class JoinTraits< short, double >
00507 {
00508 public:
00509   typedef double ValueType;
00510 };
00511 
00516 template< >
00517 class JoinTraits< unsigned short, bool >
00518 {
00519 public:
00520   typedef unsigned short ValueType;
00521 };
00522 
00523 template< >
00524 class JoinTraits< unsigned short, char >
00525 {
00526 public:
00527   typedef int ValueType;
00528 };
00529 
00530 template< >
00531 class JoinTraits< unsigned short, unsigned char >
00532 {
00533 public:
00534   typedef unsigned short ValueType;
00535 };
00536 
00537 template< >
00538 class JoinTraits< unsigned short, short >
00539 {
00540 public:
00541   typedef int ValueType;
00542 };
00543 
00544 template< >
00545 class JoinTraits< unsigned short, unsigned short >
00546 {
00547 public:
00548   typedef unsigned short ValueType;
00549 };
00550 
00551 template< >
00552 class JoinTraits< unsigned short, int >
00553 {
00554 public:
00555   typedef int ValueType;
00556 };
00557 
00558 template< >
00559 class JoinTraits< unsigned short, unsigned int >
00560 {
00561 public:
00562   typedef unsigned int ValueType;
00563 };
00564 
00565 template< >
00566 class JoinTraits< unsigned short, long >
00567 {
00568 public:
00569   typedef long ValueType;
00570 };
00571 
00572 template< >
00573 class JoinTraits< unsigned short, unsigned long >
00574 {
00575 public:
00576   typedef unsigned long ValueType;
00577 };
00578 
00579 template< >
00580 class JoinTraits< unsigned short, float >
00581 {
00582 public:
00583   typedef float ValueType;
00584 };
00585 
00586 template< >
00587 class JoinTraits< unsigned short, double >
00588 {
00589 public:
00590   typedef double ValueType;
00591 };
00592 
00597 template< >
00598 class JoinTraits< int, bool >
00599 {
00600 public:
00601   typedef int ValueType;
00602 };
00603 
00604 template< >
00605 class JoinTraits< int, char >
00606 {
00607 public:
00608   typedef int ValueType;
00609 };
00610 
00611 template< >
00612 class JoinTraits< int, unsigned char >
00613 {
00614 public:
00615   typedef int ValueType;
00616 };
00617 
00618 template< >
00619 class JoinTraits< int, short >
00620 {
00621 public:
00622   typedef int ValueType;
00623 };
00624 
00625 template< >
00626 class JoinTraits< int, unsigned short >
00627 {
00628 public:
00629   typedef int ValueType;
00630 };
00631 
00632 template< >
00633 class JoinTraits< int, int >
00634 {
00635 public:
00636   typedef int ValueType;
00637 };
00638 
00639 template< >
00640 class JoinTraits< int, unsigned int >
00641 {
00642 public:
00643   // unsigned int & unsigned long may be the same size, so promote to float
00644   typedef float ValueType;
00645 };
00646 
00647 template< >
00648 class JoinTraits< int, long >
00649 {
00650 public:
00651   typedef long ValueType;
00652 };
00653 
00654 template< >
00655 class JoinTraits< int, unsigned long >
00656 {
00657 public:
00658   typedef float ValueType;
00659 };
00660 
00661 template< >
00662 class JoinTraits< int, float >
00663 {
00664 public:
00665   typedef float ValueType;
00666 };
00667 
00668 template< >
00669 class JoinTraits< int, double >
00670 {
00671 public:
00672   typedef double ValueType;
00673 };
00674 
00679 template< >
00680 class JoinTraits< unsigned int, bool >
00681 {
00682 public:
00683   typedef unsigned int ValueType;
00684 };
00685 
00686 template< >
00687 class JoinTraits< unsigned int, char >
00688 {
00689 public:
00690   // unsigned int & unsigned long may be the same size, so promote to float
00691   typedef float ValueType;
00692 };
00693 
00694 template< >
00695 class JoinTraits< unsigned int, unsigned char >
00696 {
00697 public:
00698   typedef unsigned int ValueType;
00699 };
00700 
00701 template< >
00702 class JoinTraits< unsigned int, short >
00703 {
00704 public:
00705   // unsigned int & unsigned long may be the same size, so promote to float
00706   typedef float ValueType;
00707 };
00708 
00709 template< >
00710 class JoinTraits< unsigned int, unsigned short >
00711 {
00712 public:
00713   typedef unsigned int ValueType;
00714 };
00715 
00716 template< >
00717 class JoinTraits< unsigned int, int >
00718 {
00719 public:
00720   // unsigned int & unsigned long may be the same size, so promote to float
00721   typedef float ValueType;
00722 };
00723 
00724 template< >
00725 class JoinTraits< unsigned int, unsigned int >
00726 {
00727 public:
00728   typedef unsigned int ValueType;
00729 };
00730 
00731 template< >
00732 class JoinTraits< unsigned int, long >
00733 {
00734 public:
00735   typedef float ValueType;
00736 };
00737 
00738 template< >
00739 class JoinTraits< unsigned int, unsigned long >
00740 {
00741 public:
00742   typedef unsigned long ValueType;
00743 };
00744 
00745 template< >
00746 class JoinTraits< unsigned int, float >
00747 {
00748 public:
00749   typedef float ValueType;
00750 };
00751 
00752 template< >
00753 class JoinTraits< unsigned int, double >
00754 {
00755 public:
00756   typedef double ValueType;
00757 };
00758 
00763 template< >
00764 class JoinTraits< long, bool >
00765 {
00766 public:
00767   typedef long ValueType;
00768 };
00769 
00770 template< >
00771 class JoinTraits< long, char >
00772 {
00773 public:
00774   typedef long ValueType;
00775 };
00776 
00777 template< >
00778 class JoinTraits< long, unsigned char >
00779 {
00780 public:
00781   typedef long ValueType;
00782 };
00783 
00784 template< >
00785 class JoinTraits< long, short >
00786 {
00787 public:
00788   typedef long ValueType;
00789 };
00790 
00791 template< >
00792 class JoinTraits< long, unsigned short >
00793 {
00794 public:
00795   typedef long ValueType;
00796 };
00797 
00798 template< >
00799 class JoinTraits< long, int >
00800 {
00801 public:
00802   typedef long ValueType;
00803 };
00804 
00805 template< >
00806 class JoinTraits< long, unsigned int >
00807 {
00808 public:
00809   typedef float ValueType;
00810 };
00811 
00812 template< >
00813 class JoinTraits< long, long >
00814 {
00815 public:
00816   typedef long ValueType;
00817 };
00818 
00819 template< >
00820 class JoinTraits< long, unsigned long >
00821 {
00822 public:
00823   typedef float ValueType;
00824 };
00825 
00826 template< >
00827 class JoinTraits< long, float >
00828 {
00829 public:
00830   typedef float ValueType;
00831 };
00832 
00833 template< >
00834 class JoinTraits< long, double >
00835 {
00836 public:
00837   typedef double ValueType;
00838 };
00839 
00844 template< >
00845 class JoinTraits< unsigned long, bool >
00846 {
00847 public:
00848   typedef unsigned long ValueType;
00849 };
00850 
00851 template< >
00852 class JoinTraits< unsigned long, char >
00853 {
00854 public:
00855   typedef float ValueType;
00856 };
00857 
00858 template< >
00859 class JoinTraits< unsigned long, unsigned char >
00860 {
00861 public:
00862   typedef unsigned long ValueType;
00863 };
00864 
00865 template< >
00866 class JoinTraits< unsigned long, short >
00867 {
00868 public:
00869   typedef float ValueType;
00870 };
00871 
00872 template< >
00873 class JoinTraits< unsigned long, unsigned short >
00874 {
00875 public:
00876   typedef unsigned long ValueType;
00877 };
00878 
00879 template< >
00880 class JoinTraits< unsigned long, int >
00881 {
00882 public:
00883   typedef float ValueType;
00884 };
00885 
00886 template< >
00887 class JoinTraits< unsigned long, unsigned int >
00888 {
00889 public:
00890   typedef unsigned long ValueType;
00891 };
00892 
00893 template< >
00894 class JoinTraits< unsigned long, long >
00895 {
00896 public:
00897   typedef float ValueType;
00898 };
00899 
00900 template< >
00901 class JoinTraits< unsigned long, unsigned long >
00902 {
00903 public:
00904   typedef unsigned long ValueType;
00905 };
00906 
00907 template< >
00908 class JoinTraits< unsigned long, float >
00909 {
00910 public:
00911   typedef float ValueType;
00912 };
00913 
00914 template< >
00915 class JoinTraits< unsigned long, double >
00916 {
00917 public:
00918   typedef double ValueType;
00919 };
00920 
00925 template< >
00926 class JoinTraits< float, bool >
00927 {
00928 public:
00929   typedef float ValueType;
00930 };
00931 
00932 template< >
00933 class JoinTraits< float, char >
00934 {
00935 public:
00936   typedef float ValueType;
00937 };
00938 
00939 template< >
00940 class JoinTraits< float, unsigned char >
00941 {
00942 public:
00943   typedef float ValueType;
00944 };
00945 
00946 template< >
00947 class JoinTraits< float, short >
00948 {
00949 public:
00950   typedef float ValueType;
00951 };
00952 
00953 template< >
00954 class JoinTraits< float, unsigned short >
00955 {
00956 public:
00957   typedef float ValueType;
00958 };
00959 
00960 template< >
00961 class JoinTraits< float, int >
00962 {
00963 public:
00964   typedef float ValueType;
00965 };
00966 
00967 template< >
00968 class JoinTraits< float, unsigned int >
00969 {
00970 public:
00971   typedef float ValueType;
00972 };
00973 
00974 template< >
00975 class JoinTraits< float, long >
00976 {
00977 public:
00978   typedef float ValueType;
00979 };
00980 
00981 template< >
00982 class JoinTraits< float, unsigned long >
00983 {
00984 public:
00985   typedef float ValueType;
00986 };
00987 
00988 template< >
00989 class JoinTraits< float, float >
00990 {
00991 public:
00992   typedef float ValueType;
00993 };
00994 
00995 template< >
00996 class JoinTraits< float, double >
00997 {
00998 public:
00999   typedef double ValueType;
01000 };
01001 
01006 template< >
01007 class JoinTraits< double, bool >
01008 {
01009 public:
01010   typedef double ValueType;
01011 };
01012 
01013 template< >
01014 class JoinTraits< double, char >
01015 {
01016 public:
01017   typedef double ValueType;
01018 };
01019 
01020 template< >
01021 class JoinTraits< double, unsigned char >
01022 {
01023 public:
01024   typedef double ValueType;
01025 };
01026 
01027 template< >
01028 class JoinTraits< double, short >
01029 {
01030 public:
01031   typedef double ValueType;
01032 };
01033 
01034 template< >
01035 class JoinTraits< double, unsigned short >
01036 {
01037 public:
01038   typedef double ValueType;
01039 };
01040 
01041 template< >
01042 class JoinTraits< double, int >
01043 {
01044 public:
01045   typedef double ValueType;
01046 };
01047 
01048 template< >
01049 class JoinTraits< double, unsigned int >
01050 {
01051 public:
01052   typedef double ValueType;
01053 };
01054 
01055 template< >
01056 class JoinTraits< double, long >
01057 {
01058 public:
01059   typedef double ValueType;
01060 };
01061 
01062 template< >
01063 class JoinTraits< double, unsigned long >
01064 {
01065 public:
01066   typedef double ValueType;
01067 };
01068 
01069 template< >
01070 class JoinTraits< double, float >
01071 {
01072 public:
01073   typedef double ValueType;
01074 };
01075 
01076 template< >
01077 class JoinTraits< double, double >
01078 {
01079 public:
01080   typedef double ValueType;
01081 };
01082 
01085 } // end namespace itk
01086 
01087 #endif // __itkPixelTraits_h
01088