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"
40#include "itkVersion.h"
41#include "itkObjectFactoryBase.h"
42
43namespace itk
44{
62template< typename TPixel, unsigned int VImageDimension = 2 >
63class ITKOpenCL_EXPORT GPUImage : public Image< TPixel, VImageDimension >
64{
65public:
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 void Allocate( bool initialize = false ) 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
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
148 {
149 m_DataManager->SetGPUBufferDirty();
151 }
152
153
156 {
157 m_DataManager->UpdateCPUBuffer();
159 }
160
161
163
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
191
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
224protected:
225
227 virtual ~GPUImage() {}
228
229 virtual void PrintSelf( std::ostream & os, Indent indent ) const;
230
231private:
232
233 GPUImage( const Self & ); // purposely not implemented
234 void operator=( const Self & ); // purposely not implemented
235
237
239};
240
241//------------------------------------------------------------------------------
242template< typename T >
243class GPUTraits
244{
245public:
246
247 typedef T Type;
248};
249
250template< typename TPixelType, unsigned int NDimension >
251class GPUTraits< Image< TPixelType, NDimension > >
252{
253public:
254
255 typedef GPUImage< TPixelType, NDimension > Type;
256};
257
258} // end namespace itk
259
260#ifndef ITK_MANUAL_INSTANTIATION
261#include "itkGPUImage.hxx"
262#endif
263
264#endif
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:64
Image< TPixel, VImageDimension > Superclass
Definition: itkGPUImage.h:68
TPixel * GetBufferPointer(void)
SmartPointer< Self > Pointer
Definition: itkGPUImage.h:69
SmartPointer< const Self > ConstPointer
Definition: itkGPUImage.h:70
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor(void) const
Definition: itkGPUImage.h:155
const TPixel * GetBufferPointer(void) const
GPUDataManager::Pointer GetGPUDataManager(void) const
void GraftITKImage(const DataObject *data)
void UpdateBuffers(void)
Superclass::AccessorType AccessorType
Definition: itkGPUImage.h:92
void operator=(const Self &)
AccessorType GetPixelAccessor(void)
Definition: itkGPUImage.h:131
NeighborhoodAccessorFunctor< Self > NeighborhoodAccessorFunctorType
Definition: itkGPUImage.h:96
virtual void Graft(const DataObject *data)
virtual void Initialize(void)
const TPixel & GetPixel(const IndexType &index) const
DefaultPixelAccessorFunctor< Self > AccessorFunctorType
Definition: itkGPUImage.h:94
void UpdateGPUBuffer(void)
virtual void Modified(void) const
PixelContainer::ConstPointer PixelContainerConstPointer
Definition: itkGPUImage.h:91
Superclass::OffsetType OffsetType
Definition: itkGPUImage.h:88
Superclass::DirectionType DirectionType
Definition: itkGPUImage.h:83
const PixelContainer * GetPixelContainer(void) const
Definition: itkGPUImage.h:171
virtual void PrintSelf(std::ostream &os, Indent indent) const
Superclass::IOPixelType IOPixelType
Definition: itkGPUImage.h:82
void SetPixel(const IndexType &index, const TPixel &value)
void SetCurrentCommandQueue(int queueid)
Definition: itkGPUImage.h:178
Superclass::RegionType RegionType
Definition: itkGPUImage.h:89
PixelContainer::Pointer PixelContainerPointer
Definition: itkGPUImage.h:90
Superclass::SpacingType SpacingType
Definition: itkGPUImage.h:84
void UpdateCPUBuffer(void)
PixelContainer * GetPixelContainer(void)
Definition: itkGPUImage.h:165
void Allocate(bool initialize=false) override
TPixel & operator[](const IndexType &index)
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor(void)
Definition: itkGPUImage.h:147
const TPixel & operator[](const IndexType &index) const
GPUImage(const Self &)
void DataHasBeenGenerated(void)
Definition: itkGPUImage.h:199
itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension)
GPUImageDataManager< GPUImage >::Pointer m_DataManager
Definition: itkGPUImage.h:238
int GetCurrentCommandQueueId(void)
Definition: itkGPUImage.h:184
GPUImage Self
Definition: itkGPUImage.h:67
void SetPixelContainer(PixelContainer *container)
Superclass::ValueType ValueType
Definition: itkGPUImage.h:80
Superclass::PixelContainer PixelContainer
Definition: itkGPUImage.h:85
virtual ~GPUImage()
Definition: itkGPUImage.h:227
WeakPointer< const Self > ConstWeakPointer
Definition: itkGPUImage.h:71
Superclass::InternalPixelType InternalPixelType
Definition: itkGPUImage.h:81
TPixel & GetPixel(const IndexType &index)
void AllocateGPU(void)
Superclass::SizeType SizeType
Definition: itkGPUImage.h:86
void FillBuffer(const TPixel &value)
const AccessorType GetPixelAccessor(void) const
Definition: itkGPUImage.h:139
Superclass::IndexType IndexType
Definition: itkGPUImage.h:87
#define ITKOpenCL_EXPORT


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo