Openholo  v4.2
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 #include "ophGen.h"
50 
51 //Build Option : Multi Core Processing (OpenMP)
52 #ifdef _OPENMP
53 #include <omp.h>
54 #endif
55 
56 
57 #define THREAD_X 32
58 #define THREAD_Y 16
59 
60 /* Bitmap File Definition*/
61 #define OPH_Bitsperpixel 8 //24 // 3byte=24
62 #define OPH_Planes 1
63 #define OPH_Compression 0
64 #define OPH_Xpixelpermeter 0x130B //2835 , 72 DPI
65 #define OPH_Ypixelpermeter 0x130B //2835 , 72 DPI
66 #define OPH_Pixel 0xFF
67 
68 using namespace oph;
69 
70 
71 
75 
106 
108 
114 class GEN_DLL ophWRP : public ophGen
115 {
116 
117 public:
122  explicit ophWRP(void);
123 
124 protected:
128  virtual ~ophWRP(void);
129 
130 public:
131  const vec3& getScale() { return wrp_config_.scale; }
132  const Real& getLocation() { return wrp_config_.wrp_location; }
133  const Real& getDistance() { return wrp_config_.propagation_distance; }
134  const int& getNumOfWRP() { return wrp_config_.num_wrp; }
135  const Real& getFieldLens() { return wrp_config_.fieldLength; }
136  void setScale(vec3 scale) { wrp_config_.scale = scale; }
137  void setLocation(Real location) { wrp_config_.wrp_location = location; }
138  void setDistance(Real distance) { wrp_config_.propagation_distance = distance; }
139  void autoScaling();
140  int getNumOfPoints() { return n_points; }
141 
149  virtual int loadPointCloud(const char* pc_file);
150 
158  virtual bool readConfig(const char* fname);
159 
160  void calculateWRPCPU(void);
161  void calculateWRPGPU(void);
162 
163 // virtual void fresnelPropagation(Complex<Real>* in, Complex<Real>* out, Real distance);
164 
169  void generateHologram(void);
174  Complex<Real>** calculateMWRP(void);
175 
176  inline Complex<Real>* getWRPBuff(void) { return p_wrp_; };
177 
187  void setViewingWindow(bool is_ViewingWindow);
188  uint* getProgress() { return &m_nProgress; }
189 
190 
195  inline Vertex* getPointCloudModel() { return obj_.vertices; }
200  inline ulonglong getNumberOfPoints() { return obj_.n_points; }
201 
202 protected:
203 
204 
205 private:
206 
207  Complex<Real>* calSubWRP(double d, Complex<Real>* wrp, OphPointCloudData* sobj);
208 
209  void addPixel2WRP(int x, int y, Complex<Real> temp);
210  void addPixel2WRP(int x, int y, Complex<Real> temp, Complex<Real>* wrp);
211 
212  virtual void ophFree(void);
213  inline Real transVW(Real pt) {
214  Real fieldLens = this->getFieldLens();
215  return -fieldLens * pt / (pt - fieldLens);
216  }
217 
218  void transVW(Real* dst, Real *src, int size);
219 protected:
220 
221  int n_points;
222 
224 
228 
229 private:
230  bool is_ViewingWindow;
231  Real zmax_;
232  uint m_nProgress;
233 
234 };
235 #endif
Vertex * scaledVertex
Definition: ophWRP.h:226
int getNumOfPoints()
Definition: ophWRP.h:140
ulonglong getNumberOfPoints()
Directly Get Basic Data.
Definition: ophWRP.h:200
const vec3 & getScale()
Definition: ophWRP.h:131
Configuration for WRP.
Definition: ophGen.h:655
void setLocation(Real location)
Definition: ophWRP.h:137
OphPointCloudData obj_
Input Pointcloud Data.
Definition: ophWRP.h:225
Definition: ophWRP.h:114
float Real
Definition: typedef.h:55
const int & getNumOfWRP()
Definition: ophWRP.h:134
unsigned long long ulonglong
Definition: typedef.h:67
Complex< Real > * getWRPBuff(void)
Definition: ophWRP.h:176
Complex< Real > * p_wrp_
wrp buffer - complex type
Definition: ophWRP.h:223
OphWRPConfig wrp_config_
structure variable for WRP hologram configuration
Definition: ophWRP.h:227
void setDistance(Real distance)
Definition: ophWRP.h:138
#define GEN_DLL
Definition: ophGen.h:61
Definition: struct.h:102
void setScale(vec3 scale)
Definition: ophWRP.h:136
structure for 3-dimensional Real type vector and its arithmetic.
Definition: vec.h:466
Vertex * getPointCloudModel()
Get point cloud vertex data.
Definition: ophWRP.h:195
int n_points
numbers of points
Definition: ophWRP.h:221
Data for Point Cloud.
Definition: ophGen.h:582
const Real & getLocation()
Definition: ophWRP.h:132
uint * getProgress()
Definition: ophWRP.h:188
Definition: Bitmap.h:49
const Real & getFieldLens()
Definition: ophWRP.h:135
unsigned int uint
Definition: typedef.h:62
Definition: ophGen.h:76
const Real & getDistance()
Definition: ophWRP.h:133