go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGPUImage.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
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 /*=========================================================================
19 *
20 * Copyright Insight Software Consortium
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0.txt
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
34 *=========================================================================*/
35 #ifndef __itkGPUImage_h
36 #define __itkGPUImage_h
37 
38 #include "itkImage.h"
39 #include "itkGPUImageDataManager.h"
40 #include "itkVersion.h"
41 #include "itkObjectFactoryBase.h"
42 
43 namespace itk
44 {
62 template< typename TPixel, unsigned int VImageDimension = 2 >
63 class ITKOpenCL_EXPORT GPUImage : public Image< TPixel, VImageDimension >
64 {
65 public:
66 
67  typedef GPUImage Self;
70  typedef SmartPointer< const Self > ConstPointer;
71  typedef WeakPointer< const Self > ConstWeakPointer;
72 
73  itkNewMacro( Self );
74 
75  itkTypeMacro( GPUImage, Image );
76 
77  itkStaticConstMacro( ImageDimension, unsigned int, VImageDimension );
78 
79  typedef typename Superclass::PixelType PixelType;
80  typedef typename Superclass::ValueType ValueType;
81  typedef typename Superclass::InternalPixelType InternalPixelType;
82  typedef typename Superclass::IOPixelType IOPixelType;
83  typedef typename Superclass::DirectionType DirectionType;
84  typedef typename Superclass::SpacingType SpacingType;
85  typedef typename Superclass::PixelContainer PixelContainer;
86  typedef typename Superclass::SizeType SizeType;
87  typedef typename Superclass::IndexType IndexType;
88  typedef typename Superclass::OffsetType OffsetType;
89  typedef typename Superclass::RegionType RegionType;
90  typedef typename PixelContainer::Pointer PixelContainerPointer;
91  typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
92  typedef typename Superclass::AccessorType AccessorType;
93 
94  typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
95 
96  typedef NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType;
97 
99  virtual void Allocate( bool initialize = false ) ITK_OVERRIDE;
100 
101  void AllocateGPU( void );
102 
103  virtual void Initialize( void );
104 
105  void FillBuffer( const TPixel & value );
106 
107  void SetPixel( const IndexType & index, const TPixel & value );
108 
109  const TPixel & GetPixel( const IndexType & index ) const;
110 
111  TPixel & GetPixel( const IndexType & index );
112 
113  const TPixel & operator[]( const IndexType & index ) const;
114 
115  TPixel & operator[]( const IndexType & index );
116 
118  void UpdateBuffers( void );
119 
121  void UpdateCPUBuffer( void );
122 
123  void UpdateGPUBuffer( void );
124 
126  TPixel * GetBufferPointer( void );
127 
128  const TPixel * GetBufferPointer( void ) const;
129 
131  AccessorType GetPixelAccessor( void )
132  {
133  m_DataManager->SetGPUBufferDirty();
134  return Superclass::GetPixelAccessor();
135  }
136 
137 
139  const AccessorType GetPixelAccessor( void ) const
140  {
141  m_DataManager->UpdateCPUBuffer();
142  return Superclass::GetPixelAccessor();
143  }
144 
145 
147  NeighborhoodAccessorFunctorType GetNeighborhoodAccessor( void )
148  {
149  m_DataManager->SetGPUBufferDirty();
150  return NeighborhoodAccessorFunctorType();
151  }
152 
153 
155  const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor( void ) const
156  {
157  m_DataManager->UpdateCPUBuffer();
158  return NeighborhoodAccessorFunctorType();
159  }
160 
161 
162  void SetPixelContainer( PixelContainer * container );
163 
165  PixelContainer * GetPixelContainer( void )
166  {
167  m_DataManager->SetGPUBufferDirty(); return Superclass::GetPixelContainer();
168  }
169 
170 
171  const PixelContainer * GetPixelContainer( void ) const
172  {
173  m_DataManager->UpdateCPUBuffer();
174  return Superclass::GetPixelContainer();
175  }
176 
177 
178  void SetCurrentCommandQueue( int queueid )
179  {
180  m_DataManager->SetCurrentCommandQueue( queueid );
181  }
182 
183 
185  {
186  return m_DataManager->GetCurrentCommandQueueId();
187  }
188 
189 
190  GPUDataManager::Pointer GetGPUDataManager( void ) const;
191 
199  void DataHasBeenGenerated( void )
200  {
201  Superclass::DataHasBeenGenerated();
202 
203  if( m_DataManager->IsCPUBufferDirty() )
204  {
205  m_DataManager->Modified();
206  }
207 
208  }
209 
210 
212  virtual void Graft( const DataObject * data );
213 
214  void GraftITKImage( const DataObject * data );
215 
217  virtual void Modified( void ) const;
218 
221  itkGetConstReferenceMacro( IndexToPhysicalPoint, DirectionType );
222  itkGetConstReferenceMacro( PhysicalPointToIndex, DirectionType );
223 
224 protected:
225 
226  GPUImage();
227  virtual ~GPUImage() {}
228 
229  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
230 
231 private:
232 
233  GPUImage( const Self & ); // purposely not implemented
234  void operator=( const Self & ); // purposely not implemented
235 
236  bool m_Graft;
237 
239 };
240 
241 //------------------------------------------------------------------------------
242 template< typename T >
244 {
245 public:
246 
247  typedef T Type;
248 };
249 
250 template< typename TPixelType, unsigned int NDimension >
251 class GPUTraits< Image< TPixelType, NDimension > >
252 {
253 public:
254 
256 };
257 
258 } // end namespace itk
259 
260 #ifndef ITK_MANUAL_INSTANTIATION
261 #include "itkGPUImage.hxx"
262 #endif
263 
264 #endif
PixelContainer::ConstPointer PixelContainerConstPointer
Definition: itkGPUImage.h:91
Superclass::IOPixelType IOPixelType
Definition: itkGPUImage.h:82
DefaultPixelAccessorFunctor< Self > AccessorFunctorType
Definition: itkGPUImage.h:94
GPUImage Self
Definition: itkGPUImage.h:67
void SetCurrentCommandQueue(int queueid)
Definition: itkGPUImage.h:178
NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
Definition: itkGPUImage.h:96
virtual ~GPUImage()
Definition: itkGPUImage.h:227
void DataHasBeenGenerated(void)
Definition: itkGPUImage.h:199
Superclass::InternalPixelType InternalPixelType
Definition: itkGPUImage.h:81
Superclass::PixelType PixelType
Definition: itkGPUImage.h:79
Superclass::DirectionType DirectionType
Definition: itkGPUImage.h:83
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:63
WeakPointer< const Self > ConstWeakPointer
Definition: itkGPUImage.h:71
Superclass::AccessorType AccessorType
Definition: itkGPUImage.h:92
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor(void) const
Definition: itkGPUImage.h:155
Superclass::PixelContainer PixelContainer
Definition: itkGPUImage.h:85
Image< TPixel, VImageDimension > Superclass
Definition: itkGPUImage.h:68
GPUImageDataManager< GPUImage >::Pointer m_DataManager
Definition: itkGPUImage.h:238
int GetCurrentCommandQueueId(void)
Definition: itkGPUImage.h:184
Superclass::SpacingType SpacingType
Definition: itkGPUImage.h:84
Superclass::OffsetType OffsetType
Definition: itkGPUImage.h:88
Superclass::ValueType ValueType
Definition: itkGPUImage.h:80
Superclass::RegionType RegionType
Definition: itkGPUImage.h:89
SmartPointer< const Self > ConstPointer
Definition: itkGPUImage.h:70
#define ITKOpenCL_EXPORT
const PixelContainer * GetPixelContainer(void) const
Definition: itkGPUImage.h:171
PixelContainer * GetPixelContainer(void)
Definition: itkGPUImage.h:165
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor(void)
Definition: itkGPUImage.h:147
Superclass::SizeType SizeType
Definition: itkGPUImage.h:86
Superclass::IndexType IndexType
Definition: itkGPUImage.h:87
SmartPointer< Self > Pointer
Definition: itkGPUImage.h:69
GPUImage< TPixelType, NDimension > Type
Definition: itkGPUImage.h:255
const AccessorType GetPixelAccessor(void) const
Definition: itkGPUImage.h:139
PixelContainer::Pointer PixelContainerPointer
Definition: itkGPUImage.h:90


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo