27 #include <vtkLookupTable.h>
28 #include <vtkFieldData.h>
29 #include <vtkSmartPointer.h>
32 #include <itkMultiThreader.h>
33 #include <itksys/SystemTools.hxx>
38 #include <arpa/inet.h>
42 #define _USE_MATH_DEFINES
46 #define cAir 299704944;
47 #define fMod 20000000;
53 m_CISDist(0), m_CISAmpl(0), m_CISInten(0),
54 m_ThreadedCISDist(0), m_ThreadedCISAmpl(0), m_ThreadedCISInten(0),
55 m_Init(0), m_Width(0), m_Height(0), m_SourceDataSize(0), m_ImageSize(0), m_SourceData(0)
162 int channelSize = lineWidth*frameHeight << 1;
163 int quadChannelSize = channelSize * 0.25;
165 std::vector<short> quad = std::vector<short>(quadChannelSize);
171 while(channelNo < m_SourceData->GetNumberOfTuples())
173 short* sourceData =
new short[channelSize];
175 quad.insert(quad.begin(), sourceData, sourceData+channelSize);
187 if(
m_Threader->GetGlobalDefaultNumberOfThreads()> 5)
191 else if(
m_Threader->GetGlobalMaximumNumberOfThreads()>5)
197 maxThreadNr =
m_Threader->GetGlobalMaximumNumberOfThreads();
208 std::vector<int> threadIDVector;
209 int threadcounter = 0;
210 while(threadcounter != maxThreadNr-1)
215 threadIDVector.push_back(threadID);
222 while(count != threadIDVector.size())
224 m_Threader->TerminateThread(threadIDVector.at(count));
238 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)data;
241 return ITK_THREAD_RETURN_VALUE;
243 if (pInfo->UserData == NULL)
245 return ITK_THREAD_RETURN_VALUE;
247 int quadrant = pInfo->ThreadID;
268 double twoPi = pi + pi;
272 std::vector<short> quad1 = threadData->
m_InputData.at(0);
273 std::vector<short> quad2 = threadData->
m_InputData.at(1);
274 std::vector<short> quad3 = threadData->
m_InputData.at(2);
275 std::vector<short> quad4 = threadData->
m_InputData.at(3);
276 int index = quadrant << 1;
277 int index2 = 3-quadrant;
283 double intermed1 = cair/(pi*(modFreq << 2));
284 double intermed2 = intermed1*500;
285 int doubleLwidth = linewidth << 1;
286 int datasize = doubleLwidth*frameheight << 2;
291 index += doubleLwidth;
296 A1 = htons(quad1.at(index));
297 A2 = htons(quad2.at(index));
298 A3 = htons(quad3.at(index));
299 A4 = htons(quad4.at(index));
300 A5 = htons(quad1.at(index+1));
301 A6 = htons(quad2.at(index+1));
302 A7 = htons(quad3.at(index+1));
303 A8 = htons(quad4.at(index+1));
305 phi = atan2((A3 - A1),(A2 - A4)) + pi;
306 phi2 = atan2((A7 - A5),(A6 - A8));
307 if(phi2<0) phi2 +=twoPi;
309 A3m1 = A3*A3 - 2*A3*A1 + A1*A1;
310 A4m2 = A4*A4 - 2*A4*A2 + A2*A2;
311 A7m5 = A7*A7 - 2*A7*A5 + A5*A5;
312 A8m6 = A8*A8 - 2*A8*A6 + A6*A6;
314 threadData->
m_OutputData.at(0)[index2] = (phi+phi2)*intermed2;
315 threadData->
m_OutputData.at(1)[index2] = (sqrt(A3m1 + A4m2)+sqrt(A7m5 + A8m6))*0.5;
316 threadData->
m_OutputData.at(2)[index2] = (A1+A2+A3+A4+A5+A6+A7+A8)*0.125;
320 }
while(index2 <= (x*linewidth) - (1+quadrant));
322 index += doubleLwidth;
324 }
while(index < datasize);
328 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)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.