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
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)
void calculateNormals()
Starts calculation the normals on GPU.
void setFlippoint(float v_x, float v_y, float v_z)
Set the viewpoint to orientate the normals.
LBPointArray< float > D_Normals
CudaSurface(LBPointArray< float > &points, int device=0)
Constructor.
LBPointArray< float > D_kd_tree_values
unsigned long long m_device_global_memory
QueryPoint< Vec > QueryPointC
Definition: CudaSurface.hpp:75
void setKd(int kd)
Set the number of k nearest neighbors k-neighborhood for distance.
void getCudaInformation(int device)
static void HandleError(cudaError_t err, const char *file, int line)
Definition: CudaSurface.hpp:61
void interpolateNormals()
LBPointArray< float > * kd_tree_values
ColorVertex< float, unsigned char > cVertex
Definition: CudaSurface.hpp:74
LBPointArray< unsigned char > * kd_tree_splits
LBPointArray< unsigned char > D_kd_tree_splits
void setReconstructionMode(bool mode=true)
A query Vector for marching cubes reconstructions. It represents a Vector in space together with a &#39;d...
Definition: QueryPoint.hpp:48
A color vertex.
Definition: ColorVertex.hpp:50
void setKn(int kn)
Set the number of k nearest neighbors k-neighborhood.
void getNormals(LBPointArray< float > &output_normals)
Get the resulting normals of the normal calculation. After calling "start".
void setKi(int ki)
Set the number of k nearest neighbors k-neighborhood for interpolation.
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
void distances(std::vector< QueryPoint< Vec > > &query_points, float voxel_size)
LBPointArray< float > V
FILE * file
LBPointArray< float > D_V
LBPointArray< float > Result_Normals
void copyToDevicePointArray(LBPointArray< T > *m, LBPointArray< T > &D_m)
void setMethod(std::string &method)
Set Method for normal calculation.
BaseVector< float > Vec
boost::shared_ptr< LBKdTree > kd_tree_gen
void generateDevicePointArray(LBPointArray< T > &D_m, int width, int dim)
void copyToHostPointArray(LBPointArray< float > &D_m, LBPointArray< float > *m)


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 Mon Feb 28 2022 22:46:06