ITK  5.2.0
Insight Toolkit
itkImageRegionSplitterBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 : public Object
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_ASSIGN(ImageRegionSplitterBase);
62 
65  using Superclass = Object;
68 
70  itkTypeMacro(ImageRegionSplitterBase, Object);
71 
78  template <unsigned int VImageDimension>
79  unsigned int
80  GetNumberOfSplits(const ImageRegion<VImageDimension> & region, unsigned int requestedNumber) const
81  {
82  return this->GetNumberOfSplitsInternal(
83  VImageDimension, region.GetIndex().m_InternalArray, region.GetSize().m_InternalArray, requestedNumber);
84  }
85  inline unsigned int
86  GetNumberOfSplits(const ImageIORegion & region, unsigned int requestedNumber) const
87  {
88  return this->GetNumberOfSplitsInternal(
89  region.GetImageDimension(), &region.GetIndex()[0], &region.GetSize()[0], requestedNumber);
90  }
92 
93 
102  template <unsigned int VImageDimension>
103  unsigned int
104  GetSplit(unsigned int i, unsigned int numberOfPieces, ImageRegion<VImageDimension> & region) const
105  {
106  return this->GetSplitInternal(VImageDimension,
107  i,
108  numberOfPieces,
109  region.GetModifiableIndex().m_InternalArray,
110  region.GetModifiableSize().m_InternalArray);
111  }
112  unsigned int
113  GetSplit(unsigned int i, unsigned int numberOfPieces, ImageIORegion & region) const
114  {
115  return this->GetSplitInternal(
116  region.GetImageDimension(), i, numberOfPieces, &region.GetModifiableIndex()[0], &region.GetModifiableSize()[0]);
117  }
118 
119 protected:
121 
124  virtual unsigned int
125  GetNumberOfSplitsInternal(unsigned int dim,
126  const IndexValueType regionIndex[],
127  const SizeValueType regionSize[],
128  unsigned int requestedNumber) const = 0;
129 
134  virtual unsigned int
135  GetSplitInternal(unsigned int dim,
136  unsigned int i,
137  unsigned int numberOfPieces,
138  IndexValueType regionIndex[],
139  SizeValueType regionSize[]) const = 0;
140 
141  void
142  PrintSelf(std::ostream & os, Indent indent) const override;
143 };
144 } // end namespace itk
145 
146 #endif
itk::ImageRegion::GetModifiableIndex
IndexType & GetModifiableIndex()
Definition: itkImageRegion.h:165
itkObjectFactory.h
itk::ImageIORegion::GetModifiableSize
SizeType & GetModifiableSize()
itk::ImageRegion::GetIndex
const IndexType & GetIndex() const
Definition: itkImageRegion.h:160
itk::ImageRegion
An image region represents a structured region of data.
Definition: itkImageRegion.h:69
itk::ImageRegionSplitterBase::GetNumberOfSplits
unsigned int GetNumberOfSplits(const ImageIORegion &region, unsigned int requestedNumber) const
Definition: itkImageRegionSplitterBase.h:86
itk::ImageRegion::GetSize
const SizeType & GetSize() const
Definition: itkImageRegion.h:181
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageIORegion
An ImageIORegion represents a structured region of data.
Definition: itkImageIORegion.h:52
itkImageRegion.h
itk::ImageRegionSplitterBase::GetNumberOfSplits
unsigned int GetNumberOfSplits(const ImageRegion< VImageDimension > &region, unsigned int requestedNumber) const
Definition: itkImageRegionSplitterBase.h:80
itk::ImageRegionSplitterBase::GetSplit
unsigned int GetSplit(unsigned int i, unsigned int numberOfPieces, ImageIORegion &region) const
Definition: itkImageRegionSplitterBase.h:113
itk::ImageIORegion::GetModifiableIndex
IndexType & GetModifiableIndex()
itk::ImageIORegion::GetIndex
const IndexType & GetIndex() const
itk::ImageRegionSplitterBase
Divide an image region into several pieces.
Definition: itkImageRegionSplitterBase.h:58
itk::ImageIORegion::GetImageDimension
unsigned int GetImageDimension() const
itk::ImageIORegion::GetSize
const SizeType & GetSize() const
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itkImageIORegion.h
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::ImageRegion::GetModifiableSize
SizeType & GetModifiableSize()
Definition: itkImageRegion.h:186
itk::ImageRegionSplitterBase::GetSplit
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.
Definition: itkImageRegionSplitterBase.h:104
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83