1 /*=========================================================================
3 Module: $RCSfile: bbitkAnyImageToTypedImage.h,v $
5 Date: $Date: 2008/10/17 08:18:21 $
6 Version: $Revision: 1.8 $
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 //=================================================================
94 //=================================================================
95 // BlackBox declaration
96 template <class itkImageTypePointer, class itkImageTypeConstPointer>
97 class AnyImageToConstTypedImage : public bbtk::AtomicBlackBox
99 BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
100 bbtk::AtomicBlackBox,
102 itkImageTypeConstPointer);
103 BBTK_DECLARE_INPUT(In,anyImagePointer);
104 BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
108 //=================================================================
110 //=================================================================
111 // BlackBox description
112 BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage,
113 bbtk::AtomicBlackBox);
114 BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To" +
115 bbtk::HumanTypeName<T2>());
116 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
117 BBTK_DESCRIPTION("Converts a generic itk image pointer ("+
118 bbtk::HumanTypeName<anyImagePointer>()+
119 ") into a const typed itk image pointer ("+
120 bbtk::HumanTypeName<T2>()+")");
121 BBTK_CATEGORY("adaptor");
122 BBTK_DEFAULT_ADAPTOR();
123 BBTK_TEMPLATE2_INPUT(AnyImageToConstTypedImage,In,
124 "Input generic image pointer",anyImagePointer);
125 BBTK_TEMPLATE2_OUTPUT(AnyImageToConstTypedImage,Out,
126 "Output const typed image pointer",T2);
127 BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
128 //=================================================================
130 //=================================================================
131 template <class itkImageTypePointer, class itkImageTypeConstPointer>
132 void AnyImageToConstTypedImage<itkImageTypePointer,
133 itkImageTypeConstPointer>::DoIt()
135 if ( bbGetInputIn().type() == typeid(itkImageTypeConstPointer) )
137 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypeConstPointer >() );
139 else if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
141 bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
145 bbtkError(this->bbGetFullName()<<+" : transform of <"
146 <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
147 <<bbtk::TypeName<itkImageTypeConstPointer>()<<"> not implemented");
150 //=================================================================