NodeData.hpp
Go to the documentation of this file.
1 
28 /*
29  * NodeData.hpp
30  *
31  * Created on: Dec 11, 2015
32  * Author: Isaak Mitschke
33  */
34 
35 #ifndef LAS_VEGAS_NODEDATA_H
36 #define LAS_VEGAS_NODEDATA_H
37 #include <boost/timer/timer.hpp>
38 #include <ctime>
39 #include <fstream>
40 #include <iostream>
41 #include <string>
42 #include <vector>
43 
44 using namespace std;
45 
46 namespace lvr2
47 {
51 template <typename BaseVecT>
52 class NodeData
53 {
54  static boost::timer::cpu_timer itimer;
55  static boost::timer::cpu_timer otimer;
56  static bool timer_init;
57 
58  // Iterator
59  class Iterator;
60 
61  public:
67  NodeData(size_t bufferSize);
73  NodeData(NodeData& origin);
74 
80  NodeData& operator=(NodeData& origin);
81 
86  void open(string path);
87 
92  const string& getDataPath() const { return m_dataPath; }
93 
98  const string getFolder() const { return to_string(c_tstamp).insert(0, "node-"); }
99 
104  Iterator begin();
105 
110  Iterator end();
111 
115  void remove();
116 
121  void remove(unsigned int i);
122 
127  void add(BaseVecT input);
128 
129  void addNormal(BaseVecT input);
130 
135  void addBuffered(BaseVecT input);
136 
137  void addBufferedNormal(BaseVecT input);
138 
142  void writeBuffer();
143 
148  size_t getMaxWriteBufferSize();
153  BaseVecT get(int);
154 
155  BaseVecT getNormal(int);
160  BaseVecT next();
161 
166  size_t size();
167 
172  size_t getBufferSize();
173 
174  static void printTimer()
175  {
176  std::cout << "IO-Timer of Octree:" << std::endl
177  << "READ: " << itimer.format() << std::endl
178  << "WRITE: " << otimer.format() << std::endl;
179  }
180 
181  private:
182  // copys the data from origin to this
183  void copy(NodeData& origin);
184  // fills the buffer, copys from start_id to buffersize elements into buffer
185  void fillBuffer(size_t start_id);
186  void fillBufferNormal(size_t start_id);
187  // path to data
188  string m_dataPath;
189 
191  // if m_gotSize is set, the m_size will be used, else the size will be calculated
192  bool m_gotSize;
193  // amount of points stored in data
194  size_t m_size;
195  // current id of the dataobject, used to generate file name
196  int m_id;
197  // input buffer
198  vector<float> m_readBuffer;
199  // output buffer
200  vector<float> m_writeBuffer;
201 
202  vector<float> m_readBufferNormal;
203  // output buffer
204  vector<float> m_writeBufferNormal;
205 
206  // maximum buffer size
207  size_t m_bufferSize;
208  // current inputbuffer position
210 
212  // last id
213  static int c_last_id;
214  // timestamp, of first creation
215  static time_t c_tstamp;
216 };
217 
221 template <typename BaseVecT>
222 class NodeData<BaseVecT>::Iterator
223 {
224  public:
225  Iterator(NodeData& nodeData, size_t pos) : m_NodeData(nodeData), m_pos(pos) {}
226  Iterator(NodeData& nodeData) : m_NodeData(nodeData), m_pos(0) {}
227  Iterator(const Iterator& copy) : m_pos(copy.m_pos), m_NodeData(copy.m_NodeData) {}
228 
230  {
231  Iterator tmp(*this);
232  operator++();
233  return tmp;
234  }
235 
236  bool operator==(const Iterator& rhs) { return m_pos == rhs.m_pos; }
237  bool operator!=(const Iterator& rhs) { return m_pos != rhs.m_pos; }
238  // Todo: more if needed
239  void operator+(int i) { m_pos += i; }
240  void operator-(int i) { m_pos -= i; }
241  void operator++() { ++m_pos; }
242  void operator--() { --m_pos; }
243 
244  BaseVecT operator*() { return m_NodeData.get(m_pos); }
245  BaseVecT operator->() { return m_NodeData.get(m_pos); }
246 
247  private:
249  size_t m_pos;
250 };
251 
252 } // namespace lvr2
253 
254 #include "NodeData.tcc"
255 
256 #endif // LAS_VEGAS_NODEDATA_H
lvr2::NodeData::m_readBufferNormal
vector< float > m_readBufferNormal
Definition: NodeData.hpp:202
lvr2::NodeData::c_last_id
static int c_last_id
Definition: NodeData.hpp:213
lvr2::NodeData::Iterator::Iterator
Iterator(NodeData &nodeData)
Definition: NodeData.hpp:226
lvr2::NodeData::m_readBufferIndexNormal
size_t m_readBufferIndexNormal
Definition: NodeData.hpp:211
lvr2::NodeData::c_tstamp
static time_t c_tstamp
Definition: NodeData.hpp:215
lvr2::NodeData::Iterator::operator*
BaseVecT operator*()
Definition: NodeData.hpp:244
lvr2::NodeData::m_readBuffer
vector< float > m_readBuffer
Definition: NodeData.hpp:198
lvr2::NodeData::m_bufferSize
size_t m_bufferSize
Definition: NodeData.hpp:207
lvr2::NodeData::Iterator::operator+
void operator+(int i)
Definition: NodeData.hpp:239
lvr2::NodeData::printTimer
static void printTimer()
Definition: NodeData.hpp:174
lvr2::NodeData::itimer
static boost::timer::cpu_timer itimer
Definition: NodeData.hpp:54
lvr2::NodeData::Iterator::Iterator
Iterator(NodeData &nodeData, size_t pos)
Definition: NodeData.hpp:225
lvr2::NodeData::m_writeBuffer
vector< float > m_writeBuffer
Definition: NodeData.hpp:200
lvr2::NodeData::Iterator::operator++
void operator++()
Definition: NodeData.hpp:241
lvr2::NodeData::m_id
int m_id
Definition: NodeData.hpp:196
lvr2::NodeData::Iterator::operator-
void operator-(int i)
Definition: NodeData.hpp:240
lvr2::NodeData::Iterator::operator!=
bool operator!=(const Iterator &rhs)
Definition: NodeData.hpp:237
lvr2::NodeData::m_writeBufferNormal
vector< float > m_writeBufferNormal
Definition: NodeData.hpp:204
lvr2::NodeData::Iterator::operator->
BaseVecT operator->()
Definition: NodeData.hpp:245
lvr2::NodeData::m_dataPath
string m_dataPath
Definition: NodeData.hpp:188
lvr2::NodeData::getDataPath
const string & getDataPath() const
Definition: NodeData.hpp:92
lvr2::NodeData::Iterator::m_pos
size_t m_pos
Definition: NodeData.hpp:249
lvr2::NodeData::m_gotSize
bool m_gotSize
Definition: NodeData.hpp:192
lvr2::NodeData::Iterator::operator--
void operator--()
Definition: NodeData.hpp:242
lvr2::NodeData::Iterator::operator++
Iterator operator++(int)
Definition: NodeData.hpp:229
lvr2::NodeData::timer_init
static bool timer_init
Definition: NodeData.hpp:56
lvr2::NodeData::otimer
static boost::timer::cpu_timer otimer
Definition: NodeData.hpp:55
std
Definition: HalfEdge.hpp:124
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::NodeData::m_readBufferIndex
size_t m_readBufferIndex
Definition: NodeData.hpp:209
lvr2::NodeData::m_size
size_t m_size
Definition: NodeData.hpp:194
lvr2::NodeData::Iterator::m_NodeData
NodeData< BaseVecT > & m_NodeData
Definition: NodeData.hpp:248
lvr2::NodeData::Iterator
Definition: NodeData.hpp:222
lvr2::NodeData::getFolder
const string getFolder() const
Definition: NodeData.hpp:98
lvr2::NodeData
Definition: NodeData.hpp:52
lvr2::NodeData::Iterator::Iterator
Iterator(const Iterator &copy)
Definition: NodeData.hpp:227
lvr2::NodeData::Iterator::operator==
bool operator==(const Iterator &rhs)
Definition: NodeData.hpp:236
lvr2::NodeData::m_dataPathNormal
string m_dataPathNormal
Definition: NodeData.hpp:190
lvr2::hdf5util::open
std::shared_ptr< HighFive::File > open(const std::string &filename)
Definition: Hdf5Util.cpp:202


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