ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkImageRegionSplitterBase.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 itkImageRegionSplitterBase_h
19 #define itkImageRegionSplitterBase_h
20 
21 #include "itkImageRegion.h"
22 #include "itkObjectFactory.h"
23 #include "itkImageIORegion.h"
24 
25 namespace itk
26 {
27 
58 class ITKCommon_EXPORT ImageRegionSplitterBase
59  :public Object
60 {
61 public:
64  typedef Object Superclass;
67 
69  itkTypeMacro(ImageRegionSplitterBase, Object);
70 
77  template <unsigned int VImageDimension>
78  unsigned int GetNumberOfSplits(const ImageRegion<VImageDimension> & region,
79  unsigned int requestedNumber) const
80  {
81  return this->GetNumberOfSplitsInternal( VImageDimension,
82  region.GetIndex().m_Index,
83  region.GetSize().m_Size,
84  requestedNumber);
85  }
86  inline unsigned int GetNumberOfSplits(const ImageIORegion &region,
87  unsigned int requestedNumber) const
88  {
89  return this->GetNumberOfSplitsInternal( region.GetImageDimension(),
90  &region.GetIndex()[0],
91  &region.GetSize()[0],
92  requestedNumber);
93  }
95 
96 
105  template <unsigned int VImageDimension>
106  unsigned int GetSplit( unsigned int i,
107  unsigned int numberOfPieces,
108  ImageRegion<VImageDimension> & region ) const
109  {
110  return this->GetSplitInternal( VImageDimension,
111  i,
112  numberOfPieces,
113  region.GetModifiableIndex().m_Index,
114  region.GetModifiableSize().m_Size );
115  }
116  unsigned int GetSplit( unsigned int i,
117  unsigned int numberOfPieces,
118  ImageIORegion & region ) const
119  {
120  return this->GetSplitInternal( region.GetImageDimension(),
121  i,
122  numberOfPieces,
123  &region.GetModifiableIndex()[0],
124  &region.GetModifiableSize()[0] );
125  }
126 
127 protected:
129 
132  virtual unsigned int GetNumberOfSplitsInternal( unsigned int dim,
133  const IndexValueType regionIndex[],
134  const SizeValueType regionSize[],
135  unsigned int requestedNumber ) const = 0;
136 
141  virtual unsigned int GetSplitInternal( unsigned int dim,
142  unsigned int i,
143  unsigned int numberOfPieces,
144  IndexValueType regionIndex[],
145  SizeValueType regionSize[] ) const = 0;
146 
147  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
148 
149 private:
150  ImageRegionSplitterBase(const ImageRegionSplitterBase &) ITK_DELETE_FUNCTION;
151  void operator=(const ImageRegionSplitterBase &) ITK_DELETE_FUNCTION;
152 };
153 } // end namespace itk
154 
155 #endif
const IndexType & GetIndex() const
An ImageIORegion represents a structured region of data.
const IndexType & GetIndex() const
signed long IndexValueType
Definition: itkIntTypes.h:150
An image region represents a structured region of data.
unsigned int GetSplit(unsigned int i, unsigned int numberOfPieces, ImageIORegion &region) const
unsigned long SizeValueType
Definition: itkIntTypes.h:143
unsigned int GetImageDimension() const
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
IndexType & GetModifiableIndex()
SizeType & GetModifiableSize()
Divide an image region into several pieces.
const SizeType & GetSize() const
SmartPointer< const Self > ConstPointer
const SizeType & GetSize() const
IndexType & GetModifiableIndex()
SizeType & GetModifiableSize()
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:57
unsigned int GetNumberOfSplits(const ImageIORegion &region, unsigned int requestedNumber) const