ITK  4.5.0
Insight Segmentation and Registration Toolkit
itkImageRegionSplitter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkImageRegionSplitter_h
19 #define __itkImageRegionSplitter_h
20 
21 #include "itkImageRegion.h"
23 
24 namespace itk
25 {
68 template< unsigned int VImageDimension >
70 {
71 public:
77 
79  itkNewMacro(Self);
80 
82  itkTypeMacro(ImageRegionSplitter, Object);
83 
85  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
86 
88  static unsigned int GetImageDimension()
89  { return VImageDimension; }
90 
93 
97 
100 
107  virtual unsigned int GetNumberOfSplits(const RegionType & region,
108  unsigned int requestedNumber);
109 
110 
114  virtual RegionType GetSplit(unsigned int i, unsigned int numberOfPieces,
115  const RegionType & region);
116 
117 protected:
120 
121  virtual unsigned int GetNumberOfSplitsInternal(unsigned int,
122  const IndexValueType regionIndex[],
123  const SizeValueType regionSize[],
124  unsigned int requestedNumber) const
125  {
126  // this function adapts the legecy method, defined in this class
127  // be used by the ImageRegionSplitterBase.
128  IndexType idx;
129  idx.SetIndex( regionIndex );
130  SizeType sz;
131  sz.SetSize( regionSize );
132  RegionType region = RegionType(idx, sz);
133 
134  Self *nonconst_this = const_cast<Self*>(this);
135  return nonconst_this->GetNumberOfSplits(region, requestedNumber);
136 
137  }
138 
139  virtual unsigned int GetSplitInternal(unsigned int dim,
140  unsigned int i,
141  unsigned int numberOfPieces,
142  IndexValueType regionIndex[],
143  SizeValueType regionSize[]) const
144  {
145  // this function adapts the legecy method, defined in this class
146  // be used by the ImageRegionSplitterBase.
147  IndexType idx;
148  idx.SetIndex( regionIndex );
149  SizeType sz;
150  sz.SetSize( regionSize );
151  RegionType region = RegionType(idx, sz);
152 
153  Self *nonconst_this = const_cast<Self*>(this);
154  region = nonconst_this->GetSplit(i, numberOfPieces, region);
155 
156  for (unsigned int d = 0; d < dim; ++d)
157  {
158  regionIndex[d] = region.GetIndex(d);
159  regionSize[d] = region.GetSize(d);
160  }
161  return numberOfPieces;
162  }
163 
164  void PrintSelf(std::ostream & os, Indent indent) const;
165 
166 private:
167  ImageRegionSplitter(const ImageRegionSplitter &); //purposely not implemented
168  void operator=(const ImageRegionSplitter &); //purposely not implemented
169 };
170 } // end namespace itk
171 
172 #ifndef ITK_MANUAL_INSTANTIATION
173 #include "itkImageRegionSplitter.hxx"
174 #endif
175 
176 #endif
ImageRegionSplitterBase Superclass
SmartPointer< Self > Pointer
const IndexType & GetIndex() const
itk::SizeValueType SizeValueType
Definition: itkSize.h:60
Divide a region into several pieces.
Represent the size (bounds) of a n-dimensional image.
Definition: itkSize.h:52
signed long IndexValueType
Definition: itkIntTypes.h:150
SizeType::SizeValueType SizeValueType
An image region represents a structured region of data.
Size< VImageDimension > SizeType
virtual unsigned int GetSplitInternal(unsigned int dim, unsigned int i, unsigned int numberOfPieces, IndexValueType regionIndex[], SizeValueType regionSize[]) const
static const unsigned int ImageDimension
virtual RegionType GetSplit(unsigned int i, unsigned int numberOfPieces, const RegionType &region)
SmartPointer< const Self > ConstPointer
void SetSize(const SizeValueType val[VDimension])
Definition: itkSize.h:171
Index< VImageDimension > IndexType
unsigned int GetSplit(unsigned int i, unsigned int numberOfPieces, ImageRegion< VImageDimension > &region) const
Get a region definition that represents the ith piece a specified region.
void PrintSelf(std::ostream &os, Indent indent) const
unsigned int GetNumberOfSplits(const ImageRegion< VImageDimension > &region, unsigned int requestedNumber) const
Divide an image region into several pieces.
const SizeType & GetSize() const
ImageRegion< VImageDimension > RegionType
virtual unsigned int GetNumberOfSplits(const RegionType &region, unsigned int requestedNumber)
void operator=(const ImageRegionSplitter &)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:57
void SetIndex(const IndexValueType val[VIndexDimension])
Definition: itkIndex.h:246
virtual unsigned int GetNumberOfSplitsInternal(unsigned int, const IndexValueType regionIndex[], const SizeValueType regionSize[], unsigned int requestedNumber) const
static unsigned int GetImageDimension()