Openholo  v1.0
Open Source Digital Holographic Library
ophPAS.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef __ophPAS_h
4 #define __ophPAS_h
5 
6 #include "ophGen.h"
7 
8 
9 #define PI (3.14159265358979323846f)
10 #define M2_PI (PI*2.0)
11 #define RADIANS (PI/180.0) // Angle in radians
12 // DEGREE*asin(mytheta)
13 #define DEGREE2 (180./PI) // sin(RADIANS*DEGREE*asin(mytheta))
14 
15 #define NUMTBL 1024
16 #define NUMTBL2 (NUMTBL-1)
17 #define MAX_STR_LEN 4000
18 
19 #define FFT_SEGMENT_SIZE 64
20 
21 struct VoxelStruct;
22 struct Segment;
23 
24 using namespace oph;
25 
26 class GEN_DLL ophPAS : public ophGen
27 {
28 private:
29  OphPointCloudConfig pc_config;
30  OphPointCloudData pc_data;
31  int n_points;
32 public:
33  explicit ophPAS();
34 protected:
35  virtual ~ophPAS();
36 
37 public:
38 
39 
40 
41  bool readConfig(const char* fname);
42  int loadPoint(const char* _filename);
43 
44  //int saveAsImg(const char * fname, uint8_t bitsperpixel, void* src, int pic_width, int pic_height); // 이미지 저장
45  int save(const char * fname, uint8_t bitsperpixel, uchar* src, uint px, uint py);
46  void save(const char* fname);
47 
48 
49 
50 
51  //void PASCalcuation(long voxnum, unsigned char *cghfringe, VoxelStruct* h_vox, CGHEnvironmentData* _CGHE);
52  void PASCalculation(long voxnum, unsigned char * cghfringe, OphPointCloudData *data, OphPointCloudConfig& conf);
53  //void PAS(long voxelnum, struct VoxelStruct *voxel, double *m_pHologram, CGHEnvironmentData* _CGHE);
54  void PAS(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf);
55  void PAS_GPU(long voxelnum, OphPointCloudData *data, double *m_pHologram, OphPointCloudConfig& conf);
56  void DataInit(int segsize, int cghwidth, int cghheight, float xiinter, float etainter);
57  void DataInit(OphPointCloudConfig& conf);
58  void MemoryRelease(void);
59 
60  void generateHologram();
61 
62  void CalcSpatialFrequency(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float * xc, float * yc, float * sf_cx, float * sf_cy, int * pp_cx, int * pp_cy, int * cf_cx, int * cf_cy, float xiint, float etaint, OphPointCloudConfig& conf);
63 
64  void CalcCompensatedPhase(float cx, float cy, float cz, float amp, int segnumx, int segnumy, int segsize, int hsegsize, float sf_base, float *xc, float *yc, int *cf_cx, int *cf_cy, float *COStbl, float *SINtbl, float **inRe, float **inIm, OphPointCloudConfig& conf);
65 
66  void RunFFTW(int segnumx, int segnumy, int segsize, int hsegsize, float **inRe, float **inIm, fftw_complex *in, fftw_complex *out, fftw_plan *plan, double *pHologram, OphPointCloudConfig& conf);
67 
68  void encodeHologram(const vec2 band_limit, const vec2 spectrum_shift);
69  void encoding(unsigned int ENCODE_FLAG);
70 
71 
72  double *m_pHologram;
73 
74  float m_COStbl[NUMTBL];
75  float m_SINtbl[NUMTBL];
76 
77  int m_segSize;
80  int m_segNumx;
81  int m_segNumy;
84 
85  float* m_inRe_h;
86  float* m_inIm_h;
87 
94  float *m_xc;
95  float *m_yc;
96  unsigned char* cgh_fringe;
97 
98  float m_sf_base;
99 
100  fftw_complex *m_in, *m_out;
101  fftw_plan m_plan;
102 
103  float **m_inRe;
104  float **m_inIm;
105 
106  float m_cx;
107  float m_cy;
108  float m_cz;
109  float m_amp;
110 };
111 
112 struct GEN_DLL VoxelStruct // voxel structure - data
113 {
114  int num; // voxel or point number
115  float x; // x axis coordinate
116  float y; // y axis coordinate
117  float z; // z axis coordinate
118  float ph; // phase
119  float r; // amplitude in red channel
120  float g; // amplitude in green channel
121  float b; // amplitude in blue channel
122 };
123 
124 
125 struct GEN_DLL Segment
126 {
127  bool WorkingFlag;
128  long SegmentIndex;
129  int SegSize_x;
130  int SegSize_y;
131  int hSegSize_x; // Half size
132  int hSegSize_y; // Half size
133  double CenterX;
134  double CenterY;
135  double FrequencySlope;
136 };
137 #endif // !__ophPAS_h
ENCODE_FLAG
Definition: ophGen.h:72
fftw_complex * m_out
Definition: ophPAS.h:100
int m_hsegNumx
Definition: ophPAS.h:82
int m_segSize
Definition: ophPAS.h:77
unsigned char uchar
Definition: typedef.h:64
float * m_SFrequency_cy
Definition: ophPAS.h:89
float g
Definition: ophPAS.h:120
int * m_Coefficient_cx
Definition: ophPAS.h:92
float ** m_inIm
Definition: ophPAS.h:104
int m_segNumx
Definition: ophPAS.h:80
float m_cy
Definition: ophPAS.h:107
float m_amp
Definition: ophPAS.h:109
int * m_PickPoint_cx
Definition: ophPAS.h:90
float m_sf_base
Definition: ophPAS.h:98
float * m_inIm_h
Definition: ophPAS.h:86
float b
Definition: ophPAS.h:121
int m_segNumy
Definition: ophPAS.h:81
int num
Definition: ophTriMesh.cpp:603
int m_dsegSize
Definition: ophPAS.h:79
unsigned char * cgh_fringe
Definition: ophPAS.h:96
#define GEN_DLL
Definition: ophGen.h:54
int * m_PickPoint_cy
Definition: ophPAS.h:91
float m_cx
Definition: ophPAS.h:106
float m_cz
Definition: ophPAS.h:108
float * m_inRe_h
Definition: ophPAS.h:85
int * m_Coefficient_cy
Definition: ophPAS.h:93
int m_hsegNumy
Definition: ophPAS.h:83
double * m_pHologram
Definition: ophPAS.h:72
Configuration for Point Cloud.
Definition: ophGen.h:430
float * m_xc
Definition: ophPAS.h:94
float * m_SFrequency_cx
Definition: ophPAS.h:88
Data for Point Cloud.
Definition: ophGen.h:457
float ** m_inRe
Definition: ophPAS.h:103
fftw_plan m_plan
Definition: ophPAS.h:101
Definition: ophPAS.h:26
Definition: Bitmap.h:49
int m_hsegSize
Definition: ophPAS.h:78
#define NUMTBL
Definition: ophPAS.h:15
unsigned int uint
Definition: typedef.h:62
float * m_yc
Definition: ophPAS.h:95
Definition: ophGen.h:68