Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkPixelTraits.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkPixelTraits.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/11/12 21:14:30 $
00007   Version:   $Revision: 1.27 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
00018 
00019 =========================================================================*/
00020 #ifndef __itkPixelTraits_h
00021 #define __itkPixelTraits_h
00022 
00023 namespace itk
00024 {
00025 
00034 template<class TPixelType>
00035 class PixelTraits
00036 {
00037 public:
00039   itkStaticConstMacro(Dimension, unsigned int, TPixelType::Length);
00040   
00042   typedef typename TPixelType::ValueType ValueType;
00043 };
00044 
00046 template <>
00047 class PixelTraits<bool>
00048 {
00049 public:
00050   itkStaticConstMacro(Dimension, unsigned int, 1);
00051   typedef bool ValueType;
00052 };
00053 
00054 template <>
00055 class PixelTraits<char>
00056 {
00057 public:
00058   itkStaticConstMacro(Dimension, unsigned int, 1);
00059   typedef char ValueType;
00060 };
00061 
00062 template <>
00063 class PixelTraits<signed char>
00064 {
00065 public:
00066   itkStaticConstMacro(Dimension, unsigned int, 1);
00067   typedef char ValueType;
00068 };
00069 
00070 template <>
00071 class PixelTraits<unsigned char>
00072 {
00073 public:
00074   itkStaticConstMacro(Dimension, unsigned int, 1);
00075   typedef unsigned char ValueType;
00076 };
00077 
00078 template <>
00079 class PixelTraits<short>
00080 {
00081 public:
00082   itkStaticConstMacro(Dimension, unsigned int, 1);
00083   typedef short ValueType;
00084 };
00085 
00086 template <>
00087 class PixelTraits<unsigned short>
00088 {
00089 public:
00090   itkStaticConstMacro(Dimension, unsigned int, 1);
00091   typedef unsigned short ValueType;
00092 };
00093 
00094 template <>
00095 class PixelTraits<int>
00096 {
00097 public:
00098   itkStaticConstMacro(Dimension, unsigned int, 1);
00099   typedef int ValueType;
00100 };
00101 
00102 template <>
00103 class PixelTraits<unsigned int>
00104 {
00105 public:
00106   itkStaticConstMacro(Dimension, unsigned int, 1);
00107   typedef unsigned int ValueType;
00108 };
00109 
00110 template <>
00111 class PixelTraits<long>
00112 {
00113 public:
00114   itkStaticConstMacro(Dimension, unsigned int, 1);
00115   typedef long ValueType;
00116 };
00117 
00118 template <>
00119 class PixelTraits<unsigned long>
00120 {
00121 public:
00122   itkStaticConstMacro(Dimension, unsigned int, 1);
00123   typedef unsigned long ValueType;
00124 };
00125 
00126 template <>
00127 class PixelTraits<float>
00128 {
00129 public:
00130   itkStaticConstMacro(Dimension, unsigned int, 1);
00131   typedef float ValueType;
00132 };
00133 
00134 template <>
00135 class PixelTraits<double>
00136 {
00137 public:
00138   itkStaticConstMacro(Dimension, unsigned int, 1);
00139   typedef double ValueType;
00140 };
00141 
00159 template <class TValueType1, class TValueType2>
00160 class JoinTraits
00161 {
00162 public:
00163   typedef TValueType1 ValueType;
00164 };
00165 
00167 template<>
00168 class JoinTraits<bool, bool>
00169 {
00170 public:
00171   typedef bool ValueType;
00172 };
00173 
00174 template<>
00175 class JoinTraits<bool, char>
00176 {
00177 public:
00178   typedef char ValueType;
00179 };
00180 
00181 template<>
00182 class JoinTraits<bool, unsigned char>
00183 {
00184 public:
00185   typedef unsigned char ValueType;
00186 };
00187 
00188 template<>
00189 class JoinTraits<bool, short>
00190 {
00191 public:
00192   typedef short ValueType;
00193 };
00194 
00195 template<>
00196 class JoinTraits<bool, unsigned short>
00197 {
00198 public:
00199   typedef unsigned short ValueType;
00200 };
00201 
00202 template<>
00203 class JoinTraits<bool, int>
00204 {
00205 public:
00206   typedef int ValueType;
00207 };
00208 
00209 template<>
00210 class JoinTraits<bool, unsigned int>
00211 {
00212 public:
00213   typedef unsigned int ValueType;
00214 };
00215 
00216 template<>
00217 class JoinTraits<bool, long>
00218 {
00219 public:
00220   typedef long ValueType;
00221 };
00222 
00223 template<>
00224 class JoinTraits<bool, unsigned long>
00225 {
00226 public:
00227   typedef unsigned long ValueType;
00228 };
00229 
00230 template<>
00231 class JoinTraits<bool, float>
00232 {
00233 public:
00234   typedef float ValueType;
00235 };
00236 
00237 template<>
00238 class JoinTraits<bool, double>
00239 {
00240 public:
00241   typedef double ValueType;
00242 };
00243 
00245 template<>
00246 class JoinTraits<char, bool>
00247 {
00248 public:
00249   typedef char ValueType;
00250 };
00251 
00252 template<>
00253 class JoinTraits<char, char>
00254 {
00255 public:
00256   typedef char ValueType;
00257 };
00258 
00259 template<>
00260 class JoinTraits<char, unsigned char>
00261 {
00262 public:
00263   typedef short ValueType;
00264 };
00265 
00266 template<>
00267 class JoinTraits<char, short>
00268 {
00269 public:
00270   typedef short ValueType;
00271 };
00272 
00273 template<>
00274 class JoinTraits<char, unsigned short>
00275 {
00276 public:
00277   typedef int ValueType;
00278 };
00279 
00280 template<>
00281 class JoinTraits<char, int>
00282 {
00283 public:
00284   typedef int ValueType;
00285 };
00286 
00287 template<>
00288 class JoinTraits<char, unsigned int>
00289 {
00290 public:
00291   // unsigned int & unsigned long may be the same size, so promote to float
00292   typedef float ValueType;
00293 };
00294 
00295 template<>
00296 class JoinTraits<char, long>
00297 {
00298 public:
00299   typedef long ValueType;
00300 };
00301 
00302 template<>
00303 class JoinTraits<char, unsigned long>
00304 {
00305 public:
00306   typedef float ValueType;
00307 };
00308 
00309 template<>
00310 class JoinTraits<char, float>
00311 {
00312 public:
00313   typedef float ValueType;
00314 };
00315 
00316 template<>
00317 class JoinTraits<char, double>
00318 {
00319 public:
00320   typedef double ValueType;
00321 };
00322 
00324 template<>
00325 class JoinTraits<unsigned char, bool>
00326 {
00327 public:
00328   typedef unsigned char ValueType;
00329 };
00330 
00331 template<>
00332 class JoinTraits<unsigned char, char>
00333 {
00334 public:
00335   typedef short ValueType;
00336 };
00337 
00338 template<>
00339 class JoinTraits<unsigned char, unsigned char>
00340 {
00341 public:
00342   typedef unsigned char ValueType;
00343 };
00344 
00345 template<>
00346 class JoinTraits<unsigned char, short>
00347 {
00348 public:
00349   typedef short ValueType;
00350 };
00351 
00352 template<>
00353 class JoinTraits<unsigned char, unsigned short>
00354 {
00355 public:
00356   typedef unsigned short ValueType;
00357 };
00358 
00359 template<>
00360 class JoinTraits<unsigned char, int>
00361 {
00362 public:
00363   typedef int ValueType;
00364 };
00365 
00366 template<>
00367 class JoinTraits<unsigned char, unsigned int>
00368 {
00369 public:
00370   typedef unsigned int ValueType;
00371 };
00372 
00373 template<>
00374 class JoinTraits<unsigned char, long>
00375 {
00376 public:
00377   typedef long ValueType;
00378 };
00379 
00380 template<>
00381 class JoinTraits<unsigned char, unsigned long>
00382 {
00383 public:
00384   typedef unsigned long ValueType;
00385 };
00386 
00387 template<>
00388 class JoinTraits<unsigned char, float>
00389 {
00390 public:
00391   typedef float ValueType;
00392 };
00393 
00394 template<>
00395 class JoinTraits<unsigned char, double>
00396 {
00397 public:
00398   typedef double ValueType;
00399 };
00400   
00402 template<>
00403 class JoinTraits<short, bool>
00404 {
00405 public:
00406   typedef short ValueType;
00407 };
00408 
00409 template<>
00410 class JoinTraits<short, char>
00411 {
00412 public:
00413   typedef short ValueType;
00414 };
00415 
00416 template<>
00417 class JoinTraits<short, unsigned char>
00418 {
00419 public:
00420   typedef short ValueType;
00421 };
00422 
00423 template<>
00424 class JoinTraits<short, short>
00425 {
00426 public:
00427   typedef short ValueType;
00428 };
00429 
00430 template<>
00431 class JoinTraits<short, unsigned short>
00432 {
00433 public:
00434   typedef int ValueType;
00435 };
00436 
00437 template<>
00438 class JoinTraits<short, int>
00439 {
00440 public:
00441   typedef int ValueType;
00442 };
00443 
00444 template<>
00445 class JoinTraits<short, unsigned int>
00446 {
00447 public:
00448   // unsigned int & unsigned long may be the same size, so promote to float
00449   typedef float ValueType;
00450 };
00451 
00452 template<>
00453 class JoinTraits<short, long>
00454 {
00455 public:
00456   typedef long ValueType;
00457 };
00458 
00459 template<>
00460 class JoinTraits<short, unsigned long>
00461 {
00462 public:
00463   typedef float ValueType;
00464 };
00465 
00466 template<>
00467 class JoinTraits<short, float>
00468 {
00469 public:
00470   typedef float ValueType;
00471 };
00472 
00473 template<>
00474 class JoinTraits<short, double>
00475 {
00476 public:
00477   typedef double ValueType;
00478 };
00479   
00481 template<>
00482 class JoinTraits<unsigned short, bool>
00483 {
00484 public:
00485   typedef unsigned short ValueType;
00486 };
00487 
00488 template<>
00489 class JoinTraits<unsigned short, char>
00490 {
00491 public:
00492   typedef int ValueType;
00493 };
00494 
00495 template<>
00496 class JoinTraits<unsigned short, unsigned char>
00497 {
00498 public:
00499   typedef unsigned short ValueType;
00500 };
00501 
00502 template<>
00503 class JoinTraits<unsigned short, short>
00504 {
00505 public:
00506   typedef int ValueType;
00507 };
00508 
00509 template<>
00510 class JoinTraits<unsigned short, unsigned short>
00511 {
00512 public:
00513   typedef unsigned short ValueType;
00514 };
00515 
00516 template<>
00517 class JoinTraits<unsigned short, int>
00518 {
00519 public:
00520   typedef int ValueType;
00521 };
00522 
00523 template<>
00524 class JoinTraits<unsigned short, unsigned int>
00525 {
00526 public:
00527   typedef unsigned int ValueType;
00528 };
00529 
00530 template<>
00531 class JoinTraits<unsigned short, long>
00532 {
00533 public:
00534   typedef long ValueType;
00535 };
00536 
00537 template<>
00538 class JoinTraits<unsigned short, unsigned long>
00539 {
00540 public:
00541   typedef unsigned long ValueType;
00542 };
00543 
00544 template<>
00545 class JoinTraits<unsigned short, float>
00546 {
00547 public:
00548   typedef float ValueType;
00549 };
00550 
00551 template<>
00552 class JoinTraits<unsigned short, double>
00553 {
00554 public:
00555   typedef double ValueType;
00556 };
00557   
00559 template<>
00560 class JoinTraits<int, bool>
00561 {
00562 public:
00563   typedef int ValueType;
00564 };
00565 
00566 template<>
00567 class JoinTraits<int, char>
00568 {
00569 public:
00570   typedef int ValueType;
00571 };
00572 
00573 template<>
00574 class JoinTraits<int, unsigned char>
00575 {
00576 public:
00577   typedef int ValueType;
00578 };
00579 
00580 template<>
00581 class JoinTraits<int, short>
00582 {
00583 public:
00584   typedef int ValueType;
00585 };
00586 
00587 template<>
00588 class JoinTraits<int, unsigned short>
00589 {
00590 public:
00591   typedef int ValueType;
00592 };
00593 
00594 template<>
00595 class JoinTraits<int, int>
00596 {
00597 public:
00598   typedef int ValueType;
00599 };
00600 
00601 template<>
00602 class JoinTraits<int, unsigned int>
00603 {
00604 public:
00605   // unsigned int & unsigned long may be the same size, so promote to float
00606   typedef float ValueType;
00607 };
00608 
00609 template<>
00610 class JoinTraits<int, long>
00611 {
00612 public:
00613   typedef long ValueType;
00614 };
00615 
00616 template<>
00617 class JoinTraits<int, unsigned long>
00618 {
00619 public:
00620   typedef float ValueType;
00621 };
00622 
00623 template<>
00624 class JoinTraits<int, float>
00625 {
00626 public:
00627   typedef float ValueType;
00628 };
00629 
00630 template<>
00631 class JoinTraits<int, double>
00632 {
00633 public:
00634   typedef double ValueType;
00635 };
00636   
00638 template<>
00639 class JoinTraits<unsigned int, bool>
00640 {
00641 public:
00642   typedef unsigned int ValueType;
00643 };
00644 
00645 template<>
00646 class JoinTraits<unsigned int, char>
00647 {
00648 public:
00649   // unsigned int & unsigned long may be the same size, so promote to float
00650   typedef float ValueType;
00651 };
00652 
00653 template<>
00654 class JoinTraits<unsigned int, unsigned char>
00655 {
00656 public:
00657   typedef unsigned int ValueType;
00658 };
00659 
00660 template<>
00661 class JoinTraits<unsigned int, short>
00662 {
00663 public:
00664   // unsigned int & unsigned long may be the same size, so promote to float
00665   typedef float ValueType;
00666 };
00667 
00668 template<>
00669 class JoinTraits<unsigned int, unsigned short>
00670 {
00671 public:
00672   typedef unsigned int ValueType;
00673 };
00674 
00675 template<>
00676 class JoinTraits<unsigned int, int>
00677 {
00678 public:
00679   // unsigned int & unsigned long may be the same size, so promote to float
00680   typedef float ValueType;
00681 };
00682 
00683 template<>
00684 class JoinTraits<unsigned int, unsigned int>
00685 {
00686 public:
00687   typedef unsigned int ValueType;
00688 };
00689 
00690 template<>
00691 class JoinTraits<unsigned int, long>
00692 {
00693 public:
00694   typedef float ValueType;
00695 };
00696 
00697 template<>
00698 class JoinTraits<unsigned int, unsigned long>
00699 {
00700 public:
00701   typedef unsigned long ValueType;
00702 };
00703 
00704 template<>
00705 class JoinTraits<unsigned int, float>
00706 {
00707 public:
00708   typedef float ValueType;
00709 };
00710 
00711 template<>
00712 class JoinTraits<unsigned int, double>
00713 {
00714 public:
00715   typedef double ValueType;
00716 };
00717   
00719 template<>
00720 class JoinTraits<long, bool>
00721 {
00722 public:
00723   typedef long ValueType;
00724 };
00725 
00726 template<>
00727 class JoinTraits<long, char>
00728 {
00729 public:
00730   typedef long ValueType;
00731 };
00732 
00733 template<>
00734 class JoinTraits<long, unsigned char>
00735 {
00736 public:
00737   typedef long ValueType;
00738 };
00739 
00740 template<>
00741 class JoinTraits<long, short>
00742 {
00743 public:
00744   typedef long ValueType;
00745 };
00746 
00747 template<>
00748 class JoinTraits<long, unsigned short>
00749 {
00750 public:
00751   typedef long ValueType;
00752 };
00753 
00754 template<>
00755 class JoinTraits<long, int>
00756 {
00757 public:
00758   typedef long ValueType;
00759 };
00760 
00761 template<>
00762 class JoinTraits<long, unsigned int>
00763 {
00764 public:
00765   typedef float ValueType;
00766 };
00767 
00768 template<>
00769 class JoinTraits<long, long>
00770 {
00771 public:
00772   typedef long ValueType;
00773 };
00774 
00775 template<>
00776 class JoinTraits<long, unsigned long>
00777 {
00778 public:
00779   typedef float ValueType;
00780 };
00781 
00782 template<>
00783 class JoinTraits<long, float>
00784 {
00785 public:
00786   typedef float ValueType;
00787 };
00788 
00789 template<>
00790 class JoinTraits<long, double>
00791 {
00792 public:
00793   typedef double ValueType;
00794 };
00795   
00797 template<>
00798 class JoinTraits<unsigned long, bool>
00799 {
00800 public:
00801   typedef unsigned long ValueType;
00802 };
00803 
00804 template<>
00805 class JoinTraits<unsigned long, char>
00806 {
00807 public:
00808   typedef float ValueType;
00809 };
00810 
00811 template<>
00812 class JoinTraits<unsigned long, unsigned char>
00813 {
00814 public:
00815   typedef unsigned long ValueType;
00816 };
00817 
00818 template<>
00819 class JoinTraits<unsigned long, short>
00820 {
00821 public:
00822   typedef float ValueType;
00823 };
00824 
00825 template<>
00826 class JoinTraits<unsigned long, unsigned short>
00827 {
00828 public:
00829   typedef unsigned long ValueType;
00830 };
00831 
00832 template<>
00833 class JoinTraits<unsigned long, int>
00834 {
00835 public:
00836   typedef float ValueType;
00837 };
00838 
00839 template<>
00840 class JoinTraits<unsigned long, unsigned int>
00841 {
00842 public:
00843   typedef unsigned long ValueType;
00844 };
00845 
00846 template<>
00847 class JoinTraits<unsigned long, long>
00848 {
00849 public:
00850   typedef float ValueType;
00851 };
00852 
00853 template<>
00854 class JoinTraits<unsigned long, unsigned long>
00855 {
00856 public:
00857   typedef unsigned long ValueType;
00858 };
00859 
00860 template<>
00861 class JoinTraits<unsigned long, float>
00862 {
00863 public:
00864   typedef float ValueType;
00865 };
00866 
00867 template<>
00868 class JoinTraits<unsigned long, double>
00869 {
00870 public:
00871   typedef double ValueType;
00872 };
00873   
00875 template<>
00876 class JoinTraits<float, bool>
00877 {
00878 public:
00879   typedef float ValueType;
00880 };
00881 
00882 template<>
00883 class JoinTraits<float, char>
00884 {
00885 public:
00886   typedef float ValueType;
00887 };
00888 
00889 template<>
00890 class JoinTraits<float, unsigned char>
00891 {
00892 public:
00893   typedef float ValueType;
00894 };
00895 
00896 template<>
00897 class JoinTraits<float, short>
00898 {
00899 public:
00900   typedef float ValueType;
00901 };
00902 
00903 template<>
00904 class JoinTraits<float, unsigned short>
00905 {
00906 public:
00907   typedef float ValueType;
00908 };
00909 
00910 template<>
00911 class JoinTraits<float, int>
00912 {
00913 public:
00914   typedef float ValueType;
00915 };
00916 
00917 template<>
00918 class JoinTraits<float, unsigned int>
00919 {
00920 public:
00921   typedef float ValueType;
00922 };
00923 
00924 template<>
00925 class JoinTraits<float, long>
00926 {
00927 public:
00928   typedef float ValueType;
00929 };
00930 
00931 template<>
00932 class JoinTraits<float, unsigned long>
00933 {
00934 public:
00935   typedef float ValueType;
00936 };
00937 
00938 template<>
00939 class JoinTraits<float, float>
00940 {
00941 public:
00942   typedef float ValueType;
00943 };
00944 
00945 template<>
00946 class JoinTraits<float, double>
00947 {
00948 public:
00949   typedef double ValueType;
00950 };
00951   
00953 template<>
00954 class JoinTraits<double, bool>
00955 {
00956 public:
00957   typedef double ValueType;
00958 };
00959 
00960 template<>
00961 class JoinTraits<double, char>
00962 {
00963 public:
00964   typedef double ValueType;
00965 };
00966 
00967 template<>
00968 class JoinTraits<double, unsigned char>
00969 {
00970 public:
00971   typedef double ValueType;
00972 };
00973 
00974 template<>
00975 class JoinTraits<double, short>
00976 {
00977 public:
00978   typedef double ValueType;
00979 };
00980 
00981 template<>
00982 class JoinTraits<double, unsigned short>
00983 {
00984 public:
00985   typedef double ValueType;
00986 };
00987 
00988 template<>
00989 class JoinTraits<double, int>
00990 {
00991 public:
00992   typedef double ValueType;
00993 };
00994 
00995 template<>
00996 class JoinTraits<double, unsigned int>
00997 {
00998 public:
00999   typedef double ValueType;
01000 };
01001 
01002 template<>
01003 class JoinTraits<double, long>
01004 {
01005 public:
01006   typedef double ValueType;
01007 };
01008 
01009 template<>
01010 class JoinTraits<double, unsigned long>
01011 {
01012 public:
01013   typedef double ValueType;
01014 };
01015 
01016 template<>
01017 class JoinTraits<double, float>
01018 {
01019 public:
01020   typedef double ValueType;
01021 };
01022 
01023 template<>
01024 class JoinTraits<double, double>
01025 {
01026 public:
01027   typedef double ValueType;
01028 };
01029   
01030 } // end namespace itk
01031 
01032 #endif // __itkPixelTraits_h

Generated at Wed Mar 30 00:07:39 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000