Openholo  v4.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 
50 #include "ophGen.h"
51 
52 //Build Option : Multi Core Processing (OpenMP)
53 #ifdef _OPENMP
54 #include <omp.h>
55 #endif
56 
57 /* Bitmap File Definition*/
58 #define OPH_Bitsperpixel 8 //24 // 3byte=24
59 #define OPH_Planes 1
60 #define OPH_Compression 0
61 #define OPH_Xpixelpermeter 0x130B //2835 , 72 DPI
62 #define OPH_Ypixelpermeter 0x130B //2835 , 72 DPI
63 #define OPH_Pixel 0xFF
64 
65 using namespace oph;
66 
70 
540 
548 {
549 public:
553  };
558  explicit ophPointCloud(void);
562  explicit ophPointCloud(const char*, const char* cfg_file);
563 protected:
567  virtual ~ophPointCloud(void);
568 
569 public:
570  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; }
571  inline void setDistance(Real distance) { pc_config_.distance = distance; }
572  inline void setFilterShapeFlag(int8_t* fsf) { pc_config_.filter_shape_flag = fsf; }
573  inline void setFilterWidth(Real wx, Real wy) { pc_config_.filter_width.v[0] = wx; pc_config_.filter_width.v[1] = wy; }
574  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; }
575  inline void setTiltAngle(Real ax, Real ay) { pc_config_.tilt_angle.v[0] = ax; pc_config_.tilt_angle.v[1] = ay; }
576 
577  inline void setPointCloudModel(Vertex* vertex)
578  {
579  if (pc_data_.n_points < 1) return;
580  pc_data_.vertices = new Vertex[pc_data_.n_points];
581  memcpy(pc_data_.vertices, vertex, sizeof(Vertex) * pc_data_.n_points);
582  }
583 
584  inline void setNumberOfPoints(ulonglong n_points) { pc_data_.n_points = n_points; }
585 
586  inline void getScale(vec3& scale) { scale = pc_config_.scale; }
587  inline Real getDistance(void) { return pc_config_.distance; }
588  inline int8_t* getFilterShapeFlag(void) { return pc_config_.filter_shape_flag; }
589  inline void getFilterWidth(vec2& filterwidth) { filterwidth = pc_config_.filter_width; }
590  inline void getFocalLength(Real* lens_in, Real* lens_out, Real* lens_eye_piece) {
591  if (lens_in != nullptr) *lens_in = pc_config_.focal_length_lens_in;
592  if (lens_out != nullptr) *lens_out = pc_config_.focal_length_lens_out;
593  if (lens_eye_piece != nullptr) *lens_eye_piece = pc_config_.focal_length_lens_eye_piece;
594  }
595  inline void getTiltAngle(vec2& tiltangle) { tiltangle = pc_config_.tilt_angle; }
596 
597 
602  inline Vertex* getPointCloudModel() { return pc_data_.vertices; }
607  inline ulonglong getNumberOfPoints() { return pc_data_.n_points; }
608 
609 public:
621  bool isCPU() { return m_mode & MODE_GPU ? false : true; }
622 
628  int loadPointCloud(const char* pc_file);
629 
637  bool readConfig(const char* cfg_file);
638 
646  Real generateHologram(uint diff_flag = PC_DIFF_RS);
652  void encodeHologram(vec2 band_limit = vec2(0.8, 0.5), vec2 spectrum_shift = vec2(0.0, 0.5));
653 
654  virtual void encoding(unsigned int ENCODE_FLAG, unsigned int SSB_PASSBAND);
655  virtual void encoding(unsigned int ENCODE_FLAG);
656 
666  void setViewingWindow(bool is_ViewingWindow);
667 
673  uint* getProgress() { return &m_nProgress; }
674 private:
681  void genCghPointCloudCPU(uint diff_flag);
682 
689  void genCghPointCloudGPU(uint diff_flag);
690  void ophFree(void);
691 
692  bool is_ViewingWindow;
693  uint m_nProgress;
694  OphPointCloudConfig pc_config_;
695  OphPointCloudData pc_data_;
696 };
697 
698 #endif // !__ophPointCloud_h
void setScale(Real sx, Real sy, Real sz)
void setFilterShapeFlag(int8_t *fsf)
void getScale(vec3 &scale)
void setPointCloudModel(Vertex *vertex)
#define MODE_GPU
Definition: define.h:156
void setTiltAngle(Real ax, Real ay)
void getTiltAngle(vec2 &tiltangle)
float Real
Definition: typedef.h:55
void setDistance(Real distance)
void setFocalLength(Real lens_in, Real lens_out, Real lens_eye_piece)
void setNumberOfPoints(ulonglong n_points)
void setFilterWidth(Real wx, Real wy)
unsigned long long ulonglong
Definition: typedef.h:67
Real getDistance(void)
void getFocalLength(Real *lens_in, Real *lens_out, Real *lens_eye_piece)
Openholo Point Cloud based Compter-generated holography.
#define GEN_DLL
Definition: ophGen.h:61
structure for 2-dimensional Real type vector and its arithmetic.
Definition: vec.h:66
Definition: struct.h:102
structure for 3-dimensional Real type vector and its arithmetic.
Definition: vec.h:466
int8_t * getFilterShapeFlag(void)
Configuration for Point Cloud.
Definition: ophGen.h:556
Data for Point Cloud.
Definition: ophGen.h:583
ulonglong getNumberOfPoints()
Directly Get Basic Data.
Definition: Bitmap.h:49
void getFilterWidth(vec2 &filterwidth)
unsigned int uint
Definition: typedef.h:62
uint * getProgress()
Get the value of a CGH progress status.
Vertex * getPointCloudModel()
Get point cloud vertex data.
Definition: ophGen.h:76
bool isCPU()
get the value of a variable generation mode (true or false)