]> Creatis software - bbtk.git/blob - packages/itk/src/bbitkImageRegion.h
3e0746403b1ab1b00ab9167ed89f230dae170c9d
[bbtk.git] / packages / itk / src / bbitkImageRegion.h
1 #ifdef _USE_ITK_
2
3 #ifndef __bbitkImageRegion_h_INCLUDED__
4 #define __bbitkImageRegion_h_INCLUDED__
5
6 #include "itkImageRegion.h"
7 #include "bbtkMessageManager.h"
8 #include "bbtkAny.h"
9 #include "bbtkAtomicBlackBox.h"
10
11 namespace bbitk
12 {
13   //=======================================================================
14   /// Type traits ImageRegion to define bbtk::any<ImageRegion>
15   template <typename T> struct ImageRegion { static const bool value = false; };
16   // Specialisations for instantiated image types
17 #ifdef BBTK_ITK_IMAGE_DIM_2
18   typedef itk::ImageRegion<2> ImageRegion_2;
19   template <> struct ImageRegion<ImageRegion_2> { static const bool value = true; };
20 #endif
21 #ifdef BBTK_ITK_IMAGE_DIM_3
22   typedef itk::ImageRegion<3> ImageRegion_3;
23   template <> struct ImageRegion<ImageRegion_3> { static const bool value = true; };
24 #endif
25 #ifdef BBTK_ITK_IMAGE_DIM_4
26   typedef itk::ImageRegion<4> ImageRegion_4;
27   template <> struct ImageRegion<ImageRegion_4> { static const bool value = true; };
28 #endif
29
30   /// 
31   typedef bbtk::any<ImageRegion> anyImageRegion;
32 } // namespace bbitk
33  
34 namespace bbtk
35 {
36   /// Human readable name for bbtk::any<bbitk::ImageRegion>
37   BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImageRegion,"anyItkImageRegion");
38 } // namespace bbtk
39
40
41
42 namespace bbitk
43 {
44   //=======================================================================
45   /// Black Box which creates an anyImageRegion
46   class /*BBTK_EXPORT*/ ImageRegionCreator
47     : public bbtk::AtomicBlackBox
48   {
49     BBTK_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
50     BBTK_DECLARE_INPUT(Index,std::vector<long>);
51     BBTK_DECLARE_INPUT(Size,std::vector<long>);
52     BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
53     BBTK_PROCESS(DoIt);
54   private:
55     void DoIt();
56     template <unsigned int Dimension> void DoIt();
57  };
58
59
60   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageRegionCreator,bbtk::AtomicBlackBox);
61   BBTK_NAME("ImageRegion");
62   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
63   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).");
64   BBTK_CATEGORY("image");
65         typedef std::vector<long> vectoroflong;
66   BBTK_INPUT(ImageRegionCreator,Index,"Vector of region indices",
67              vectoroflong,"image index");
68   BBTK_INPUT(ImageRegionCreator,Size,"Vector of region sizes",
69              vectoroflong,"image size");
70   BBTK_OUTPUT(ImageRegionCreator,Out,"Output generic region",anyImageRegion,"");
71   BBTK_END_DESCRIBE_BLACK_BOX(ImageRegionCreator);
72   
73 } // namespace bbitk
74
75
76 #endif
77 #endif