Openholo  v2.1
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 setDistance(Real distance) { pc_config_.distance = distance; }
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 getDistance(void) { return pc_config_.distance; }
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; }
625  inline void setNumberOfPoints(int nPoint) { n_points = nPoint; }
626 
627 public:
639  bool isCPU() { return m_mode & MODE_GPU ? false : true; }
640 
652  int loadPointCloud(const char* pc_file);
653 
662  bool readConfig(const char* cfg_file);
663 
671  Real generateHologram(uint diff_flag = PC_DIFF_RS);
677  void encodeHologram(vec2 band_limit = vec2(0.8, 0.5), vec2 spectrum_shift = vec2(0.0, 0.5));
678 
679  virtual void encoding(unsigned int ENCODE_FLAG);
680  virtual void encoding(unsigned int ENCODE_FLAG, unsigned int SSB_PASSBAND);
681 
691  void setViewingWindow(bool is_ViewingWindow);
692 
698  uint* getProgress() { return &m_nProgress; }
699 
700  //int AddPoint(vec3 vertex) { points.push_back(vertex); }
701 
702 private:
710  Real genCghPointCloudCPU(uint diff_flag);
711 
712  void diffractEncodedRS(uint channel, ivec2 pn, vec2 pp, vec2 ss, vec3 pc, Real k, Real amplitude, vec2 theta);
713  void diffractNotEncodedRS(uint channel, ivec2 pn, vec2 pp, vec2 ss, vec3 pc, Real k, Real amplitude, Real lambda);
714 
715  void diffractNotEncodedFrsn(uint channel, ivec2 pn, vec2 pp, vec2 ss, vec3 pc, Real k, Real amplitude, Real lambda);
716 
717 
725  Real genCghPointCloudGPU(uint diff_flag);
726 
727  virtual void ophFree(void);
728 
729  bool is_ViewingWindow;
730  int n_points;
731  uint m_nProgress;
732  OphPointCloudConfig pc_config_;
733  OphPointCloudData pc_data_;
734 };
735 
736 #endif // !__ophPointCloud_h
void setScale(Real sx, Real sy, Real sz)
void setFilterShapeFlag(int8_t *fsf)
void getScale(vec3 &scale)
#define GEN_DLL
Definition: ophGen.h:54
void setTiltAngle(Real ax, Real ay)
void getTiltAngle(vec2 &tiltangle)
const Real * getModelColor(Real *color)
Directly Get Basic Data.
void setDistance(Real distance)
void setFocalLength(Real lens_in, Real lens_out, Real lens_eye_piece)
Real ** getVertex(void)
void setFilterWidth(Real wx, Real wy)
def k(wvl)
Definition: Depthmap.py:16
const Real * getModelPhase(Real *phase)
Directly Get Basic Data.
void getPointCloudModel(Real *vertex, Real *color, Real *phase)
Real getDistance(void)
void getFocalLength(Real *lens_in, Real *lens_out, Real *lens_eye_piece)
#define false
Definition: tmwtypes.h:800
Openholo Point Cloud based Compter-generated holography.
const Real * getModelVertex(Real *vertex)
Directly Get Basic Data.
__managed__ float amplitude
Definition: ophPAS_GPU.cpp:28
int8_t * getFilterShapeFlag(void)
void setPointCloudModel(Real *vertex, Real *color, Real *phase)
#define MODE_GPU
Definition: define.h:140
Configuration for Point Cloud.
Definition: ophGen.h:522
int getNumberOfPoints()
Directly Get Basic Data.
Data for Point Cloud.
Definition: ophGen.h:549
float Real
Definition: typedef.h:55
Definition: Bitmap.h:49
void setNumberOfPoints(int nPoint)
Directly Set Basic Data.
Real ** getColorPC(void)
Real ** getPhasePC(void)
void getFilterWidth(vec2 &filterwidth)
unsigned int uint
Definition: typedef.h:62
uint * getProgress()
Get the value of a CGH progress status.
Definition: ophGen.h:68
bool isCPU()
get the value of a variable generation mode (true or false)