CudaSurface.hpp
Go to the documentation of this file.
1 
34 #ifndef __CudaSurface_H
35 #define __CudaSurface_H
36 
42 
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <iostream>
46 #include <fstream>
47 #include <sstream>
48 #include <vector>
49 #include <math.h>
50 #include <float.h>
51 #include <stdint.h>
52 
53 #include <cuda_runtime.h>
54 #include <driver_types.h>
55 
56 #include <boost/shared_array.hpp>
57 
58 namespace lvr2
59 {
60 
61 static void HandleError( cudaError_t err,
62  const char *file,
63  int line ) {
64  if (err != cudaSuccess) {
65  printf( "%s in %s at line %d\n", cudaGetErrorString( err ),
66  file, line );
67  exit( EXIT_FAILURE );
68  }
69 }
70 #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
71 
72 using Vec = BaseVector<float>;
73 typedef boost::shared_array<float> floatArr;
76 
77 
78 class CudaSurface {
79 
80 public:
86  CudaSurface(LBPointArray<float>& points, int device = 0);
87 
88  CudaSurface(floatArr& points, size_t num_points, int device=0 );
89 
90  ~CudaSurface();
91 
96  void calculateNormals();
97 
98  void interpolateNormals();
99 
105  void getNormals(LBPointArray<float>& output_normals);
106 
107  void getNormals(floatArr output_normals);
108 
116  void setKn(int kn);
117 
125  void setKi(int ki);
126 
134  void setKd(int kd);
135 
144  void setFlippoint(float v_x, float v_y, float v_z);
145 
152  void setMethod(std::string& method);
153 
158  void setReconstructionMode(bool mode = true);
159 
164  void distances(std::vector<QueryPoint<Vec> >& query_points, float voxel_size);
165 
166  void freeGPU();
167 
168 private:
169  //~ Hostfunctions
170  void init();
171 
172  void printSettings();
173 
174  void getCudaInformation(int device);
175 
176  void calculateBlocksThreads(int n, int elements, int element_size,
177  int max_mem_shared, int max_threads_per_block,
178  int& out_blocks_per_grid, int& out_threads_per_block, int& needed_shared_memory);
179 
180  template <typename T>
181  void generateDevicePointArray(LBPointArray<T>& D_m, int width, int dim);
182 
183  template <typename T>
185 
186  template <typename T>
188 
189 
191 
192  // Divice Function
193  void GPU_NN();
194 
195  void initKdTree();
196 
197  // V->points and normals
201 
203  boost::shared_ptr<LBKdTree> kd_tree_gen;
204 
205  float m_vx, m_vy, m_vz;
206  int m_k, m_ki, m_kd;
207 
208 
211 
212  // Device Information
213  int m_device;
214  int m_mps;
219  unsigned long long m_device_global_memory;
220 
225 
226 };
227 
228 } /* namespace lvr2 */
229 
230 #endif // !__CudaSurface_H
lvr2::floatArr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
LBKdTree.hpp
BaseVector.hpp
lvr2::CudaSurface::~CudaSurface
~CudaSurface()
lvr2::CudaSurface::m_reconstruction_mode
bool m_reconstruction_mode
Definition: CudaSurface.hpp:210
lvr2::CudaSurface::m_size_thread_block
int * m_size_thread_block
Definition: CudaSurface.hpp:217
lvr2::cVertex
ColorVertex< float, unsigned char > cVertex
Definition: CudaSurface.hpp:74
lvr2::CudaSurface::setReconstructionMode
void setReconstructionMode(bool mode=true)
lvr2::CudaSurface::CudaSurface
CudaSurface(LBPointArray< float > &points, int device=0)
Constructor.
lvr2::CudaSurface::printSettings
void printSettings()
lvr2::CudaSurface::interpolateNormals
void interpolateNormals()
LBPointArray.hpp
lvr2::QueryPointC
QueryPoint< Vec > QueryPointC
Definition: CudaSurface.hpp:75
lvr2::CudaSurface::m_threads_per_mp
int m_threads_per_mp
Definition: CudaSurface.hpp:215
lvr2::CudaSurface::m_mps
int m_mps
Definition: CudaSurface.hpp:214
lvr2::CudaSurface::getNormals
void getNormals(LBPointArray< float > &output_normals)
Get the resulting normals of the normal calculation. After calling "start".
lvr2::CudaSurface::calculateNormals
void calculateNormals()
Starts calculation the normals on GPU.
lvr2::CudaSurface::m_vz
float m_vz
Definition: CudaSurface.hpp:205
lvr2::CudaSurface::setKn
void setKn(int kn)
Set the number of k nearest neighbors k-neighborhood.
lvr2::CudaSurface::m_calc_method
int m_calc_method
Definition: CudaSurface.hpp:209
lvr2::CudaSurface::m_ki
int m_ki
Definition: CudaSurface.hpp:206
lvr2::CudaSurface
Definition: CudaSurface.hpp:78
ColorVertex.hpp
lvr2::CudaSurface::calculateBlocksThreads
void calculateBlocksThreads(int n, int elements, int element_size, int max_mem_shared, int max_threads_per_block, int &out_blocks_per_grid, int &out_threads_per_block, int &needed_shared_memory)
lvr2::CudaSurface::init
void init()
lvr2::CudaSurface::getCudaInformation
void getCudaInformation(int device)
lvr2::CudaSurface::D_Normals
LBPointArray< float > D_Normals
Definition: CudaSurface.hpp:224
lvr2::CudaSurface::m_vx
float m_vx
Definition: CudaSurface.hpp:205
lvr2::CudaSurface::kd_tree_values
LBPointArray< float > * kd_tree_values
Definition: CudaSurface.hpp:199
lvr2::CudaSurface::m_threads_per_block
int m_threads_per_block
Definition: CudaSurface.hpp:216
lvr2::CudaSurface::m_kd
int m_kd
Definition: CudaSurface.hpp:206
lvr2::CudaSurface::m_device
int m_device
Definition: CudaSurface.hpp:213
lvr2::CudaSurface::D_kd_tree_values
LBPointArray< float > D_kd_tree_values
Definition: CudaSurface.hpp:222
lvr2::CudaSurface::setKd
void setKd(int kd)
Set the number of k nearest neighbors k-neighborhood for distance.
lvr2::CudaSurface::m_k
int m_k
Definition: CudaSurface.hpp:206
Vec
BaseVector< float > Vec
Definition: src/tools/lvr2_cuda_normals/Main.cpp:57
lvr2::CudaSurface::setFlippoint
void setFlippoint(float v_x, float v_y, float v_z)
Set the viewpoint to orientate the normals.
lvr2::CudaSurface::m_size_grid
int * m_size_grid
Definition: CudaSurface.hpp:218
lvr2::CudaSurface::freeGPU
void freeGPU()
lvr2::CudaSurface::D_V
LBPointArray< float > D_V
Definition: CudaSurface.hpp:221
file
FILE * file
Definition: arithmeticencoder.cpp:77
QueryPoint.hpp
lvr2::QueryPoint
A query Vector for marching cubes reconstructions. It represents a Vector in space together with a 'd...
Definition: QueryPoint.hpp:48
lvr2::CudaSurface::m_vy
float m_vy
Definition: CudaSurface.hpp:205
lvr2::CudaSurface::copyToHostPointArray
void copyToHostPointArray(LBPointArray< float > &D_m, LBPointArray< float > *m)
lvr2::CudaSurface::GPU_NN
void GPU_NN()
lvr2::CudaSurface::setKi
void setKi(int ki)
Set the number of k nearest neighbors k-neighborhood for interpolation.
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::CudaSurface::D_kd_tree_splits
LBPointArray< unsigned char > D_kd_tree_splits
Definition: CudaSurface.hpp:223
lvr2::CudaSurface::setMethod
void setMethod(std::string &method)
Set Method for normal calculation.
lvr2::CudaSurface::Result_Normals
LBPointArray< float > Result_Normals
Definition: CudaSurface.hpp:202
lvr2::CudaSurface::kd_tree_gen
boost::shared_ptr< LBKdTree > kd_tree_gen
Definition: CudaSurface.hpp:203
lvr2::LBPointArray< float >
lvr2::CudaSurface::distances
void distances(std::vector< QueryPoint< Vec > > &query_points, float voxel_size)
lvr2::CudaSurface::initKdTree
void initKdTree()
lvr2::CudaSurface::copyToDevicePointArray
void copyToDevicePointArray(LBPointArray< T > *m, LBPointArray< T > &D_m)
lvr2::ColorVertex
A color vertex.
Definition: ColorVertex.hpp:50
lvr2::CudaSurface::m_device_global_memory
unsigned long long m_device_global_memory
Definition: CudaSurface.hpp:219
lvr2::CudaSurface::generateDevicePointArray
void generateDevicePointArray(LBPointArray< T > &D_m, int width, int dim)
lvr2::CudaSurface::V
LBPointArray< float > V
Definition: CudaSurface.hpp:198
lvr2::CudaSurface::kd_tree_splits
LBPointArray< unsigned char > * kd_tree_splits
Definition: CudaSurface.hpp:200
lvr2::HandleError
static void HandleError(cudaError_t err, const char *file, int line)
Definition: CudaSurface.hpp:61


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:23