1 /*=========================================================================
3 Module: $RCSfile: bbitkImageRegion.cxx,v $
5 Date: $Date: 2009/05/15 14:57:58 $
6 Version: $Revision: 1.5 $
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 #include "bbitkImageRegion.h"
35 #include "bbitkPackage.h"
40 BBTK_BLACK_BOX_IMPLEMENTATION(ImageRegionCreator,
41 bbtk::AtomicBlackBox);
43 BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageRegionCreator);
46 void ImageRegionCreator::bbUserSetDefaultValues() { }
47 void ImageRegionCreator::bbUserInitializeProcessing() { }
48 void ImageRegionCreator::bbUserFinalizeProcessing() { }
50 template <unsigned int Dimension>
51 void ImageRegionCreator::bbUserSetDefaultValues() { }
53 template <unsigned int Dimension>
54 void ImageRegionCreator::bbUserInitializeProcessing() { }
56 template <unsigned int Dimension>
57 void ImageRegionCreator::bbUserFinalizeProcessing() { }
60 void ImageRegionCreator::DoIt()
62 const std::vector<long>& index = bbGetInputIndex();
63 const std::vector<long>& size = bbGetInputSize();
64 // std::cout<< "isize="<<index.size()<<std::endl;
65 // std::cout<< "ssize="<<size.size()<<std::endl;
66 unsigned long maxs = index.size() > size.size() ? index.size() : size.size();
69 case 2 : DoIt<2>(); break;
70 case 3 : DoIt<3>(); break;
71 case 4 : DoIt<4>(); break;
72 default : bbtkError("ImageRegionCreator : cannot build a region of dimension "<<maxs);
78 template <unsigned int Dimension>
79 void ImageRegionCreator::DoIt()
81 std::vector<long> index = bbGetInputIndex();
82 std::vector<long> size = bbGetInputSize();
83 // std::cout<< "isize="<<index.size()<<std::endl;
84 // std::cout<< "ssize="<<size.size()<<std::endl;
86 int ds = index.size() - size.size();
89 for (int i=0;i<-ds;++i)
94 for (int i=0;i<ds;++i) size.push_back(0);
97 typename itk::ImageRegion<Dimension>::IndexType I;
98 typename itk::ImageRegion<Dimension>::SizeType S;
100 std::vector<long>::const_iterator ii,si;
102 for (ii=index.begin(), si=size.begin();
103 ii!=index.end(); ++ii, ++si, ++d)
107 // std::cout << "o="<<*ii<<" d="<<*si<<std::endl;
111 bbSetOutputOut ( itk::ImageRegion<Dimension>(I,S) );