1 /*=========================================================================
3 Module: $RCSfile: bbitkImageRegion.h,v $
5 Date: $Date: 2009/05/18 10:45:44 $
6 Version: $Revision: 1.7 $
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 __bbitkImageRegion_h_INCLUDED__
35 #define __bbitkImageRegion_h_INCLUDED__
37 #include "itkImageRegion.h"
38 #include "bbtkMessageManager.h"
40 #include "bbtkAtomicBlackBox.h"
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; };
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; };
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; };
62 typedef bbtk::any<ImageRegion> anyImageRegion;
67 /// Human readable name for bbtk::any<bbitk::ImageRegion>
68 BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImageRegion,"anyItkImageRegion");
75 //=======================================================================
76 /// Black Box which creates an anyImageRegion
77 class /*BBTK_EXPORT*/ ImageRegionCreator
78 : public bbtk::AtomicBlackBox
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);
87 template <unsigned int Dimension> void DoItForDimension();
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);