23 #include <vtkLookupTable.h> 24 #include <vtkFieldData.h> 25 #include <vtkSmartPointer.h> 28 #include <itkMultiThreader.h> 29 #include <itksys/SystemTools.hxx> 34 #include <arpa/inet.h> 38 #define cAir 299704944; 39 #define fMod 20000000; 45 m_CISDist(0), m_CISAmpl(0), m_CISInten(0),
46 m_ThreadedCISDist(0), m_ThreadedCISAmpl(0), m_ThreadedCISInten(0),
47 m_Init(0), m_Width(0), m_Height(0), m_SourceDataSize(0), m_ImageSize(0), m_SourceData(0)
154 int channelSize = lineWidth*frameHeight << 1;
155 int quadChannelSize = channelSize * 0.25;
157 std::vector<short> quad = std::vector<short>(quadChannelSize);
163 while(channelNo < m_SourceData->GetNumberOfTuples())
165 short* sourceData =
new short[channelSize];
167 quad.insert(quad.begin(), sourceData, sourceData+channelSize);
179 if(
m_Threader->GetGlobalDefaultNumberOfThreads()> 5)
183 else if(
m_Threader->GetGlobalMaximumNumberOfThreads()>5)
189 maxThreadNr =
m_Threader->GetGlobalMaximumNumberOfThreads();
200 std::vector<int> threadIDVector;
201 int threadcounter = 0;
202 while(threadcounter != maxThreadNr-1)
207 threadIDVector.push_back(threadID);
214 while(count != threadIDVector.size())
216 m_Threader->TerminateThread(threadIDVector.at(count));
230 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)data;
231 if (pInfo ==
nullptr)
233 return ITK_THREAD_RETURN_VALUE;
235 if (pInfo->UserData ==
nullptr)
237 return ITK_THREAD_RETURN_VALUE;
239 int quadrant = pInfo->ThreadID;
259 double twoPi = itk::Math::pi + itk::Math::pi;
263 std::vector<short> quad1 = threadData->
m_InputData.at(0);
264 std::vector<short> quad2 = threadData->
m_InputData.at(1);
265 std::vector<short> quad3 = threadData->
m_InputData.at(2);
266 std::vector<short> quad4 = threadData->
m_InputData.at(3);
267 int index = quadrant << 1;
268 int index2 = 3-quadrant;
274 double intermed1 = cair/(itk::Math::pi*(modFreq << 2));
275 double intermed2 = intermed1*500;
276 int doubleLwidth = linewidth << 1;
277 int datasize = doubleLwidth*frameheight << 2;
282 index += doubleLwidth;
287 A1 = htons(quad1.at(index));
288 A2 = htons(quad2.at(index));
289 A3 = htons(quad3.at(index));
290 A4 = htons(quad4.at(index));
291 A5 = htons(quad1.at(index+1));
292 A6 = htons(quad2.at(index+1));
293 A7 = htons(quad3.at(index+1));
294 A8 = htons(quad4.at(index+1));
296 phi = atan2((A3 - A1),(A2 - A4)) + itk::Math::pi;
297 phi2 = atan2((A7 - A5),(A6 - A8));
298 if(phi2<0) phi2 +=twoPi;
300 A3m1 = A3*A3 - 2*A3*A1 + A1*A1;
301 A4m2 = A4*A4 - 2*A4*A2 + A2*A2;
302 A7m5 = A7*A7 - 2*A7*A5 + A5*A5;
303 A8m6 = A8*A8 - 2*A8*A6 + A6*A6;
305 threadData->
m_OutputData.at(0)[index2] = (phi+phi2)*intermed2;
306 threadData->
m_OutputData.at(1)[index2] = (sqrt(A3m1 + A4m2)+sqrt(A7m5 + A8m6))*0.5;
307 threadData->
m_OutputData.at(2)[index2] = (A1+A2+A3+A4+A5+A6+A7+A8)*0.125;
311 }
while(index2 <= (x*linewidth) - (1+quadrant));
313 index += doubleLwidth;
315 }
while(index < datasize);
319 return ITK_THREAD_RETURN_VALUE;
void Initialize(int width, int height, int modulationFrequency, int sourceDataSize)
itk::FastMutexLock::Pointer m_ImageDataMutex
mutex for coordinated access to image data
virtual void GenerateData()
method generating the outputs of this filter. Called in the updated process of the pipeline...
void GetIntensities(float *inten)
float * m_CISDist
holds the distance information from for one distance image slice
float * m_ThreadedCISDist
void GetAmplitudes(float *ampl)
DataCollection - Class to facilitate loading/accessing structured data.
float * m_CISAmpl
holds the amplitude information from for one amplitude image slice
std::vector< float * > m_OutputData
float * m_ThreadedCISInten
ThreadDataStruct * m_ThreadData
ThreadedToFRawDataReconstruction()
standard constructor
~ThreadedToFRawDataReconstruction()
standard destructor
itk::Barrier::Pointer m_Barrier
barrier to synchronize ends of threads
void GetDistances(float *dist)
void SetChannelData(vtkShortArray *sourceData)
unsigned int m_FrameHeight
vtkShortArray * m_SourceData
unsigned int m_ModulationFrequency
std::vector< std::vector< short > > m_InputData
static ITK_THREAD_RETURN_TYPE ThreadedGenerateDataCallbackFunction(void *data)
threader callback function for multi threaded data generation
float * m_ThreadedCISAmpl
float * m_CISInten
holds the intensity information from for one intensity image slice
itk::MultiThreader::Pointer m_Threader
virtual void BeforeThreadedGenerateData()
method configures the camera output and prepares the thread data struct for threaded data generation ...
itk::FastMutexLock::Pointer m_ThreadDataMutex
mutex to control access to images
void GetAllData(float *dist, float *ampl, float *inten)