ITK  4.13.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 >
44 class ITK_TEMPLATE_EXPORT GPUImageDataManager : public GPUDataManager
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 ITK_CONSTEXPR_VAR 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() ITK_OVERRIDE {}
79 
80 private:
81  ITK_DISALLOW_COPY_AND_ASSIGN(GPUImageDataManager);
82 
83  WeakPointer<ImageType> m_Image; // WeakPointer has to be used here
84  // to avoid SmartPointer loop
85  int m_BufferedRegionIndex[ImageType::ImageDimension];
86  int m_BufferedRegionSize[ImageType::ImageDimension];
89 
90 };
91 
92 } // namespace itk
93 
94 #ifndef ITK_MANUAL_INSTANTIATION
95 #include "itkGPUImageDataManager.hxx"
96 #endif
97 
98 #endif
Light weight base class for most itk classes.
virtual ~GPUImageDataManager() override
GPUDataManager::Pointer m_GPUBufferedRegionSize
ObjectType * GetPointer() const
GPU memory manager implemented using OpenCL. Required by GPUImage class.
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:40
GPUDataManager::Pointer m_GPUBufferedRegionIndex
GPU kernel manager implemented using OpenCL.
Implements transparent reference counting.
WeakPointer< ImageType > m_Image