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 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbitkImageRegion.h,v $
32 Date: $Date: 2012/11/16 08:50:39 $
33 Version: $Revision: 1.8 $
34 =========================================================================*/
41 #ifndef __bbitkImageRegion_h_INCLUDED__
42 #define __bbitkImageRegion_h_INCLUDED__
44 #include "itkImageRegion.h"
45 #include "bbtkMessageManager.h"
47 #include "bbtkAtomicBlackBox.h"
51 //=======================================================================
52 /// Type traits ImageRegion to define bbtk::any<ImageRegion>
53 template <typename T> struct ImageRegion { static const bool value = false; };
54 // Specialisations for instantiated image types
55 #ifdef BBTK_ITK_IMAGE_DIM_2
56 typedef itk::ImageRegion<2> ImageRegion_2;
57 template <> struct ImageRegion<ImageRegion_2> { static const bool value = true; };
59 #ifdef BBTK_ITK_IMAGE_DIM_3
60 typedef itk::ImageRegion<3> ImageRegion_3;
61 template <> struct ImageRegion<ImageRegion_3> { static const bool value = true; };
63 #ifdef BBTK_ITK_IMAGE_DIM_4
64 typedef itk::ImageRegion<4> ImageRegion_4;
65 template <> struct ImageRegion<ImageRegion_4> { static const bool value = true; };
69 typedef bbtk::any<ImageRegion> anyImageRegion;
74 /// Human readable name for bbtk::any<bbitk::ImageRegion>
75 BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImageRegion,"anyItkImageRegion");
82 //=======================================================================
83 /// Black Box which creates an anyImageRegion
84 class /*BBTK_EXPORT*/ ImageRegionCreator
85 : public bbtk::AtomicBlackBox
87 BBTK_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
88 BBTK_DECLARE_INPUT(Index,std::vector<long>);
89 BBTK_DECLARE_INPUT(Size,std::vector<long>);
90 BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
94 template <unsigned int Dimension> void DoItForDimension();
98 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageRegionCreator,bbtk::AtomicBlackBox);
99 BBTK_NAME("ImageRegion");
100 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
101 BBTK_DESCRIPTION("Creates a generic ImageRegion ("+bbtk::TypeName<anyImageRegion>()+") from two vectors providing the index and size of the region. The dimension D of the actual itk::ImageRegion<D> created is the max of the sizes of Index and Size (the smallest vector is padded by zeros).");
102 BBTK_CATEGORY("image");
103 typedef std::vector<long> vectoroflong;
104 BBTK_INPUT(ImageRegionCreator,Index,"Vector of region indices",
105 vectoroflong,"image index");
106 BBTK_INPUT(ImageRegionCreator,Size,"Vector of region sizes",
107 vectoroflong,"image size");
108 BBTK_OUTPUT(ImageRegionCreator,Out,"Output generic region",anyImageRegion,"");
109 BBTK_END_DESCRIBE_BLACK_BOX(ImageRegionCreator);