13 #define _USE_MATH_DEFINES 20 mitk::OCLDelayCalculation::OCLDelayCalculation(mitk::BeamformingSettings::Pointer settings)
21 : m_PixelCalculation(NULL),
24 this->AddSourceFile(
"DelayCalculation.cl");
25 this->m_FilterID =
"DelayCalculation";
34 mitk::OCLDelayCalculation::~OCLDelayCalculation()
36 if (this->m_PixelCalculation)
38 clReleaseKernel(m_PixelCalculation);
45 if (!this->Initialize())
52 mitkThrow() <<
"Filter is not initialized. Cannot update.";
60 void mitk::OCLDelayCalculation::Execute()
64 unsigned int gridDim[3] = { m_Conf->GetReconstructionLines() / 2, m_Conf->GetSamplesPerLine(), 1 };
65 m_BufferSize = gridDim[0] * gridDim[1] * 1;
69 this->InitExecNoInput(this->m_PixelCalculation, gridDim, m_BufferSize,
sizeof(
unsigned short));
73 MITK_ERROR <<
"Caught exception while initializing Delay Calculation filter: " << e.what();
78 m_DelayMultiplicatorRaw = 1 / (m_Conf->GetTimeSpacing()*m_Conf->GetSpeedOfSound()) *
79 (m_Conf->GetPitchInMeters()*(float)m_Conf->GetTransducerElements());
82 m_IsPAImage = m_Conf->GetIsPhotoacousticImage();
84 unsigned int reconstructionLines = this->m_Conf->GetReconstructionLines();
85 unsigned int samplesperLine = this->m_Conf->GetSamplesPerLine();
87 float totalSamples_i = (float)(m_Conf->GetReconstructionDepth()) / (
float)(m_Conf->GetSpeedOfSound() * m_Conf->GetTimeSpacing());
88 totalSamples_i = totalSamples_i <= m_Conf->GetInputDim()[1] ? totalSamples_i : m_Conf->GetInputDim()[1];
90 clErr = clSetKernelArg(this->m_PixelCalculation, 1,
sizeof(cl_mem), &(this->m_UsedLines));
91 clErr |= clSetKernelArg(this->m_PixelCalculation, 2,
sizeof(cl_uint), &(this->m_Conf->GetInputDim()[0]));
92 clErr |= clSetKernelArg(this->m_PixelCalculation, 3,
sizeof(cl_uint), &(this->m_Conf->GetInputDim()[1]));
93 clErr |= clSetKernelArg(this->m_PixelCalculation, 4,
sizeof(cl_uint), &(reconstructionLines));
94 clErr |= clSetKernelArg(this->m_PixelCalculation, 5,
sizeof(cl_uint), &(samplesperLine));
95 clErr |= clSetKernelArg(this->m_PixelCalculation, 6,
sizeof(cl_char), &(this->m_IsPAImage));
96 clErr |= clSetKernelArg(this->m_PixelCalculation, 7,
sizeof(cl_float), &(this->m_DelayMultiplicatorRaw));
97 clErr |= clSetKernelArg(this->m_PixelCalculation, 8,
sizeof(cl_float), &(totalSamples_i));
102 if (!this->ExecuteKernelChunksInBatches(m_PixelCalculation, 2, m_ChunkSize, 16, 50))
103 mitkThrow() <<
"openCL Error when executing Kernel";
108 us::Module *mitk::OCLDelayCalculation::GetModule()
113 bool mitk::OCLDelayCalculation::Initialize()
115 bool buildErr =
true;
118 if (OclFilter::Initialize())
120 this->m_PixelCalculation = clCreateKernel(this->m_ClProgram,
"ckDelayCalculationSphe", &clErr);
123 return (OclFilter::IsInitialized() && buildErr);
#define CHECK_OCL_ERR(_er)
virtual void InvalidateStorage()=0
Remove all invalid (=do not compile) programs from the internal storage.
ServiceReferenceU GetServiceReference(const std::string &clazz)
static void Update(vtkPolyData *)
void * GetService(const ServiceReferenceBase &reference)
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Module * GetModule() const
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Declaration of the OpenCL Resources micro-service.