ITK  4.4.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< class TPixel, unsigned int VImageDimension = 2 >
95 class ITK_EXPORT 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 
142  typedef typename Superclass::IndexType IndexType;
143 
145  typedef typename Superclass::OffsetType OffsetType;
146 
148  typedef typename Superclass::SizeType SizeType;
149 
152 
155  typedef typename Superclass::RegionType RegionType;
156 
161  typedef typename Superclass::SpacingType SpacingType;
162 
165  typedef typename Superclass::PointType PointType;
166 
170 
173  void Allocate();
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() : 0; }
231 
233  PixelContainer * GetPixelContainer() { return m_Buffer.GetPointer(); }
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<class TCoordRep>
264  virtual bool TransformPhysicalPointToContinuousIndex(
265  const Point<TCoordRep, VImageDimension>& point,
266  ContinuousIndex<TCoordRep, VImageDimension>& index ) const = 0;
267 
268  template<class TCoordRep>
269  virtual bool TransformPhysicalPointToIndex(
270  const Point<TCoordRep, VImageDimension>&,
271  IndexType & index ) const = 0;
272 
273  template<class TCoordRep>
274  virtual void TransformContinuousIndexToPhysicalPoint(
275  const ContinuousIndex<TCoordRep, VImageDimension>& index,
276  Point<TCoordRep, VImageDimension>& point ) const = 0;
277 
278  template<class 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
304