52 , scaledVertex(nullptr)
56 is_ViewingWindow =
false;
57 LOG(
"*** WRP : BUILD DATE: %s %s ***\n\n", __DATE__, __TIME__);
66 this->is_ViewingWindow = is_ViewingWindow;
71 LOG(
"%s : ", __FUNCTION__);
79 Real size = pnY * ppY * 0.8 / 2.0;
103 Real x_max, y_max, z_max;
113 Real maxXY = (x_max > y_max) ? x_max : y_max;
149 LOG(
"<FAILED> Wrong file ext.\n");
154 LOG(
"<FAILED> Loading file.\n");
159 char szNodeName[32] = { 0, };
161 sprintf(szNodeName,
"FieldLength");
165 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
169 sprintf(szNodeName,
"ScaleX");
173 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
176 sprintf(szNodeName,
"ScaleY");
180 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
183 sprintf(szNodeName,
"ScaleZ");
187 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
190 sprintf(szNodeName,
"Distance");
194 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
197 sprintf(szNodeName,
"LocationOfWRP");
201 LOG(
"<FAILED> Not found node : \'%s\' (Double) \n", szNodeName);
204 sprintf(szNodeName,
"NumOfWRP");
208 LOG(
"<FAILED> Not found node : \'%s\' (Integer) \n", szNodeName);
214 LOG(
"**************************************************\n");
215 LOG(
" Read Config (WRP) \n");
219 LOG(
"**************************************************\n");
229 if (x >= 0 && x < (
int)pnX && y >= 0 && y < (
int)pnY) {
230 uint adr = x + y * pnX;
243 if (x >= 0 && x < Nx && y >= 0 && y < Ny) {
244 long long int adr = x + y*Nx;
245 wrp[adr] += temp[adr];
269 #pragma omp parallel for firstprivate(wrp_d, wpx, wpy, Nx_h, Ny_h, wave_num, wave_len) 271 for (
int k = 0;
k < num;
k++) {
281 float dz = wrp_d - z;
283 float tw = fabs(dz)*wave_len / wpx / wpx / 2;
287 int tx = (int)(x / wpx) + Nx_h;
288 int ty = (int)(y / wpy) + Ny_h;
290 printf(
"num=%d, tx=%d, ty=%d, w=%d\n",
k, tx, ty,
w);
292 for (
int wy = -
w; wy <
w; wy++) {
293 for (
int wx = -
w; wx<
w; wx++) {
297 double dz = wrp_d - z;
299 double sign = (dz>0.0) ? (1.0) : (-1.0);
300 double r = sign*sqrt(dx*dx + dy*dy + dz*dz);
305 tmp[
_RE] = (amplitude*cosf(wave_num*r)*cosf(wave_num*wave_len*
rand(0, 1))) / (r + 0.05);
306 tmp[
_IM] = (-amplitude*sinf(wave_num*r)*sinf(wave_num*wave_len*
rand(0, 1))) / (r + 0.05);
308 if (tx + wx >= 0 && tx + wx < Nx && ty + wy >= 0 && ty + wy < Ny)
310 addPixel2WRP(wx + tx, wy + ty, tmp, wrp);
321 LOG(
"%s\n", __FUNCTION__);
328 const long long int N = pnX * pnY;
348 Real ppXX = ppX * ppX * 2;
350 Real dz = wrp_d - zmax_;
355 for (
uint ch = 0; ch < nChannel; ch++)
362 #pragma omp parallel for firstprivate(iColor, ppXX, pnX, pnY, ppX, ppY, hpnX, hpnY, wrp_d, k, pi2, dz, dzz) 376 bool sign = (dz > 0.0) ?
true :
false;
378 Real tw = fabs(lambda * dz / ppXX) * 2;
382 int tx = (int)(x / ppX) + hpnX;
383 int ty = (int)(y / ppY) + hpnY;
385 for (
int wy = -
w; wy <
w; wy++)
390 int baseY = tmpY * pnX;
392 for (
int wx = -
w; wx <
w; wx++)
395 if (tmpX >= 0 && tmpX < pnX && tmpY >= 0 && tmpY < pnY) {
396 uint adr = tmpX + baseY;
399 Real r = sign ? sqrt(dx * dx + dyy + dzz) : -sqrt(dx * dx + dyy + dzz);
401 Real randVal = bRandomPhase ?
rand(0.0, 1.0) : 1.0;
402 Real randpi2 = pi2 * randVal;
404 tmp[
_RE] = (amplitude * cos(kr) * cos(randpi2)) / r;
405 tmp[
_IM] = (-amplitude * sin(kr) * sin(randpi2)) / r;
439 LOG(
"**************************************************\n");
440 LOG(
" Generate Hologram \n");
441 LOG(
"1) Algorithm Method : WRP\n");
451 LOG(
"4) Number of Point Cloud : %d\n",
n_points);
452 LOG(
"5) Precision Level : %s\n",
m_mode &
MODE_FLOAT ?
"Single" :
"Double");
455 LOG(
"**************************************************\n");
481 for (
int i = 0; i < wrp_num; i++)
490 void ophWRP::ophFree(
void)
498 void ophWRP::transVW(
Real* dst,
Real* src,
int size)
501 for (
int i = 0; i < size; i++) {
502 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.
Complex< Real > * p_wrp_
wrp buffer - complex type
OphWRPConfig wrp_config_
structure variable for WRP hologram configuration
void calculateWRPCPU(void)
void fresnelPropagation(OphConfig context, Complex< Real > *in, Complex< Real > *out, Real distance)
Fresnel propagation.
virtual ~ophWRP(void)
Destructor.
structure for 3-dimensional Real type vector and its arithmetic.
int n_colors
Number of color channel.
bool readConfig(const char *fname)
load to configuration file.
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
Vertex * vertices
Data of point clouds.
Complex< Real > ** complex_H
void calculateWRPGPU(void)
Real propagation_distance
Distance of Hologram plane.
void resetBuffer()
reset buffer
#define ELAPSED_TIME(x, y)
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()
void generateHologram(void)
Generate a hologram, main funtion.
Complex< Real > ** calculateMWRP(void)
Generate multiple wavefront recording planes, main funtion.