GridIO.cpp
Go to the documentation of this file.
1 
35 #include "lvr2/io/GridIO.hpp"
36 #include "lvr2/io/DataStruct.hpp"
37 
38 #include <fstream>
39 using std::ifstream;
40 
41 namespace lvr2
42 {
43 
45 {
46  // TODO Auto-generated constructor stub
47 
48 }
49 
50 void GridIO::read( std::string filename )
51 {
52  ifstream in(filename.c_str());
53 
54  if(in.good())
55  {
56  size_t n_points;
57  size_t n_cells;
58  float voxelsize;
59 
60  // Read header
61  in >> n_points >> voxelsize >> n_cells;
62 
63  // Alloc and read points
64  m_points = floatArr( new float[4 * n_points] );
65  m_numPoints = n_points;
66  for(size_t i = 0; i < n_points; i++)
67  {
68  in >> m_points[i * 4] >> m_points[i * 4 + 1] >> m_points[i * 4 + 2] >> m_points[i * 4 + 3];
69  }
70 
71  // Alloc and read box indices
72  m_boxes = uintArr( new unsigned int[8 * n_cells] );
73  m_numBoxes = n_cells;
74  for(size_t i = 0; i < n_cells; i++)
75  {
76  size_t pos = i * 8;
77  for(size_t j = 0; j < 8; j++)
78  {
79  in >> m_boxes[pos + j];
80  }
81  }
82 
83  }
84 }
85 
86 
88 {
89  n = m_numPoints;
90  return m_points;
91 }
92 
93 
95 {
96  n = m_numBoxes;
97  return m_boxes;
98 }
99 
100 
102 {
103  // TODO Auto-generated destructor stub
104 }
105 
106 } /* namespace lvr2 */
floatArr getPoints(size_t &n)
Definition: GridIO.cpp:87
Datastructures for holding loaded data.
boost::shared_array< unsigned int > uintArr
Definition: DataStruct.hpp:130
size_t m_numPoints
Definition: GridIO.hpp:58
size_t m_numBoxes
Definition: GridIO.hpp:59
void read(std::string filename)
Definition: GridIO.cpp:50
floatArr m_points
Definition: GridIO.hpp:56
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
uintArr m_boxes
Definition: GridIO.hpp:57
uintArr getBoxes(size_t &n)
Definition: GridIO.cpp:94
virtual ~GridIO()
Definition: GridIO.cpp:101


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