]> Creatis software - bbtk.git/blob - packages/itk/src/bbitkImageRegion.h
92473d5979dde8475be6af47686c2b675d324ce9
[bbtk.git] / packages / itk / src / bbitkImageRegion.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbitkImageRegion.h,v $
4   Language:  C++
5   Date:      $Date: 2009/05/18 10:45:44 $
6   Version:   $Revision: 1.7 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31
32 #ifdef _USE_ITK_
33
34 #ifndef __bbitkImageRegion_h_INCLUDED__
35 #define __bbitkImageRegion_h_INCLUDED__
36
37 #include "itkImageRegion.h"
38 #include "bbtkMessageManager.h"
39 #include "bbtkAny.h"
40 #include "bbtkAtomicBlackBox.h"
41
42 namespace bbitk
43 {
44   //=======================================================================
45   /// Type traits ImageRegion to define bbtk::any<ImageRegion>
46   template <typename T> struct ImageRegion { static const bool value = false; };
47   // Specialisations for instantiated image types
48 #ifdef BBTK_ITK_IMAGE_DIM_2
49   typedef itk::ImageRegion<2> ImageRegion_2;
50   template <> struct ImageRegion<ImageRegion_2> { static const bool value = true; };
51 #endif
52 #ifdef BBTK_ITK_IMAGE_DIM_3
53   typedef itk::ImageRegion<3> ImageRegion_3;
54   template <> struct ImageRegion<ImageRegion_3> { static const bool value = true; };
55 #endif
56 #ifdef BBTK_ITK_IMAGE_DIM_4
57   typedef itk::ImageRegion<4> ImageRegion_4;
58   template <> struct ImageRegion<ImageRegion_4> { static const bool value = true; };
59 #endif
60
61   /// 
62   typedef bbtk::any<ImageRegion> anyImageRegion;
63 } // namespace bbitk
64  
65 namespace bbtk
66 {
67   /// Human readable name for bbtk::any<bbitk::ImageRegion>
68   BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImageRegion,"anyItkImageRegion");
69 } // namespace bbtk
70
71
72
73 namespace bbitk
74 {
75   //=======================================================================
76   /// Black Box which creates an anyImageRegion
77   class /*BBTK_EXPORT*/ ImageRegionCreator
78     : public bbtk::AtomicBlackBox
79   {
80     BBTK_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
81     BBTK_DECLARE_INPUT(Index,std::vector<long>);
82     BBTK_DECLARE_INPUT(Size,std::vector<long>);
83     BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
84     BBTK_PROCESS(DoIt);
85   private:
86     void DoIt();
87     template <unsigned int Dimension> void DoItForDimension();
88  };
89
90
91   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageRegionCreator,bbtk::AtomicBlackBox);
92   BBTK_NAME("ImageRegion");
93   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
94   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).");
95   BBTK_CATEGORY("image");
96         typedef std::vector<long> vectoroflong;
97   BBTK_INPUT(ImageRegionCreator,Index,"Vector of region indices",
98              vectoroflong,"image index");
99   BBTK_INPUT(ImageRegionCreator,Size,"Vector of region sizes",
100              vectoroflong,"image size");
101   BBTK_OUTPUT(ImageRegionCreator,Out,"Output generic region",anyImageRegion,"");
102   BBTK_END_DESCRIBE_BLACK_BOX(ImageRegionCreator);
103   
104 } // namespace bbitk
105
106
107 #endif
108 #endif