00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef _USE_ITK_
00033
00034 #ifndef __bbitkAnyImageToTypedImage_h_INCLUDED__
00035 #define __bbitkAnyImageToTypedImage_h_INCLUDED__
00036
00037 #include "bbtkAtomicBlackBox.h"
00038 #include "bbitkImage.h"
00039
00040 namespace bbitk
00041 {
00042
00043
00044
00045 template <class itkImageTypePointer>
00046 class AnyImageToTypedImage : public bbtk::AtomicBlackBox
00047 {
00048 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
00049 bbtk::AtomicBlackBox,
00050 itkImageTypePointer);
00051 BBTK_DECLARE_INPUT(In,anyImagePointer);
00052 BBTK_DECLARE_OUTPUT(Out,itkImageTypePointer);
00053 BBTK_PROCESS(DoIt);
00054 void DoIt();
00055 };
00056
00057
00058
00059
00060 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage,
00061 bbtk::AtomicBlackBox);
00062 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To"
00063 +bbtk::HumanTypeName<T>());
00064 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
00065 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
00066 bbtk::HumanTypeName<anyImagePointer>()+
00067 ") into a typed itk image pointer ("+
00068 bbtk::HumanTypeName<T>()+")");
00069 BBTK_DEFAULT_ADAPTOR();
00070 BBTK_TEMPLATE_INPUT(AnyImageToTypedImage,In,
00071 "Input generic image pointer",anyImagePointer);
00072 BBTK_TEMPLATE_OUTPUT(AnyImageToTypedImage,Out,
00073 "Output typed image pointer",T);
00074 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
00075
00076
00077
00078 template <class itkImageTypePointer>
00079 void AnyImageToTypedImage<itkImageTypePointer>::DoIt()
00080 {
00081 if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
00082 {
00083 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
00084 }
00085 else
00086 {
00087 bbtkError(this->bbGetFullName()<<+" : transform of <"
00088 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
00089 <<bbtk::TypeName<itkImageTypePointer>()<<"> not implemented");
00090 }
00091 }
00092
00093
00094
00095
00096 template <class itkImageTypePointer, class itkImageTypeConstPointer>
00097 class AnyImageToConstTypedImage : public bbtk::AtomicBlackBox
00098 {
00099 BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
00100 bbtk::AtomicBlackBox,
00101 itkImageTypePointer,
00102 itkImageTypeConstPointer);
00103 BBTK_DECLARE_INPUT(In,anyImagePointer);
00104 BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
00105 BBTK_PROCESS(DoIt);
00106 void DoIt();
00107 };
00108
00109
00110
00111
00112 BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage,
00113 bbtk::AtomicBlackBox);
00114 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To" +
00115 bbtk::HumanTypeName<T2>());
00116 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
00117 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
00118 bbtk::HumanTypeName<anyImagePointer>()+
00119 ") into a const typed itk image pointer ("+
00120 bbtk::HumanTypeName<T2>()+")");
00121 BBTK_CATEGORY("adaptor");
00122 BBTK_DEFAULT_ADAPTOR();
00123 BBTK_TEMPLATE2_INPUT(AnyImageToConstTypedImage,In,
00124 "Input generic image pointer",anyImagePointer);
00125 BBTK_TEMPLATE2_OUTPUT(AnyImageToConstTypedImage,Out,
00126 "Output const typed image pointer",T2);
00127 BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
00128
00129
00130
00131 template <class itkImageTypePointer, class itkImageTypeConstPointer>
00132 void AnyImageToConstTypedImage<itkImageTypePointer,
00133 itkImageTypeConstPointer>::DoIt()
00134 {
00135 if ( bbGetInputIn().type() == typeid(itkImageTypeConstPointer) )
00136 {
00137 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypeConstPointer >() );
00138 }
00139 else if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
00140 {
00141 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
00142 }
00143 else
00144 {
00145 bbtkError(this->bbGetFullName()<<+" : transform of <"
00146 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
00147 <<bbtk::TypeName<itkImageTypeConstPointer>()<<"> not implemented");
00148 }
00149 }
00150
00151
00152
00153 }
00154 #endif
00155 #endif