Openholo  v1.0
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 
177  void setMode(bool is_CPU);
178 
179  double calculateWRPCPU(void);
180  double calculateWRPGPU(void);
181 
182 // virtual void fresnelPropagation(Complex<Real>* in, Complex<Real>* out, Real distance);
183 
188  void generateHologram(void);
193  Complex<Real>** calculateMWRP(void);
194 
195  inline Complex<Real>* getWRPBuff(void) { return p_wrp_; };
196 
206  void setViewingWindow(bool is_ViewingWindow);
207 
208 protected:
209  // ==== GPU Methods ===============================================
210  void prepareInputdataGPU();
211 
212 private:
213 
214  Complex<Real>* ophWRP::calSubWRP(double d, oph::Complex<Real>* wrp, OphPointCloudData* sobj);
215 
216  void addPixel2WRP(int x, int y, oph::Complex<Real> temp);
217  void addPixel2WRP(int x, int y, oph::Complex<Real> temp, oph::Complex<Real>* wrp);
218 
219  virtual void ophFree(void);
220  inline Real transVW(Real pt) {
221  Real fieldLens = this->getFieldLens();
222  return -fieldLens * pt / (pt - fieldLens);
223  }
224 
225  void transVW(Real* dst, Real *src, int size);
226 protected:
227 
228  int n_points;
229 
230  Complex<Real>* p_wrp_;
231 
235 
236 private:
237  bool is_ViewingWindow;
238  bool is_CPU;
239  Real zmax_;
240 
241 };
242 #endif
int getNumOfPoints()
Definition: ophWRP.h:148
const vec3 & getScale()
Definition: ophWRP.h:139
Real * scaledVertex
Definition: ophWRP.h:233
Configuration for WRP.
Definition: ophGen.h:511
void setLocation(Real location)
Definition: ophWRP.h:145
OphPointCloudData obj_
Input Pointcloud Data.
Definition: ophWRP.h:232
float Real
Definition: typedef.h:55
Definition: ophWRP.h:122
const int & getNumOfWRP()
Definition: ophWRP.h:142
Complex< Real > * getWRPBuff(void)
Definition: ophWRP.h:195
OphWRPConfig wrp_config_
structure variable for WRP hologram configuration
Definition: ophWRP.h:234
#define GEN_DLL
Definition: ophGen.h:54
void setDistance(Real distance)
Definition: ophWRP.h:146
void setScale(vec3 scale)
Definition: ophWRP.h:144
Complex< Real > * p_wrp_
wrp buffer - complex type
Definition: ophWRP.h:230
int n_points
numbers of points
Definition: ophWRP.h:228
Data for Point Cloud.
Definition: ophGen.h:427
const Real & getLocation()
Definition: ophWRP.h:140
Definition: Bitmap.h:49
const Real & getFieldLens()
Definition: ophWRP.h:143
Definition: ophGen.h:68
const Real & getDistance()
Definition: ophWRP.h:141