2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
27 /*=========================================================================
29 Module: $RCSfile: bbitkAnyImageToTypedImage.h,v $
31 Date: $Date: 2012/11/16 08:50:39 $
32 Version: $Revision: 1.10 $
33 =========================================================================*/
40 #ifndef __bbitkAnyImageToTypedImage_h_INCLUDED__
41 #define __bbitkAnyImageToTypedImage_h_INCLUDED__
43 #include "bbtkAtomicBlackBox.h"
44 #include "bbitkImage.h"
49 //=================================================================
50 // BlackBox declaration
51 template <class itkImageTypePointer>
52 class AnyImageToTypedImage : public bbtk::AtomicBlackBox
54 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
57 BBTK_DECLARE_INPUT(In,anyImagePointer);
58 BBTK_DECLARE_OUTPUT(Out,itkImageTypePointer);
62 //=================================================================
64 //=================================================================
65 // BlackBox description
66 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage,
67 bbtk::AtomicBlackBox);
68 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To"
69 +bbtk::HumanTypeName<T>());
70 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
71 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
72 bbtk::HumanTypeName<anyImagePointer>()+
73 ") into a typed itk image pointer ("+
74 bbtk::HumanTypeName<T>()+")");
75 BBTK_DEFAULT_ADAPTOR();
76 BBTK_TEMPLATE_INPUT(AnyImageToTypedImage,In,
77 "Input generic image pointer",anyImagePointer);
78 BBTK_TEMPLATE_OUTPUT(AnyImageToTypedImage,Out,
79 "Output typed image pointer",T);
80 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
81 //=================================================================
83 //=================================================================
84 template <class itkImageTypePointer>
85 void AnyImageToTypedImage<itkImageTypePointer>::DoIt()
87 if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
89 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
93 bbtkError(this->bbGetFullName()<<+" : transform of <"
94 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
95 <<bbtk::TypeName<itkImageTypePointer>()<<"> not implemented");
98 //=================================================================
101 //===================================================
103 void AnyImageToTypedImage<T1>::bbUserSetDefaultValues() {}
105 void AnyImageToTypedImage<T1>::bbUserInitializeProcessing(){}
107 void AnyImageToTypedImage<T1>::bbUserFinalizeProcessing() {}
108 //===================================================
123 //=================================================================
124 // BlackBox declaration
125 template <class itkImageTypePointer, class itkImageTypeConstPointer>
126 class AnyImageToConstTypedImage : public bbtk::AtomicBlackBox
128 BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
129 bbtk::AtomicBlackBox,
131 itkImageTypeConstPointer);
132 BBTK_DECLARE_INPUT(In,anyImagePointer);
133 BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
137 //=================================================================
139 //=================================================================
140 // BlackBox description
141 BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage,
142 bbtk::AtomicBlackBox);
143 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To" +
144 bbtk::HumanTypeName<T2>());
145 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
146 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
147 bbtk::HumanTypeName<anyImagePointer>()+
148 ") into a const typed itk image pointer ("+
149 bbtk::HumanTypeName<T2>()+")");
150 BBTK_CATEGORY("adaptor");
151 BBTK_DEFAULT_ADAPTOR();
152 BBTK_TEMPLATE2_INPUT(AnyImageToConstTypedImage,In,
153 "Input generic image pointer",anyImagePointer);
154 BBTK_TEMPLATE2_OUTPUT(AnyImageToConstTypedImage,Out,
155 "Output const typed image pointer",T2);
156 BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
157 //=================================================================
159 //=================================================================
160 template <class itkImageTypePointer, class itkImageTypeConstPointer>
161 void AnyImageToConstTypedImage<itkImageTypePointer,
162 itkImageTypeConstPointer>::DoIt()
164 if ( bbGetInputIn().type() == typeid(itkImageTypeConstPointer) )
166 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypeConstPointer >() );
168 else if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
170 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
174 bbtkError(this->bbGetFullName()<<+" : transform of <"
175 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
176 <<bbtk::TypeName<itkImageTypeConstPointer>()<<"> not implemented");
179 //=================================================================
181 //===================================================
182 template <class T1, class T2>
183 void AnyImageToConstTypedImage<T1,T2>::bbUserSetDefaultValues() {}
184 template <class T1, class T2>
185 void AnyImageToConstTypedImage<T1,T2>::bbUserInitializeProcessing(){}
186 template <class T1, class T2>
187 void AnyImageToConstTypedImage<T1,T2>::bbUserFinalizeProcessing() {}
188 //===================================================