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 
132  float minx, float miny, float minz, float maxx, float maxy, float maxz, size_t& numPoints);
133 
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 
156 
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
lvr2::floatArr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
lvr2::CellInfo::CellInfo
CellInfo()
Definition: BigGrid.hpp:60
lvr2::ScanProjectEditMarkPtr
std::shared_ptr< ScanProjectEditMark > ScanProjectEditMarkPtr
Definition: ScanTypes.hpp:357
lvr2::BigGrid::normals
lvr2::floatArr normals(float minx, float miny, float minz, float maxx, float maxy, float maxz, size_t &numPoints)
lvr2::BigGrid::m_ColorFile
boost::iostreams::mapped_file m_ColorFile
Definition: BigGrid.hpp:216
lvr2::CellInfo
Definition: BigGrid.hpp:58
lvr2::BigGrid::m_numPoints
size_t m_numPoints
Definition: BigGrid.hpp:202
lvr2::BigGrid::~BigGrid
virtual ~BigGrid()
lvr2::BigGrid::getDistanceFileOffset
size_t getDistanceFileOffset(size_t hash)
Definition: BigGrid.hpp:173
lvr2::BigGrid::m_extrude
bool m_extrude
Definition: BigGrid.hpp:207
lvr2::BigGrid::serialize
void serialize(std::string path="serinfo.ls")
lvr2::CellInfo::iy
size_t iy
Definition: BigGrid.hpp:66
lvr2::BigGrid::hasColors
bool hasColors()
Definition: BigGrid.hpp:188
lvr2::BigGrid::insert
void insert(float x, float y, float z)
lvr2::BigGrid::m_maxIndexSquare
size_t m_maxIndexSquare
Definition: BigGrid.hpp:197
lvr2::BigGrid::hasNormals
bool hasNormals()
Definition: BigGrid.hpp:189
lvr2::BigGrid::getpartialBB
BoundingBox< BaseVecT > & getpartialBB()
Definition: BigGrid.hpp:163
lvr2::BigGrid::m_scans
std::vector< shared_ptr< Scan > > m_scans
Definition: BigGrid.hpp:222
lvr2::BigGrid::m_bb
BoundingBox< BaseVecT > m_bb
Definition: BigGrid.hpp:217
lvr2::CellInfo::dist_offset
size_t dist_offset
Definition: BigGrid.hpp:64
lvr2::BigGrid::getSizeofBox
size_t getSizeofBox(float minx, float miny, float minz, float maxx, float maxy, float maxz)
lvr2::BigGrid::colors
lvr2::ucharArr colors(float minx, float miny, float minz, float maxx, float maxy, float maxz, size_t &numPoints)
lvr2::BigGrid::m_PointFile
boost::iostreams::mapped_file m_PointFile
Definition: BigGrid.hpp:214
lvr2::CellInfo::size
size_t size
Definition: BigGrid.hpp:61
lvr2::BigGrid::m_NomralFile
boost::iostreams::mapped_file m_NomralFile
Definition: BigGrid.hpp:215
DataStruct.hpp
Datastructures for holding loaded data.
lvr2::CellInfo::iz
size_t iz
Definition: BigGrid.hpp:67
lvr2::BigGrid::calcIndex
int calcIndex(float f)
Definition: BigGrid.hpp:192
lvr2::BigGrid::pointSize
size_t pointSize()
Vec
BaseVector< float > Vec
Definition: src/tools/lvr2_cuda_normals/Main.cpp:57
lvr2::BigGrid::m_has_normal
bool m_has_normal
Definition: BigGrid.hpp:211
lvr2::BigGrid::m_partialbb
BoundingBox< BaseVecT > m_partialbb
Definition: BigGrid.hpp:220
lvr2::BigGrid::m_has_color
bool m_has_color
Definition: BigGrid.hpp:212
lvr2::BigGrid::m_maxIndexX
size_t m_maxIndexX
Definition: BigGrid.hpp:199
lvr2::BigGrid::m_scale
float m_scale
Definition: BigGrid.hpp:225
lvr2::BigGrid::m_maxIndexY
size_t m_maxIndexY
Definition: BigGrid.hpp:200
lvr2::BigGrid::points
lvr2::floatArr points(int i, int j, int k, size_t &numPoints)
lvr2::BigGrid::m_gridNumPoints
std::unordered_map< size_t, CellInfo > m_gridNumPoints
Definition: BigGrid.hpp:224
lvr2::BigGrid::size
size_t size()
lvr2::CellInfo::offset
size_t offset
Definition: BigGrid.hpp:62
lvr2::BoundingBox
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
lvr2::BigGrid::exists
bool exists(size_t hash)
Definition: BigGrid.hpp:182
lvr2::BigGrid::getPointCloud
lvr2::floatArr getPointCloud(size_t &numPoints)
lvr2::ucharArr
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
lvr2::BigGrid::m_maxIndexZ
size_t m_maxIndexZ
Definition: BigGrid.hpp:201
lvr2::CellInfo::ix
size_t ix
Definition: BigGrid.hpp:65
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::BigGrid::hashValue
size_t hashValue(size_t i, size_t j, size_t k)
Definition: BigGrid.hpp:168
lvr2::BigGrid::BigGrid
BigGrid(std::vector< std::string > cloudPath, float voxelsize, float scale=0, size_t bufferSize=1024)
lvr2::BigGrid::m_maxIndex
size_t m_maxIndex
Definition: BigGrid.hpp:198
lvr2::BigGrid::m_pointBufferSize
size_t m_pointBufferSize
Definition: BigGrid.hpp:204
lvr2::BigGrid
Definition: BigGrid.hpp:71
lvr2::BigGrid::getBB
BoundingBox< BaseVecT > & getBB()
Definition: BigGrid.hpp:155
lvr2::CellInfo::inserted
size_t inserted
Definition: BigGrid.hpp:63
BoundingBox.hpp
lvr2::BigGrid::m_voxelSize
float m_voxelSize
Definition: BigGrid.hpp:206


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:22