WPOCT Software Developer's Kit (SDK)
SDK For using Wasatch Photonics OCT Spectrometers
ConversionInOutData.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <atomic>
9 #include "IWPOCTInOutData.h"
10 
12 {
13 public:
14  // Constructors.
16  ConversionInOutData(int width, int height, bool allocateRaw = false,
17  bool allocateIntensity = false, bool allocatePhase = false,
18  bool allocateScaled = false, bool allocateTransposed = false,
19  bool allocateColor = false);
20 
21  // Destructor
22  virtual ~ConversionInOutData();
23 
24  // Getters
25  // Determines if these arrays were allocated by the converter dll.
26  // If value returned is true, then the dll allocated the array.
27  bool IsRawAllocated () const override { return _rawAllocated; }
28  bool IsIntensityAllocated() const override { return _intensityAllocated; }
29  bool IsPhaseAllocated() const override { return _phaseAllocated; }
30  bool IsScaledAllocated() const override { return _scaledAllocated; }
31  bool IsTransposedAllocated() const override { return _transposedAllocated; }
32  bool IsColorAllocated() const override { return _colorAllocated; }
33 
34  int GetRawSize () const override;
35  int GetIntensitySize() const override;
36  int GetPhaseSize () const override;
37  int GetScaledSize () const override;
38  int GetTransposedSize() const override;
39  int GetColorSize () const override;
40 
41  int GetInputWidth () const override { return _inputWidth; }
42  int GetInputHeight () const override { return _inputHeight; }
43  int GetOutputWidth () const override { return _outputWidth; }
44  int GetOutputHeight () const override { return _outputHeight; }
45 
47  unsigned short* GetRawData () override { return _rawData; }
49  float* GetIntensityData() override { return _intensityData; }
51  float* GetPhaseData () override { return _phaseData; }
53  unsigned short* GetScaledData () override { return _scaledData; }
55  unsigned short* GetTransposedData() override { return _transposedData; }
57  unsigned char* GetColorData () override { return _colorData; }
58 
59  // Get copies of the data.
60  bool GetRawData (unsigned short* data) override;
61  bool GetIntensityData(float* data) override;
62  bool GetPhaseData (float* data) override;
63  bool GetScaledData (unsigned short* data) override;
64  bool GetTransposedData(unsigned short* data) override;
65  bool GetColorData (unsigned char* data) override;
66 
67  // Setters
68  // Determines if these arrays will be allocated or they will be supplied by the user.
69  // If value is true, then the dll will allocate the array. If false, the application (user)
70  // must supply the array.
71  bool SetAllocateRaw (bool value) override;
72  bool SetAllocateIntensity(bool value) override;
73  bool SetAllocatePhase (bool value) override;
74  bool SetAllocateScaled (bool value) override;
75  bool SetAllocateTransposed(bool value) override;
76  bool SetAllocateColor (bool value) override;
77 
78  bool SetInputWidth (int value) override { _inputWidth = value; return true; }
79  bool SetInputHeight (int value) override { _inputHeight = value; return true; }
80  bool SetOutputWidth (int value) override { _outputWidth = value; return true; }
81  bool SetOutputHeight (int value) override { _outputHeight = value; return true; }
82 
83 
85  bool SetRawData (unsigned short* data, int width, int height) override;
87  bool SetIntensityData (float* data, int width, int height) override;
89  bool SetPhaseData (float* data) override;
91  bool SetScaledData (unsigned short* data) override;
93  bool SetTransposedData (unsigned short* data) override;
95  bool SetColorData (unsigned char* data) override;
96 
97  bool Resize (int width, int height) override;
98  bool Resize () override;
99 
100  IWPOCTInOutData::ErrorCode GetLastError() const override;
101 
102 protected:
103  void Init();
104 
105 private:
106  // Keep track of which buffers have been allocated.
107  bool _rawAllocated;
108  bool _intensityAllocated;
109  bool _phaseAllocated;
110  bool _scaledAllocated;
111  bool _transposedAllocated;
112  bool _colorAllocated;
113 
114  // These flags indicate if buffers should be allocated when the next Resize is called.
115  bool _rawToBeAllocated;
116  bool _intensityToBeAllocated;
117  bool _phaseToBeAllocated;
118  bool _scaledToBeAllocated;
119  bool _transposedToBeAllocated;
120  bool _colorToBeAllocated;
121 
122  int _currentSize;
123  int _inputWidth;
124  int _inputHeight;
125  int _outputWidth;
126  int _outputHeight;
127 
128  unsigned short* _rawData;
129  float* _intensityData;
130  float* _phaseData;
131  unsigned short* _scaledData;
132  unsigned short* _transposedData;
133  unsigned char* _colorData;
134 
136  std::atomic<ErrorCode> _lastError;
137 
138  // Methods
139  void DeleteArrays();
140 };
Interface fo the IWPOCTInOutData class.
Definition: ConversionInOutData.h:12
bool Resize() override
After changing one or more of the allocated flags, one of these methods must be called.
Definition: ConversionInOutData.cpp:396
int GetTransposedSize() const override
Returns the size of the transposed array.
Definition: ConversionInOutData.cpp:109
unsigned char * GetColorData() override
Get pointer to color array.
Definition: ConversionInOutData.h:57
bool SetScaledData(unsigned short *data) override
Sets the scaled data array pointer.
Definition: ConversionInOutData.cpp:287
int GetIntensitySize() const override
Returns the size of the output intensity array.
Definition: ConversionInOutData.cpp:82
bool SetColorData(unsigned char *data) override
Sets the color data array pointer.
Definition: ConversionInOutData.cpp:315
bool SetAllocateScaled(bool value) override
Sets the flag that determines if the scaled data array is allocated by this DLL when the Resize API i...
Definition: ConversionInOutData.cpp:362
unsigned short * GetTransposedData() override
Get pointer to transposed array.
Definition: ConversionInOutData.h:55
float * GetIntensityData() override
Get pointer to intensity array.
Definition: ConversionInOutData.h:49
bool SetAllocateColor(bool value) override
Sets the flag that determines if the color data array is allocated by this DLL when the Resize API is...
Definition: ConversionInOutData.cpp:384
int GetScaledSize() const override
Returns the size of the scaled array.
Definition: ConversionInOutData.cpp:100
bool IsIntensityAllocated() const override
Returns a flag indicating if the intensity array is allocated.
Definition: ConversionInOutData.h:28
bool SetAllocatePhase(bool value) override
Sets the flag that determines if the phase data array is allocated by this DLL when the Resize API is...
Definition: ConversionInOutData.cpp:351
bool SetAllocateTransposed(bool value) override
Sets the flag that determines if the transposed data array is allocated by this DLL when the Resize A...
Definition: ConversionInOutData.cpp:373
float * GetPhaseData() override
Get pointer to phase array.
Definition: ConversionInOutData.h:51
int GetPhaseSize() const override
Returns the size of the output phase array.
Definition: ConversionInOutData.cpp:91
bool SetPhaseData(float *data) override
Sets the phase data array pointer.
Definition: ConversionInOutData.cpp:273
bool SetAllocateIntensity(bool value) override
Sets the flag that determines if the intensity data array is allocated by this DLL when the Resize AP...
Definition: ConversionInOutData.cpp:340
bool SetAllocateRaw(bool value) override
Sets the flag that determines if the raw data array is allocated by this DLL when the Resize API is c...
Definition: ConversionInOutData.cpp:329
bool SetIntensityData(float *data, int width, int height) override
Sets the intensity data array pointer.
Definition: ConversionInOutData.cpp:258
bool IsPhaseAllocated() const override
Returns a flag indicating if the phase array is allocated.
Definition: ConversionInOutData.h:29
int GetRawSize() const override
Gets the size of the raw input array.
Definition: ConversionInOutData.cpp:73
bool IsTransposedAllocated() const override
Returns a flag indicating if the transposed array is allocated.
Definition: ConversionInOutData.h:31
bool SetTransposedData(unsigned short *data) override
Sets the transposed data array pointer.
Definition: ConversionInOutData.cpp:301
bool IsRawAllocated() const override
Returns a flag indicating if the raw array is allocated.
Definition: ConversionInOutData.h:27
bool IsScaledAllocated() const override
Returns a flag indicating if the scaled array is allocated.
Definition: ConversionInOutData.h:30
unsigned short * GetScaledData() override
Get pointer to extra array.
Definition: ConversionInOutData.h:53
bool SetRawData(unsigned short *data, int width, int height) override
Sets the raw data array pointer.
Definition: ConversionInOutData.cpp:242
bool IsColorAllocated() const override
Returns a flag indicating if the color array is allocated.
Definition: ConversionInOutData.h:32
int GetColorSize() const override
Returns the size of the color array.
Definition: ConversionInOutData.cpp:118
unsigned short * GetRawData() override
Get pointer to raw array.
Definition: ConversionInOutData.h:47
The data object contains pointers to input and output data.
Definition: IWPOCTInOutData.h:14
ErrorCode
The following are error codes that are used within the data object.
Definition: IWPOCTInOutData.h:19