point_type.h
Go to the documentation of this file.
1 
7 #ifndef __POINT_TYPE_H__
8 #define __POINT_TYPE_H__
9 
10 #include "point.h"
11 #include "data_types.h"
12 
13 #include <string>
14 using std::string;
15 #include <iostream>
16 using std::cout;
17 using std::cerr;
18 using std::endl;
19 
20 #include <iostream>
21 #include <fstream>
22 #include <string.h>
23 
24 
25 class PointType {
26 public:
27 
28  static const unsigned int USE_NONE;
29  static const unsigned int USE_REFLECTANCE;
30  static const unsigned int USE_AMPLITUDE;
31  static const unsigned int USE_DEVIATION;
32  static const unsigned int USE_HEIGHT;
33  static const unsigned int USE_TYPE;
34  static const unsigned int USE_COLOR;
35  static const unsigned int USE_TIME;
36  static const unsigned int USE_INDEX;
37 
38  PointType();
39 
40  PointType(unsigned int _types);
41 
42  bool hasReflectance();
43  bool hasAmplitude();
44  bool hasDeviation();
45  bool hasType();
46  bool hasColor();
47  bool hasTime();
48  bool hasIndex();
49 
50  unsigned int getReflectance();
51  unsigned int getAmplitude();
52  unsigned int getDeviation();
53  unsigned int getTime();
54  unsigned int getIndex();
55  unsigned int getType();
56  unsigned int getType(unsigned int type);
57 
58 
59  unsigned int getPointDim();
60 
61  static PointType deserialize(std::ifstream &f);
62 
63  void serialize(std::ofstream &f);
64  unsigned int toFlags() const;
65 
66  template <class T>
67  T *createPoint(const Point &P, unsigned int index=0);
68 
69  template <class T>
70  Point createPoint(T *p);
71 
72 // //! Aquire DataPointer objects from \a scan, determined by its types
73 // void useScan(Scan* scan);
74 //
75 // //! Release the DataPointer objects
76 // void clearScan();
77 //
79  template<typename T>
80  T* createPoint(unsigned int i, unsigned int index = 0);
81 
82 // //! Create an array with coordinate+attribute array per point with transfer of ownership
83 // template<typename T>
84 // T** createPointArray(Scan* scan);
85 
86 private:
90  unsigned int types;
94  unsigned int pointdim;
95 
99  unsigned int pointbytes;
100 
104  int dimensionmap[8];
105 
106  bool hasType(unsigned int type);
107 
108 // unsigned int getScanSize(Scan* scan);
109 
116 };
117 
118 
119 template <class T>
120 T *PointType::createPoint(const Point &P, unsigned int index ) {
121  unsigned int counter = 0;
122 
123  T *p = new T[pointdim];
124  p[counter++] = P.x;
125  p[counter++] = P.y;
126  p[counter++] = P.z;
127  if (types & USE_REFLECTANCE) {
128  p[counter++] = P.reflectance;
129  }
130  if (types & USE_AMPLITUDE) {
131  p[counter++] = P.amplitude;
132  }
133  if (types & USE_DEVIATION) {
134  p[counter++] = P.deviation;
135  }
136  if (types & USE_TYPE) {
137  p[counter++] = P.type;
138  }
139  if (types & USE_COLOR) {
140  memcpy(&p[counter], P.rgb, 3);
141  counter++;
142  }
143  if (types & USE_TIME) {
144 // p[counter++] = P.timestamp;
145  }
146  if (types & USE_INDEX) {
147  p[counter++] = index;
148  }
149 
150  return p;
151 }
152 
153 template <class T>
155  Point P;
156  unsigned int counter = 0;
157 
158  P.x = p[counter++];
159  P.y = p[counter++];
160  P.z = p[counter++];
161  if (types & USE_REFLECTANCE) {
162  P.reflectance = p[counter++];
163  }
164  if (types & USE_AMPLITUDE) {
165  P.amplitude = p[counter++];
166  }
167  if (types & USE_DEVIATION) {
168  P.deviation = p[counter++];
169  }
170  if (types & USE_TYPE) {
171  P.type = p[counter++];
172  }
173  if (types & USE_COLOR) {
174  memcpy(P.rgb, &p[counter], 3);
175  counter++;
176  }
177  if (types & USE_TIME) {
178 // P.timestamp = p[counter++];
179  }
180 
181  return P;
182 }
183 
184 template <class T>
185 T *PointType::createPoint(unsigned int i, unsigned int index) {
186  unsigned int counter = 0;
187  T* p = new T[pointdim];
188 
189  for(unsigned int j = 0; j < 3; ++j)
190  p[counter++] = (*m_xyz)[i][j];
191 
192  // if a type is requested try to write the value if the scan provided one
193  if (types & USE_REFLECTANCE) {
194  p[counter++] = (m_reflectance? (*m_reflectance)[i]: 0);
195  }
196  if (types & USE_AMPLITUDE) {
197  p[counter++] = (m_amplitude? (*m_amplitude)[i]: 0);
198  }
199  if (types & USE_DEVIATION) {
200  p[counter++] = (m_deviation? (*m_deviation)[i]: 0);
201  }
202  if (types & USE_TYPE) {
203  p[counter++] = (m_type? (*m_type)[i]: 0);
204  }
205  if (types & USE_COLOR) {
206  if(m_rgb)
207  memcpy(&p[counter], (*m_rgb)[i], 3);
208  else
209  p[counter] = 0;
210  counter++;
211  }
212  if (types & USE_TIME) {
213  }
214  if (types & USE_INDEX) {
215  p[counter++] = index;
216  }
217 
218  return p;
219 }
220 
221 //template<typename T>
222 //T** PointType::createPointArray(Scan* scan)
223 //{
224 // // access data with prefetching
225 // useScan(scan);
226 //
227 // // create a float array with requested attributes by pointtype via createPoint
228 // unsigned int nrpts = getScanSize(scan);
229 // T** pts = new T*[nrpts];
230 // for(unsigned int i = 0; i < nrpts; i++) {
231 // pts[i] = createPoint<T>(i);
232 // }
233 //
234 // // unlock access to data, remove unneccessary data fields
235 // clearScan();
236 //
237 // return pts;
238 //}
239 
240 #endif
PointType::getTime
unsigned int getTime()
Definition: point_type.cc:89
data_types.h
Basic DataPointer class and its derivates SingleArray and TripleArray.
Point::reflectance
float reflectance
Definition: point.h:120
point.h
Representation of a 3D point.
PointType::USE_DEVIATION
static const unsigned int USE_DEVIATION
Definition: point_type.h:31
Point::amplitude
float amplitude
Definition: point.h:121
SingleArray
Definition: data_types.h:107
PointType::getPointDim
unsigned int getPointDim()
Definition: point_type.cc:124
PointType::USE_AMPLITUDE
static const unsigned int USE_AMPLITUDE
Definition: point_type.h:30
PointType::m_type
DataType * m_type
Definition: point_type.h:114
PointType::getAmplitude
unsigned int getAmplitude()
Definition: point_type.cc:81
PointType::USE_TYPE
static const unsigned int USE_TYPE
Definition: point_type.h:33
PointType::deserialize
static PointType deserialize(std::ifstream &f)
Definition: point_type.cc:126
p
SharedPointer p
Definition: ConvertShared.hpp:42
PointType::hasColor
bool hasColor()
Definition: point_type.cc:66
PointType::hasReflectance
bool hasReflectance()
Definition: point_type.cc:54
PointType::pointbytes
unsigned int pointbytes
Definition: point_type.h:99
PointType::USE_TIME
static const unsigned int USE_TIME
Definition: point_type.h:35
Point::type
int type
Definition: point.h:106
PointType::createPoint
T * createPoint(const Point &P, unsigned int index=0)
Definition: point_type.h:120
PointType
Definition: point_type.h:25
PointType::getType
unsigned int getType()
Definition: point_type.cc:97
Point::z
double z
z coordinate in 3D space
Definition: point.h:103
PointType::types
unsigned int types
Definition: point_type.h:90
PointType::serialize
void serialize(std::ofstream &f)
Definition: point_type.cc:132
PointType::USE_NONE
static const unsigned int USE_NONE
Definition: point_type.h:28
PointType::USE_HEIGHT
static const unsigned int USE_HEIGHT
Definition: point_type.h:32
Point::x
double x
x coordinate in 3D space
Definition: point.h:99
PointType::m_reflectance
DataReflectance * m_reflectance
Definition: point_type.h:112
PointType::m_amplitude
DataAmplitude * m_amplitude
Definition: point_type.h:113
PointType::USE_COLOR
static const unsigned int USE_COLOR
Definition: point_type.h:34
PointType::getIndex
unsigned int getIndex()
Definition: point_type.cc:93
PointType::m_deviation
DataDeviation * m_deviation
Definition: point_type.h:115
Point::rgb
unsigned char rgb[3]
Definition: point.h:118
PointType::hasDeviation
bool hasDeviation()
Definition: point_type.cc:60
PointType::dimensionmap
int dimensionmap[8]
Definition: point_type.h:104
PointType::hasAmplitude
bool hasAmplitude()
Definition: point_type.cc:57
PointType::getDeviation
unsigned int getDeviation()
Definition: point_type.cc:85
PointType::m_rgb
DataRGB * m_rgb
Definition: point_type.h:111
PointType::hasType
bool hasType()
Definition: point_type.cc:63
Point::y
double y
y coordinate in 3D space
Definition: point.h:101
Point
Representation of a point in 3D space.
Definition: point.h:22
PointType::USE_INDEX
static const unsigned int USE_INDEX
Definition: point_type.h:36
PointType::getReflectance
unsigned int getReflectance()
Definition: point_type.cc:77
PointType::toFlags
unsigned int toFlags() const
Definition: point_type.cc:136
PointType::USE_REFLECTANCE
static const unsigned int USE_REFLECTANCE
Definition: point_type.h:29
PointType::PointType
PointType()
Definition: point_type.cc:33
PointType::hasTime
bool hasTime()
Definition: point_type.cc:69
PointType::pointdim
unsigned int pointdim
Definition: point_type.h:94
PointType::hasIndex
bool hasIndex()
Definition: point_type.cc:73
TripleArray
Definition: data_types.h:135
Point::deviation
float deviation
Definition: point.h:122
PointType::m_xyz
DataXYZ * m_xyz
Definition: point_type.h:110


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