ITK  4.9.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 {
67 template< unsigned int VImageDimension >
69 {
70 public:
76 
78  itkNewMacro(Self);
79 
81  itkTypeMacro(ImageRegionSplitter, Object);
82 
84  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
85 
87  static unsigned int GetImageDimension()
88  { return VImageDimension; }
89 
92 
96 
99 
106  virtual unsigned int GetNumberOfSplits(const RegionType & region,
107  unsigned int requestedNumber);
108 
109 
113  virtual RegionType GetSplit(unsigned int i, unsigned int numberOfPieces,
114  const RegionType & region);
115 
116 protected:
119 
120  virtual unsigned int GetNumberOfSplitsInternal(unsigned int,
121  const IndexValueType regionIndex[],
122  const SizeValueType regionSize[],
123  unsigned int requestedNumber) const ITK_OVERRIDE
124  {
125  // this function adapts the legecy method, defined in this class
126  // be used by the ImageRegionSplitterBase.
127  IndexType idx;
128  idx.SetIndex( regionIndex );
129  SizeType sz;
130  sz.SetSize( regionSize );
131  RegionType region = RegionType(idx, sz);
132 
133  Self *nonconst_this = const_cast<Self*>(this);
134  return nonconst_this->GetNumberOfSplits(region, requestedNumber);
135 
136  }
137 
138  virtual unsigned int GetSplitInternal(unsigned int dim,
139  unsigned int i,
140  unsigned int numberOfPieces,
141  IndexValueType regionIndex[],
142  SizeValueType regionSize[]) const ITK_OVERRIDE
143  {
144  // this function adapts the legecy method, defined in this class
145  // be used by the ImageRegionSplitterBase.
146  IndexType idx;
147  idx.SetIndex( regionIndex );
148  SizeType sz;
149  sz.SetSize( regionSize );
150  RegionType region = RegionType(idx, sz);
151 
152  Self *nonconst_this = const_cast<Self*>(this);
153  region = nonconst_this->GetSplit(i, numberOfPieces, region);
154 
155  for (unsigned int d = 0; d < dim; ++d)
156  {
157  regionIndex[d] = region.GetIndex(d);
158  regionSize[d] = region.GetSize(d);
159  }
160  return numberOfPieces;
161  }
162 
163  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
164 
165 private:
166  ImageRegionSplitter(const ImageRegionSplitter &) ITK_DELETE_FUNCTION;
167  void operator=(const ImageRegionSplitter &) ITK_DELETE_FUNCTION;
168 };
169 } // end namespace itk
170 
171 #ifndef ITK_MANUAL_INSTANTIATION
172 #include "itkImageRegionSplitter.hxx"
173 #endif
174 
175 #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
virtual void PrintSelf(std::ostream &os, Indent indent) const override
signed long IndexValueType
Definition: itkIntTypes.h:150
SizeType::SizeValueType SizeValueType
An image region represents a structured region of data.
Size< VImageDimension > SizeType
static const unsigned int ImageDimension
virtual unsigned int GetNumberOfSplitsInternal(unsigned int, const IndexValueType regionIndex[], const SizeValueType regionSize[], unsigned int requestedNumber) const override
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.
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)
virtual unsigned int GetSplitInternal(unsigned int dim, unsigned int i, unsigned int numberOfPieces, IndexValueType regionIndex[], SizeValueType regionSize[]) const override
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:260
static unsigned int GetImageDimension()