1 /*=========================================================================
3 Module: $RCSfile: bbitkAnyImageToTypedImage.h,v $
5 Date: $Date: 2009/05/18 10:45:43 $
6 Version: $Revision: 1.9 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
34 #ifndef __bbitkAnyImageToTypedImage_h_INCLUDED__
35 #define __bbitkAnyImageToTypedImage_h_INCLUDED__
37 #include "bbtkAtomicBlackBox.h"
38 #include "bbitkImage.h"
43 //=================================================================
44 // BlackBox declaration
45 template <class itkImageTypePointer>
46 class AnyImageToTypedImage : public bbtk::AtomicBlackBox
48 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
51 BBTK_DECLARE_INPUT(In,anyImagePointer);
52 BBTK_DECLARE_OUTPUT(Out,itkImageTypePointer);
56 //=================================================================
58 //=================================================================
59 // BlackBox description
60 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage,
61 bbtk::AtomicBlackBox);
62 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To"
63 +bbtk::HumanTypeName<T>());
64 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
65 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
66 bbtk::HumanTypeName<anyImagePointer>()+
67 ") into a typed itk image pointer ("+
68 bbtk::HumanTypeName<T>()+")");
69 BBTK_DEFAULT_ADAPTOR();
70 BBTK_TEMPLATE_INPUT(AnyImageToTypedImage,In,
71 "Input generic image pointer",anyImagePointer);
72 BBTK_TEMPLATE_OUTPUT(AnyImageToTypedImage,Out,
73 "Output typed image pointer",T);
74 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
75 //=================================================================
77 //=================================================================
78 template <class itkImageTypePointer>
79 void AnyImageToTypedImage<itkImageTypePointer>::DoIt()
81 if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
83 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
87 bbtkError(this->bbGetFullName()<<+" : transform of <"
88 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
89 <<bbtk::TypeName<itkImageTypePointer>()<<"> not implemented");
92 //=================================================================
95 //===================================================
97 void AnyImageToTypedImage<T1>::bbUserSetDefaultValues() {}
99 void AnyImageToTypedImage<T1>::bbUserInitializeProcessing(){}
101 void AnyImageToTypedImage<T1>::bbUserFinalizeProcessing() {}
102 //===================================================
117 //=================================================================
118 // BlackBox declaration
119 template <class itkImageTypePointer, class itkImageTypeConstPointer>
120 class AnyImageToConstTypedImage : public bbtk::AtomicBlackBox
122 BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
123 bbtk::AtomicBlackBox,
125 itkImageTypeConstPointer);
126 BBTK_DECLARE_INPUT(In,anyImagePointer);
127 BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
131 //=================================================================
133 //=================================================================
134 // BlackBox description
135 BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage,
136 bbtk::AtomicBlackBox);
137 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To" +
138 bbtk::HumanTypeName<T2>());
139 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
140 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
141 bbtk::HumanTypeName<anyImagePointer>()+
142 ") into a const typed itk image pointer ("+
143 bbtk::HumanTypeName<T2>()+")");
144 BBTK_CATEGORY("adaptor");
145 BBTK_DEFAULT_ADAPTOR();
146 BBTK_TEMPLATE2_INPUT(AnyImageToConstTypedImage,In,
147 "Input generic image pointer",anyImagePointer);
148 BBTK_TEMPLATE2_OUTPUT(AnyImageToConstTypedImage,Out,
149 "Output const typed image pointer",T2);
150 BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
151 //=================================================================
153 //=================================================================
154 template <class itkImageTypePointer, class itkImageTypeConstPointer>
155 void AnyImageToConstTypedImage<itkImageTypePointer,
156 itkImageTypeConstPointer>::DoIt()
158 if ( bbGetInputIn().type() == typeid(itkImageTypeConstPointer) )
160 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypeConstPointer >() );
162 else if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
164 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
168 bbtkError(this->bbGetFullName()<<+" : transform of <"
169 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
170 <<bbtk::TypeName<itkImageTypeConstPointer>()<<"> not implemented");
173 //=================================================================
175 //===================================================
176 template <class T1, class T2>
177 void AnyImageToConstTypedImage<T1,T2>::bbUserSetDefaultValues() {}
178 template <class T1, class T2>
179 void AnyImageToConstTypedImage<T1,T2>::bbUserInitializeProcessing(){}
180 template <class T1, class T2>
181 void AnyImageToConstTypedImage<T1,T2>::bbUserFinalizeProcessing() {}
182 //===================================================