ITK  5.0.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:
62  ITK_DISALLOW_COPY_AND_ASSIGN(ImageRegionSplitterBase);
63 
66  using Superclass = Object;
69 
71  itkTypeMacro(ImageRegionSplitterBase, Object);
72 
79  template <unsigned int VImageDimension>
80  unsigned int GetNumberOfSplits(const ImageRegion<VImageDimension> & region,
81  unsigned int requestedNumber) const
82  {
83  return this->GetNumberOfSplitsInternal( VImageDimension,
84  region.GetIndex().m_InternalArray,
85  region.GetSize().m_InternalArray,
86  requestedNumber);
87  }
88  inline unsigned int GetNumberOfSplits(const ImageIORegion &region,
89  unsigned int requestedNumber) const
90  {
91  return this->GetNumberOfSplitsInternal( region.GetImageDimension(),
92  &region.GetIndex()[0],
93  &region.GetSize()[0],
94  requestedNumber);
95  }
97 
98 
107  template <unsigned int VImageDimension>
108  unsigned int GetSplit( unsigned int i,
109  unsigned int numberOfPieces,
110  ImageRegion<VImageDimension> & region ) const
111  {
112  return this->GetSplitInternal( VImageDimension,
113  i,
114  numberOfPieces,
115  region.GetModifiableIndex().m_InternalArray,
116  region.GetModifiableSize().m_InternalArray );
117  }
118  unsigned int GetSplit( unsigned int i,
119  unsigned int numberOfPieces,
120  ImageIORegion & region ) const
121  {
122  return this->GetSplitInternal( region.GetImageDimension(),
123  i,
124  numberOfPieces,
125  &region.GetModifiableIndex()[0],
126  &region.GetModifiableSize()[0] );
127  }
128 
129 protected:
131 
134  virtual unsigned int GetNumberOfSplitsInternal( unsigned int dim,
135  const IndexValueType regionIndex[],
136  const SizeValueType regionSize[],
137  unsigned int requestedNumber ) const = 0;
138 
143  virtual unsigned int GetSplitInternal( unsigned int dim,
144  unsigned int i,
145  unsigned int numberOfPieces,
146  IndexValueType regionIndex[],
147  SizeValueType regionSize[] ) const = 0;
148 
149  void PrintSelf(std::ostream & os, Indent indent) const override;
150 };
151 } // end namespace itk
152 
153 #endif
const IndexType & GetIndex() const
An ImageIORegion represents a structured region of data.
const IndexType & GetIndex() const
unsigned long SizeValueType
Definition: itkIntTypes.h:83
An image region represents a structured region of data.
unsigned int GetSplit(unsigned int i, unsigned int numberOfPieces, ImageIORegion &region) const
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()
signed long IndexValueType
Definition: itkIntTypes.h:90
Divide an image region into several pieces.
const SizeType & GetSize() const
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:60
unsigned int GetNumberOfSplits(const ImageIORegion &region, unsigned int requestedNumber) const