BigGrid.hpp
Go to the documentation of this file.
1 
28 /*
29  * BigGrid.hpp
30  *
31  * Created on: Jul 17, 2017
32  * Author: Isaak Mitschke
33  */
34 
35 #ifndef LAS_VEGAS_BIGGRID_HPP
36 #define LAS_VEGAS_BIGGRID_HPP
37 
39 #include "lvr2/io/DataStruct.hpp"
40 
41 #include <boost/archive/binary_iarchive.hpp>
42 #include <boost/archive/binary_oarchive.hpp>
43 #include <boost/iostreams/device/mapped_file.hpp>
44 #include <string>
45 #include <unordered_map>
46 #include <utility>
47 
48 #ifndef __APPLE__
49 #include <omp.h>
50 #endif
51 
52 
53 namespace lvr2
54 {
55 
56 using Vec = BaseVector<float>;
57 
58 struct CellInfo
59 {
60  CellInfo() : size(0), offset(0), inserted(0), dist_offset(0) {}
61  size_t size;
62  size_t offset;
63  size_t inserted;
64  size_t dist_offset;
65  size_t ix;
66  size_t iy;
67  size_t iz;
68 };
69 
70 template <typename BaseVecT>
71 class BigGrid
72 {
73  public:
79  BigGrid(std::vector<std::string> cloudPath, float voxelsize, float scale = 0, size_t bufferSize = 1024);
80 
87  BigGrid(float voxelsize,ScanProjectEditMarkPtr project, float scale = 0);
88 
89  BigGrid(std::string path);
90 
94  size_t size();
95 
99  size_t pointSize();
100 
108  size_t pointSize(int i, int j, int k);
109 
118  lvr2::floatArr points(int i, int j, int k, size_t& numPoints);
119 
131  lvr2::floatArr points(
132  float minx, float miny, float minz, float maxx, float maxy, float maxz, size_t& numPoints);
133 
134  lvr2::floatArr normals(
135  float minx, float miny, float minz, float maxx, float maxy, float maxz, size_t& numPoints);
136 
138  float minx, float miny, float minz, float maxx, float maxy, float maxz, size_t& numPoints);
149  size_t getSizeofBox(float minx, float miny, float minz, float maxx, float maxy, float maxz);
150 
151  void serialize(std::string path = "serinfo.ls");
152 
153  lvr2::floatArr getPointCloud(size_t& numPoints);
154 
155  BoundingBox<BaseVecT>& getBB() { return m_bb; }
156 
163  BoundingBox<BaseVecT>& getpartialBB() { return m_partialbb; }
164 
165 
166  virtual ~BigGrid();
167 
168  inline size_t hashValue(size_t i, size_t j, size_t k)
169  {
170  return i * m_maxIndexSquare + j * m_maxIndex + k;
171  }
172 
173  inline size_t getDistanceFileOffset(size_t hash)
174  {
175  if (exists(hash))
176  {
177  return m_gridNumPoints[hash].dist_offset;
178  }
179  else
180  return 0;
181  }
182  inline bool exists(size_t hash)
183  {
184  auto it = m_gridNumPoints.find(hash);
185  return it != m_gridNumPoints.end();
186  }
187 
188  inline bool hasColors() { return m_has_color; }
189  inline bool hasNormals() { return m_has_normal; }
190 
191  private:
192  inline int calcIndex(float f) { return f < 0 ? f - .5 : f + .5; }
193 
194  bool exists(int i, int j, int k);
195  void insert(float x, float y, float z);
196 
198  size_t m_maxIndex;
199  size_t m_maxIndexX;
200  size_t m_maxIndexY;
201  size_t m_maxIndexZ;
202  size_t m_numPoints;
203 
205 
206  float m_voxelSize;
207  bool m_extrude;
208 #ifdef LVR2_USE_OPEN_MP
209  omp_lock_t m_lock;
210 #endif
213 
214  boost::iostreams::mapped_file m_PointFile;
215  boost::iostreams::mapped_file m_NomralFile;
216  boost::iostreams::mapped_file m_ColorFile;
218 
219  //BoundingBox, of unreconstructed scans
221 
222  std::vector<shared_ptr<Scan>> m_scans;
223 
224  std::unordered_map<size_t, CellInfo> m_gridNumPoints;
225  float m_scale;
226 };
227 
228 } // namespace lvr2
229 
230 #include "lvr2/reconstruction/BigGrid.tcc"
231 
232 #endif // LAS_VEGAS_BIGGRID_HPP
bool exists(size_t hash)
Definition: BigGrid.hpp:182
size_t hashValue(size_t i, size_t j, size_t k)
Definition: BigGrid.hpp:168
Datastructures for holding loaded data.
BoundingBox< BaseVecT > m_bb
Definition: BigGrid.hpp:217
size_t inserted
Definition: BigGrid.hpp:63
bool hasNormals()
Definition: BigGrid.hpp:189
size_t m_pointBufferSize
Definition: BigGrid.hpp:204
BoundingBox< BaseVecT > & getBB()
Definition: BigGrid.hpp:155
bool hasColors()
Definition: BigGrid.hpp:188
size_t getDistanceFileOffset(size_t hash)
Definition: BigGrid.hpp:173
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
boost::iostreams::mapped_file m_ColorFile
Definition: BigGrid.hpp:216
size_t m_maxIndexX
Definition: BigGrid.hpp:199
float m_scale
Definition: BigGrid.hpp:225
std::unordered_map< size_t, CellInfo > m_gridNumPoints
Definition: BigGrid.hpp:224
size_t m_maxIndexSquare
Definition: BigGrid.hpp:197
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
bool m_has_normal
Definition: BigGrid.hpp:211
size_t m_maxIndexZ
Definition: BigGrid.hpp:201
std::vector< shared_ptr< Scan > > m_scans
Definition: BigGrid.hpp:222
size_t dist_offset
Definition: BigGrid.hpp:64
size_t m_maxIndexY
Definition: BigGrid.hpp:200
size_t offset
Definition: BigGrid.hpp:62
size_t size
Definition: BigGrid.hpp:61
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
bool m_has_color
Definition: BigGrid.hpp:212
std::shared_ptr< ScanProjectEditMark > ScanProjectEditMarkPtr
Definition: ScanTypes.hpp:357
float m_voxelSize
Definition: BigGrid.hpp:206
size_t m_maxIndex
Definition: BigGrid.hpp:198
BoundingBox< BaseVecT > & getpartialBB()
Definition: BigGrid.hpp:163
BoundingBox< BaseVecT > m_partialbb
Definition: BigGrid.hpp:220
size_t m_numPoints
Definition: BigGrid.hpp:202
BaseVector< float > Vec
boost::iostreams::mapped_file m_NomralFile
Definition: BigGrid.hpp:215
int calcIndex(float f)
Definition: BigGrid.hpp:192
bool m_extrude
Definition: BigGrid.hpp:207
boost::iostreams::mapped_file m_PointFile
Definition: BigGrid.hpp:214


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