CTL  0.6.1
Computed Tomography Library
genericoclvolumefilter.h
1 #ifndef CTL_GENERICOCLVOLUMEFILTER_H
2 #define CTL_GENERICOCLVOLUMEFILTER_H
3 
4 #include "ocl/openclconfig.h"
5 #include "processing/abstractvolumefilter.h"
6 
7 namespace CTL {
8 
9 template<typename>
10 class VoxelVolume;
11 
12 namespace OCL {
13 
119 {
121 
122 public: void filter(VoxelVolume<float>& volume) override;
123 
124 public:
125  explicit GenericOCLVolumeFilter(const std::string& clFileName,
126  const std::vector<float>& arguments = {});
127 
128  void setAdditionalKernelArg(float argument);
129  void setAdditionalKernelArgs(const std::vector<float>& arguments);
130 
131  // AbstractVolumeFilter interface
132  QVariant parameter() const override;
133  void setParameter(const QVariant& parameter) override;
134 
135 protected:
137  explicit GenericOCLVolumeFilter(cl::Kernel* kernel, const std::vector<float>& arguments = {});
138 
139  // only for serialization
140  std::string _clFileName;
141  std::vector<float> _additionalArgs;
142 
143  cl::Kernel* _kernel;
144  cl::CommandQueue _queue;
145 
146  virtual cl::NDRange globalWorksize(const VoxelVolume<float>& volume) const;
147  virtual cl::NDRange localWorksize(const VoxelVolume<float>& volume) const;
148 
149 private:
150  static cl::Kernel* addKernelFromFile(const std::string& clFileName);
151  static cl::CommandQueue getCommandQueue();
152 };
153 
154 } // namespace OCL
155 } // namespace CTL
156 
157 #endif // CTL_GENERICOCLVOLUMEFILTER_H
virtual cl::NDRange localWorksize(const VoxelVolume< float > &volume) const
Returns the local worksize for the kernel call.
Definition: genericoclvolumefilter.cpp:86
GenericOCLVolumeFilter()
Creates a GenericOCLVolumeFilter without any OpenCL kernel associated to it.
Definition: genericoclvolumefilter.cpp:60
The VoxelVolume class provides a simple container for storage of voxelized 3D volume data.
Definition: ctsystemview.h:14
Definition: abstractvolumefilter.h:11
void setParameter(const QVariant &parameter) override
Sets the parameters of this instance based on the passed QVariant parameter.
Definition: genericoclvolumefilter.cpp:276
void setAdditionalKernelArgs(const std::vector< float > &arguments)
Sets the additional kernel arguments to arguments.
Definition: genericoclvolumefilter.cpp:169
The GenericOCLVolumeFilter class is a facility class that allows easy construction of a volume filter...
Definition: genericoclvolumefilter.h:118
static cl::CommandQueue getCommandQueue()
Returns the command queue to be used by this instance.
Definition: genericoclvolumefilter.cpp:306
#define CTL_TYPE_ID(newIndex)
Definition: serializationinterface.h:189
void filter(VoxelVolume< float > &volume) override
Filters the input volume by executing the OpenCL kernel of this instance.
Definition: genericoclvolumefilter.cpp:200
static cl::Kernel * addKernelFromFile(const std::string &clFileName)
Adds the OpenCL kernel defined in the file clFileName to the OpenCL environment and returns a pointer...
Definition: genericoclvolumefilter.cpp:100
QVariant parameter() const override
Returns the parameters of this instance as QVariant.
Definition: genericoclvolumefilter.cpp:251
void setAdditionalKernelArg(float argument)
Convenience method for simpler setting of a single additional argument.
Definition: genericoclvolumefilter.cpp:154
virtual cl::NDRange globalWorksize(const VoxelVolume< float > &volume) const
Returns the global worksize for the kernel call.
Definition: genericoclvolumefilter.cpp:74