Openholo  v1.0
Open Source Digital Holographic Library
ophPointCloud.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 __ophPointCloud_h
47 #define __ophPointCloud_h
48 
49 #define _USE_MATH_DEFINES
50 
51 #include "ophGen.h"
52 
53 //Build Option : Multi Core Processing (OpenMP)
54 #ifdef _OPENMP
55 #include <omp.h>
56 #endif
57 
58 /* Bitmap File Definition*/
59 #define OPH_Bitsperpixel 8 //24 // 3byte=24
60 #define OPH_Planes 1
61 #define OPH_Compression 0
62 #define OPH_Xpixelpermeter 0x130B //2835 , 72 DPI
63 #define OPH_Ypixelpermeter 0x130B //2835 , 72 DPI
64 #define OPH_Pixel 0xFF
65 
66 using namespace oph;
67 
71 
541 
549 {
550 public:
554  };
559  explicit ophPointCloud(void);
563  explicit ophPointCloud(const char*, const char* cfg_file);
564 protected:
568  virtual ~ophPointCloud(void);
569 
570 public:
571  inline void setScale(Real sx, Real sy, Real sz) { pc_config_.scale.v[0] = sx; pc_config_.scale.v[1] = sy; pc_config_.scale.v[2] = sz; }
572  inline void setOffsetDepth(Real offset_depth) { pc_config_.offset_depth = offset_depth; }
573  inline void setFilterShapeFlag(int8_t* fsf) { pc_config_.filter_shape_flag = fsf; }
574  inline void setFilterWidth(Real wx, Real wy) { pc_config_.filter_width.v[0] = wx; pc_config_.filter_width.v[1] = wy; }
575  inline void setFocalLength(Real lens_in, Real lens_out, Real lens_eye_piece) { pc_config_.focal_length_lens_in = lens_in; pc_config_.focal_length_lens_out = lens_out; pc_config_.focal_length_lens_eye_piece = lens_eye_piece; }
576  inline void setTiltAngle(Real ax, Real ay) { pc_config_.tilt_angle.v[0] = ax; pc_config_.tilt_angle.v[1] = ay; }
577 
578  inline void getScale(vec3& scale) { scale = pc_config_.scale; }
579  inline Real getOffsetDepth(void) { return pc_config_.offset_depth; }
580  inline int8_t* getFilterShapeFlag(void) { return pc_config_.filter_shape_flag; }
581  inline void getFilterWidth(vec2& filterwidth) { filterwidth = pc_config_.filter_width; }
582  inline void getFocalLength(Real* lens_in, Real* lens_out, Real* lens_eye_piece) {
583  if (lens_in != nullptr) *lens_in = pc_config_.focal_length_lens_in;
584  if (lens_out != nullptr) *lens_out = pc_config_.focal_length_lens_out;
585  if (lens_eye_piece != nullptr) *lens_eye_piece = pc_config_.focal_length_lens_eye_piece;
586  }
587  inline void getTiltAngle(vec2& tiltangle) { tiltangle = pc_config_.tilt_angle; }
588  inline Real** getVertex(void) { return &pc_data_.vertex; }
589  inline Real** getColorPC(void) { return &pc_data_.color; }
590  inline Real** getPhasePC(void) { return &pc_data_.phase; }
591  inline void setPointCloudModel(Real* vertex, Real* color, Real *phase) {
592  pc_data_.vertex = vertex;
593  pc_data_.color = color;
594  pc_data_.phase = phase;
595  }
596  inline void getPointCloudModel(Real *vertex, Real *color, Real *phase) {
597  getModelVertex(vertex);
598  getModelColor(color);
599  getModelPhase(phase);
600  }
601 
606  inline const Real* getModelVertex(Real *vertex) { vertex != NULL ? vertex = pc_data_.vertex : vertex; return pc_data_.vertex; }
611  inline const Real* getModelColor(Real *color) { color != NULL ? color = pc_data_.color : color; return pc_data_.color; }
616  inline const Real* getModelPhase(Real *phase) { phase != NULL ? phase = pc_data_.phase : phase; return pc_data_.phase; }
621  inline int getNumberOfPoints() { return n_points; }
626  inline Real getFieldLens(void) { return pc_config_.fieldLength; }
627 
628 public:
638  void setMode(bool is_CPU);
639 
651  int loadPointCloud(const char* pc_file);
652 
661  bool readConfig(const char* cfg_file);
662 
670  Real generateHologram(uint diff_flag = PC_DIFF_RS);
676  void encodeHologram(vec2 band_limit = vec2(0.8, 0.5), vec2 spectrum_shift = vec2(0.0, 0.5));
677 
678  virtual void encoding(unsigned int ENCODE_FLAG);
679  virtual void encoding(unsigned int ENCODE_FLAG, unsigned int SSB_PASSBAND);
680 
690  void setViewingWindow(bool is_ViewingWindow);
691 
697  uint* getPercent() { return &n_percent; }
698 private:
706  Real genCghPointCloudCPU(uint diff_flag);
707 
708  void diffractEncodedRS(uint channel, ivec2 pn, vec2 pp, vec2 ss, vec3 pc, Real k, Real amplitude, vec2 theta);
709  void diffractNotEncodedRS(uint channel, ivec2 pn, vec2 pp, vec2 ss, vec3 pc, Real k, Real amplitude, Real lambda);
710 
711  void diffractEncodedFrsn(void);
712  void diffractNotEncodedFrsn(uint channel, ivec2 pn, vec2 pp, vec2 ss, vec3 pc, Real k, Real amplitude, Real lambda);
713 
714  inline Real transVW(Real pt) {
715  Real fieldLens = this->getFieldLens();
716  return -fieldLens * pt / (pt - fieldLens);
717  }
718  void transVW(int nSize, Real *dst, Real *src);
719 
727  Real genCghPointCloudGPU(uint diff_flag);
728 
729  virtual void ophFree(void);
730 
731  bool is_CPU;
732  bool is_ViewingWindow;
733  int n_points;
734  uint n_percent;
735  OphPointCloudConfig pc_config_;
736  OphPointCloudData pc_data_;
737 };
738 
739 #endif // !__ophPointCloud_h
void setScale(Real sx, Real sy, Real sz)
void setFilterShapeFlag(int8_t *fsf)
void getScale(vec3 &scale)
Real getOffsetDepth(void)
void setTiltAngle(Real ax, Real ay)
void getTiltAngle(vec2 &tiltangle)
float Real
Definition: typedef.h:55
const Real * getModelColor(Real *color)
Directly Get Basic Data.
void setFocalLength(Real lens_in, Real lens_out, Real lens_eye_piece)
void setOffsetDepth(Real offset_depth)
Real ** getVertex(void)
void setFilterWidth(Real wx, Real wy)
uint * getPercent()
Get the value of a CGH progress status.
const Real * getModelPhase(Real *phase)
Directly Get Basic Data.
void getPointCloudModel(Real *vertex, Real *color, Real *phase)
void getFocalLength(Real *lens_in, Real *lens_out, Real *lens_eye_piece)
Real getFieldLens(void)
Directly Get Basic Data.
Openholo Point Cloud based Compter-generated holography.
#define GEN_DLL
Definition: ophGen.h:54
const Real * getModelVertex(Real *vertex)
Directly Get Basic Data.
int8_t * getFilterShapeFlag(void)
void setPointCloudModel(Real *vertex, Real *color, Real *phase)
Configuration for Point Cloud.
Definition: ophGen.h:396
int getNumberOfPoints()
Directly Get Basic Data.
Data for Point Cloud.
Definition: ophGen.h:427
Definition: Bitmap.h:49
Real ** getColorPC(void)
Real ** getPhasePC(void)
void getFilterWidth(vec2 &filterwidth)
unsigned int uint
Definition: typedef.h:62
Definition: ophGen.h:68