Openholo  v2.1
Open Source Digital Holographic Library
ophWRP.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 
46 #ifndef __ophWRP_h
47 #define __ophWRP_h
48 
49 #define _USE_MATH_DEFINES
50 
51 #include "ophGen.h"
52 
53 #ifdef RECON_EXPORT
54 #define RECON_DLL __declspec(dllexport)
55 #else
56 #define RECON_DLL __declspec(dllimport)
57 #endif
58 
59 //Build Option : Multi Core Processing (OpenMP)
60 #ifdef _OPENMP
61 #include <omp.h>
62 #endif
63 
64 
65 #define THREAD_X 32
66 #define THREAD_Y 16
67 
68 /* Bitmap File Definition*/
69 #define OPH_Bitsperpixel 8 //24 // 3byte=24
70 #define OPH_Planes 1
71 #define OPH_Compression 0
72 #define OPH_Xpixelpermeter 0x130B //2835 , 72 DPI
73 #define OPH_Ypixelpermeter 0x130B //2835 , 72 DPI
74 #define OPH_Pixel 0xFF
75 
76 using namespace oph;
77 
78 
79 
83 
114 
116 
122 class GEN_DLL ophWRP : public ophGen
123 {
124 
125 public:
130  explicit ophWRP(void);
131 
132 protected:
136  virtual ~ophWRP(void);
137 
138 public:
139  const vec3& getScale() { return wrp_config_.scale; }
140  const Real& getLocation() { return wrp_config_.wrp_location; }
141  const Real& getDistance() { return wrp_config_.propagation_distance; }
142  const int& getNumOfWRP() { return wrp_config_.num_wrp; }
143  const Real& getFieldLens() { return wrp_config_.fieldLength; }
144  void setScale(vec3 scale) { wrp_config_.scale = scale; }
145  void setLocation(Real location) { wrp_config_.wrp_location = location; }
146  void setDistance(Real distance) { wrp_config_.propagation_distance; }
147  void autoScaling();
148  int getNumOfPoints() { return n_points; }
149 
157  virtual int loadPointCloud(const char* pc_file);
158 
166  virtual bool readConfig(const char* fname);
167 
168  double calculateWRPCPU(void);
169  void calculateWRPGPU(void);
170 
171 // virtual void fresnelPropagation(Complex<Real>* in, Complex<Real>* out, Real distance);
172 
177  void generateHologram(void);
182  Complex<Real>** calculateMWRP(void);
183 
184  inline Complex<Real>* getWRPBuff(void) { return p_wrp_; };
185 
195  void setViewingWindow(bool is_ViewingWindow);
196  uint* getProgress() { return &m_nProgress; }
197 
198 protected:
199 
200 
201 private:
202 
203  Complex<Real>* ophWRP::calSubWRP(double d, oph::Complex<Real>* wrp, OphPointCloudData* sobj);
204 
205  void addPixel2WRP(int x, int y, oph::Complex<Real> temp);
206  void addPixel2WRP(int x, int y, oph::Complex<Real> temp, oph::Complex<Real>* wrp);
207 
208  virtual void ophFree(void);
209  inline Real transVW(Real pt) {
210  Real fieldLens = this->getFieldLens();
211  return -fieldLens * pt / (pt - fieldLens);
212  }
213 
214  void transVW(Real* dst, Real *src, int size);
215 protected:
216 
217  int n_points;
218 
219  Complex<Real>* p_wrp_;
220 
224 
225 private:
226  bool is_ViewingWindow;
227  Real zmax_;
228  uint m_nProgress;
229 
230 };
231 #endif
int getNumOfPoints()
Definition: ophWRP.h:148
const vec3 & getScale()
Definition: ophWRP.h:139
Configuration for WRP.
Definition: ophGen.h:633
void setLocation(Real location)
Definition: ophWRP.h:145
#define GEN_DLL
Definition: ophGen.h:54
OphPointCloudData obj_
Input Pointcloud Data.
Definition: ophWRP.h:221
Definition: ophWRP.h:122
const int & getNumOfWRP()
Definition: ophWRP.h:142
Real * scaledVertex
Definition: ophWRP.h:222
Complex< Real > * getWRPBuff(void)
Definition: ophWRP.h:184
Complex< Real > * p_wrp_
wrp buffer - complex type
Definition: ophWRP.h:219
OphWRPConfig wrp_config_
structure variable for WRP hologram configuration
Definition: ophWRP.h:223
void setDistance(Real distance)
Definition: ophWRP.h:146
void setScale(vec3 scale)
Definition: ophWRP.h:144
delete [] temp
Definition: ImgControl.cpp:239
int n_points
numbers of points
Definition: ophWRP.h:217
Data for Point Cloud.
Definition: ophGen.h:549
float Real
Definition: typedef.h:55
const Real & getLocation()
Definition: ophWRP.h:140
uint * getProgress()
Definition: ophWRP.h:196
Definition: Bitmap.h:49
const Real & getFieldLens()
Definition: ophWRP.h:143
unsigned int uint
Definition: typedef.h:62
Definition: ophGen.h:68
const Real & getDistance()
Definition: ophWRP.h:141