ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkSpecialCoordinatesImage.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 __itkSpecialCoordinatesImage_h
19 #define __itkSpecialCoordinatesImage_h
20 
21 #include "itkImageBase.h"
25 #include "itkContinuousIndex.h"
26 
27 namespace itk
28 {
94 template< typename TPixel, unsigned int VImageDimension = 2 >
95 class SpecialCoordinatesImage:public ImageBase< VImageDimension >
96 {
97 public:
104 
106  itkNewMacro(Self);
107 
110 
113  typedef TPixel PixelType;
114 
116  typedef TPixel ValueType;
117 
122  typedef TPixel InternalPixelType;
123 
125 
129 
134 
139  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
140 
143 
146 
148  typedef typename Superclass::SizeType SizeType;
149 
152 
156 
162 
166 
170 
173  virtual void Allocate(bool initialize=false) ITK_OVERRIDE;
174 
177  virtual void Initialize();
178 
181  void FillBuffer(const TPixel & value);
182 
188  void SetPixel(const IndexType & index, const TPixel & value)
189  {
190  OffsetValueType offset = this->ComputeOffset(index);
191  ( *m_Buffer )[offset] = value;
192  }
193 
198  const TPixel & GetPixel(const IndexType & index) const
199  {
200  OffsetValueType offset = this->ComputeOffset(index);
201  return ( ( *m_Buffer )[offset] );
202  }
203 
208  TPixel & GetPixel(const IndexType & index)
209  {
210  OffsetValueType offset = this->ComputeOffset(index);
211  return ( ( *m_Buffer )[offset] );
212  }
213 
218  TPixel & operator[](const IndexType & index) { return this->GetPixel(index); }
219 
224  const TPixel & operator[](const IndexType & index) const { return this->GetPixel(index); }
225 
228  TPixel * GetBufferPointer() { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
229  const TPixel * GetBufferPointer() const { return m_Buffer ? m_Buffer->GetBufferPointer() : ITK_NULLPTR; }
231 
234 
235  const PixelContainer * GetPixelContainer() const { return m_Buffer.GetPointer(); }
236 
239  void SetPixelContainer(PixelContainer *container);
240 
243 
245  const AccessorType GetPixelAccessor(void) const { return AccessorType(); }
246 
252  virtual void SetSpacing(const SpacingType &) {}
253  virtual void SetSpacing(const double[VImageDimension]) {}
254  virtual void SetSpacing(const float[VImageDimension]) {}
255  virtual void SetOrigin(const PointType) {}
256  virtual void SetOrigin(const double[VImageDimension]) {}
257  virtual void SetOrigin(const float[VImageDimension]) {}
259 
260  /* It is ILLEGAL in C++ to make a templated member function virtual! */
261  /* Therefore, we must just let templates take care of everything. */
262  /*
263  template<typename TCoordRep>
264  virtual bool TransformPhysicalPointToContinuousIndex(
265  const Point<TCoordRep, VImageDimension>& point,
266  ContinuousIndex<TCoordRep, VImageDimension>& index ) const = 0;
267 
268  template<typename TCoordRep>
269  virtual bool TransformPhysicalPointToIndex(
270  const Point<TCoordRep, VImageDimension>&,
271  IndexType & index ) const = 0;
272 
273  template<typename TCoordRep>
274  virtual void TransformContinuousIndexToPhysicalPoint(
275  const ContinuousIndex<TCoordRep, VImageDimension>& index,
276  Point<TCoordRep, VImageDimension>& point ) const = 0;
277 
278  template<typename TCoordRep>
279  virtual void TransformIndexToPhysicalPoint(
280  const IndexType & index,
281  Point<TCoordRep, VImageDimension>& point ) const = 0;
282  */
283 
284 protected:
286  void PrintSelf(std::ostream & os, Indent indent) const;
287 
289 
290 private:
291  SpecialCoordinatesImage(const Self &); //purposely not implemented
292  void operator=(const Self &); //purposely not implemented
293 
296 };
297 } // end namespace itk
298 
299 #ifndef ITK_MANUAL_INSTANTIATION
300 #include "itkSpecialCoordinatesImage.hxx"
301 #endif
302 
303 #endif
Index< VImageDimension > IndexType
Definition: itkImageBase.h:134
void operator=(const Self &)
DefaultPixelAccessor< PixelType > AccessorType
TPixel & GetPixel(const IndexType &index)
Get a reference to a pixel (e.g. for editing).
virtual void SetOrigin(const PointType)
Templated n-dimensional nonrectilinear-coordinate image base class.
static const unsigned int ImageDimension
virtual void SetOrigin(const double[VImageDimension])
ObjectType * GetPointer() const
DefaultPixelAccessorFunctor< Self > AccessorFunctorType
Implements a weak reference to an object.
Size< VImageDimension > SizeType
Definition: itkImageBase.h:143
Point< PointValueType, VImageDimension > PointType
Definition: itkImageBase.h:159
virtual void Allocate(bool initialize=false) ITK_OVERRIDE
ImageBase< VImageDimension > Superclass
TPixel & operator[](const IndexType &index)
Access a pixel. This version can be an lvalue.
const TPixel & operator[](const IndexType &index) const
Access a pixel. This version can only be an rvalue.
Offset< VImageDimension > OffsetType
Definition: itkImageBase.h:139
Vector< SpacingValueType, VImageDimension > SpacingType
Definition: itkImageBase.h:154
const TPixel * GetBufferPointer() const
void FillBuffer(const TPixel &value)
void PrintSelf(std::ostream &os, Indent indent) const
virtual void SetOrigin(const float[VImageDimension])
virtual void SetSpacing(const double[VImageDimension])
Provides a common API for pixel accessors for Image and VectorImage.
PixelContainer::ConstPointer PixelContainerConstPointer
OffsetType::OffsetValueType OffsetValueType
Definition: itkImageBase.h:140
virtual void SetSpacing(const float[VImageDimension])
PixelContainer::Pointer PixelContainerPointer
Base class for templated image classes.
Definition: itkImageBase.h:112
const TPixel & GetPixel(const IndexType &index) const
Get a pixel (read only version).
Control indentation during Print() invocation.
Definition: itkIndent.h:49
const PixelContainer * GetPixelContainer() const
OffsetValueType ComputeOffset(const IndexType &ind) const
Definition: itkImageBase.h:332
SmartPointer< const Self > ConstPointer
void SetPixelContainer(PixelContainer *container)
ImageRegion< VImageDimension > RegionType
Definition: itkImageBase.h:147
virtual void SetSpacing(const SpacingType &)
Give access to partial aspects a type.
WeakPointer< const Self > ConstWeakPointer
Base class for all data objects in ITK.
void SetPixel(const IndexType &index, const TPixel &value)
Set a pixel value.
const AccessorType GetPixelAccessor(void) const
Defines an itk::Image front-end to a standard C-array.
ImportImageContainer< SizeValueType, PixelType > PixelContainer