1 /*=========================================================================
3 Module: $RCSfile: bbitkImageRegion.cxx,v $
5 Date: $Date: 2009/05/18 10:45:44 $
6 Version: $Revision: 1.6 $
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()
48 void ImageRegionCreator::bbUserInitializeProcessing()
50 void ImageRegionCreator::bbUserFinalizeProcessing()
54 void ImageRegionCreator::DoIt()
56 const std::vector<long>& index = bbGetInputIndex();
57 const std::vector<long>& size = bbGetInputSize();
58 // std::cout<< "isize="<<index.size()<<std::endl;
59 // std::cout<< "ssize="<<size.size()<<std::endl;
60 unsigned long maxs = index.size() > size.size() ? index.size() : size.size();
63 case 2 : DoItForDimension<2>(); break;
64 case 3 : DoItForDimension<3>(); break;
65 case 4 : DoItForDimension<4>(); break;
66 default : bbtkError("ImageRegionCreator : cannot build a region of dimension "<<maxs);
72 template <unsigned int Dimension>
73 void ImageRegionCreator::DoItForDimension()
75 std::vector<long> index = bbGetInputIndex();
76 std::vector<long> size = bbGetInputSize();
77 // std::cout<< "isize="<<index.size()<<std::endl;
78 // std::cout<< "ssize="<<size.size()<<std::endl;
80 int ds = index.size() - size.size();
83 for (int i=0;i<-ds;++i)
88 for (int i=0;i<ds;++i) size.push_back(0);
91 typename itk::ImageRegion<Dimension>::IndexType I;
92 typename itk::ImageRegion<Dimension>::SizeType S;
94 std::vector<long>::const_iterator ii,si;
96 for (ii=index.begin(), si=size.begin();
97 ii!=index.end(); ++ii, ++si, ++d)
101 // std::cout << "o="<<*ii<<" d="<<*si<<std::endl;
105 bbSetOutputOut ( itk::ImageRegion<Dimension>(I,S) );