ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkGPUImageDataManager.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 
19 #ifndef itkGPUImageDataManager_h
20 #define itkGPUImageDataManager_h
21 
22 #include <itkObject.h>
23 #include <itkTimeStamp.h>
24 #include <itkLightObject.h>
25 #include <itkObjectFactory.h>
26 #include "itkOpenCLUtil.h"
27 #include "itkGPUDataManager.h"
28 #include "itkGPUContextManager.h"
29 #include "itkSimpleFastMutexLock.h"
30 
31 namespace itk
32 {
33 template < typename TPixel, unsigned int NDimension > class GPUImage;
34 
43 template < typename ImageType >
45 {
46  // allow GPUKernelManager to access GPU buffer pointer
47  friend class GPUKernelManager;
48  friend class GPUImage< typename ImageType::PixelType, ImageType::ImageDimension >;
49 
50 public:
53  typedef SmartPointer<Self> Pointer;
54  typedef SmartPointer<const Self> ConstPointer;
55 
56  itkNewMacro(Self);
57  itkTypeMacro(GPUImageDataManager, GPUDataManager);
58 
59  static const unsigned int ImageDimension = ImageType::ImageDimension;
60 
61  itkGetModifiableObjectMacro(GPUBufferedRegionIndex, GPUDataManager);
62  itkGetModifiableObjectMacro(GPUBufferedRegionSize, GPUDataManager);
63 
64  void SetImagePointer( typename ImageType::Pointer img );
65  ImageType *GetImagePointer()
66  {
67  return this->m_Image.GetPointer();
68  }
69 
71  virtual void MakeCPUBufferUpToDate();
72 
74  virtual void MakeGPUBufferUpToDate();
75 
76 protected:
78  virtual ~GPUImageDataManager() {}
79 
80 private:
81  GPUImageDataManager(const Self&) ITK_DELETE_FUNCTION;
82  void operator=(const Self&);
83 
84  WeakPointer<ImageType> m_Image; // WeakPointer has to be used here
85  // to avoid SmartPointer loop
87  int m_BufferedRegionSize[ImageType::ImageDimension];
90 
91 };
92 
93 } // namespace itk
94 
95 #ifndef ITK_MANUAL_INSTANTIATION
96 #include "itkGPUImageDataManager.hxx"
97 #endif
98 
99 #endif
Light weight base class for most itk classes.
static const unsigned int ImageDimension
int m_BufferedRegionSize[ImageType::ImageDimension]
GPUDataManager::Pointer m_GPUBufferedRegionSize
int m_BufferedRegionIndex[ImageType::ImageDimension]
Implements a weak reference to an object.
void SetImagePointer(typename ImageType::Pointer img)
GPU memory manager implemented using OpenCL. Required by GPUImage class.
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:40
virtual void MakeCPUBufferUpToDate()
GPUDataManager::Pointer m_GPUBufferedRegionIndex
GPU kernel manager implemented using OpenCL.
virtual void MakeGPUBufferUpToDate()
ObjectType * GetPointer() const
Implements transparent reference counting.
WeakPointer< ImageType > m_Image