52 , scaledVertex(nullptr)
58 is_ViewingWindow =
false;
59 LOG(
"*** WRP : BUILD DATE: %s %s ***\n\n", __DATE__, __TIME__);
68 this->is_ViewingWindow = is_ViewingWindow;
73 LOG(
"%s : ", __FUNCTION__);
81 Real size = pnY * ppY * 0.8 / 2.0;
105 Real x_max, y_max, z_max;
115 Real maxXY = (x_max > y_max) ? x_max : y_max;
151 LOG(
"<FAILED> Wrong file ext.\n");
156 LOG(
"<FAILED> Loading file.\n");
161 char szNodeName[32] = { 0, };
163 sprintf(szNodeName,
"FieldLength");
167 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
171 sprintf(szNodeName,
"ScaleX");
175 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
178 sprintf(szNodeName,
"ScaleY");
182 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
185 sprintf(szNodeName,
"ScaleZ");
189 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
192 sprintf(szNodeName,
"Distance");
196 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
199 sprintf(szNodeName,
"LocationOfWRP");
203 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
206 sprintf(szNodeName,
"NumOfWRP");
210 LOG(
"<FAILED> Not found node : \'%s\' (Integer) \n", szNodeName);
216 LOG(
"**************************************************\n");
217 LOG(
" Read Config (WRP) \n");
221 LOG(
"**************************************************\n");
231 if (x >= 0 && x < (
int)pnX && y >= 0 && y < (
int)pnY) {
232 uint adr = x + y * pnX;
245 if (x >= 0 && x < Nx && y >= 0 && y < Ny) {
246 long long int adr = x + y*Nx;
247 wrp[adr] += temp[adr];
271 #pragma omp parallel for firstprivate(wrp_d, wpx, wpy, Nx_h, Ny_h, wave_num, wave_len) 273 for (
int k = 0; k < num; k++) {
283 float dz = wrp_d - z;
285 float tw = fabs(dz)*wave_len / wpx / wpx / 2;
289 int tx = (int)(x / wpx) + Nx_h;
290 int ty = (int)(y / wpy) + Ny_h;
292 printf(
"num=%d, tx=%d, ty=%d, w=%d\n", k, tx, ty,
w);
294 for (
int wy = -
w; wy <
w; wy++) {
295 for (
int wx = -
w; wx<
w; wx++) {
299 double dz = wrp_d - z;
301 double sign = (dz>0.0) ? (1.0) : (-1.0);
302 double r = sign*sqrt(dx*dx + dy*dy + dz*dz);
307 tmp[
_RE] = (amplitude*cosf(wave_num*r)*cosf(wave_num*wave_len*
rand(0, 1))) / (r + 0.05);
308 tmp[
_IM] = (-amplitude*sinf(wave_num*r)*sinf(wave_num*wave_len*
rand(0, 1))) / (r + 0.05);
310 if (tx + wx >= 0 && tx + wx < Nx && ty + wy >= 0 && ty + wy < Ny)
312 addPixel2WRP(wx + tx, wy + ty, tmp, wrp);
323 LOG(
"%s\n", __FUNCTION__);
330 const long long int N = pnX * pnY;
350 Real ppXX = ppX * ppX * 2;
352 Real dz = wrp_d - zmax_;
357 for (
uint ch = 0; ch < nChannel; ch++)
364 #pragma omp parallel for firstprivate(iColor, ppXX, pnX, pnY, ppX, ppY, hpnX, hpnY, wrp_d, k, pi2, dz, dzz) 378 bool sign = (dz > 0.0) ?
true :
false;
380 Real tw = fabs(lambda * dz / ppXX) * 2;
384 int tx = (int)(x / ppX) + hpnX;
385 int ty = (int)(y / ppY) + hpnY;
387 for (
int wy = -
w; wy <
w; wy++)
392 int baseY = tmpY * pnX;
394 for (
int wx = -
w; wx <
w; wx++)
397 if (tmpX >= 0 && tmpX < pnX && tmpY >= 0 && tmpY < pnY) {
398 uint adr = tmpX + baseY;
401 Real r = sign ? sqrt(dx * dx + dyy + dzz) : -sqrt(dx * dx + dyy + dzz);
403 Real randVal = bRandomPhase ?
rand(0.0, 1.0) : 1.0;
404 Real randpi2 = pi2 * randVal;
406 tmp[
_RE] = (amplitude * cos(kr) * cos(randpi2)) / r;
407 tmp[
_IM] = (-amplitude * sin(kr) * sin(randpi2)) / r;
442 LOG(
"**************************************************\n");
443 LOG(
" Generate Hologram \n");
444 LOG(
"1) Algorithm Method : WRP\n");
454 LOG(
"4) Number of Point Cloud : %d\n",
n_points);
455 LOG(
"5) Precision Level : %s\n",
m_mode &
MODE_FLOAT ?
"Single" :
"Double");
458 LOG(
"**************************************************\n");
484 for (
int i = 0; i < wrp_num; i++)
493 void ophWRP::ophFree(
void)
503 void ophWRP::transVW(
Real* dst,
Real* src,
int size)
506 for (
int i = 0; i < size; i++) {
507 dst[i] = (-fieldLens * src[i]) / (src[i] - fieldLens);
void fftFree(void)
Resource release method.
Real fieldLength
fieldLength variable for viewing window.
OphPointCloudData obj_
Input Pointcloud Data.
void initialize(void)
Initialize variables for Hologram complex field, encoded data, normalized data.
void setViewingWindow(bool is_ViewingWindow)
Set the value of a variable is_ViewingWindow(true or false)
int num_wrp
Number of wavefront recording plane(WRP)
bool checkExtension(const char *fname, const char *ext)
Functions for extension checking.
bool GetRandomPhase()
Function for getting the random phase.
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
virtual bool readConfig(const char *fname)
load to configuration file.
vec3 scale
Scaling factor of coordinate of point cloud.
virtual int loadPointCloud(const char *pc_file)
load to point cloud data.
Real wrp_location
Location distance of WRP.
void Fresnel_FFT(Complex< Real > *src, Complex< Real > *dst, Real lambda, Real distance)
Fresnel-fft method.
OphWRPConfig wrp_config_
structure variable for WRP hologram configuration
void calculateWRPCPU(void)
virtual ~ophWRP(void)
Destructor.
#define ELAPSED_TIME(x, y)
structure for 3-dimensional Real type vector and its arithmetic.
int n_colors
Number of color channel.
Vertex * vertices
Data of point clouds.
bool readConfig(const char *fname)
load to configuration file.
Complex< Real > * p_wrp_
wrp buffer - complex type
XMLError LoadFile(const char *filename)
Real rand(const Real min, const Real max, oph::ulong _SEED_VALUE=0)
Get random Real value from min to max.
int n_points
numbers of points
void calculateWRPGPU(void)
Real propagation_distance
Distance of Hologram plane.
void resetBuffer()
reset buffer
Complex< Real > ** complex_H
int loadPointCloud(const char *pc_file, OphPointCloudData *pc_data_)
load to point cloud data.
const XMLElement * FirstChildElement(const char *name=0) const
const Real & getFieldLens()
virtual void ophFree(void)
Pure virtual function for override in child classes.
void generateHologram(void)
Generate a hologram, main funtion.
Complex< Real > ** calculateMWRP(void)
Generate multiple wavefront recording planes, main funtion.