point_type.cc
Go to the documentation of this file.
1 /*
2  * point_type implementation
3  *
4  * Copyright (C) Jan Elseberg
5  *
6  * Released under the GPL version 3.
7  *
8  */
9 
16 #include "slam6d/point_type.h"
17 
18 #include <string>
19 using std::string;
20 #include <iostream>
21 using std::cout;
22 using std::cerr;
23 using std::endl;
24 
25 #include <fstream>
26 #include <string.h>
27 
28 #include <stdexcept>
29 using std::runtime_error;
30 
31 
32 
34  types = USE_NONE;
35  pointdim = 3;
36  dimensionmap[1] = dimensionmap[2] = dimensionmap[3] = dimensionmap[4] = dimensionmap[5] = dimensionmap[6] = dimensionmap[7] = 1; // choose height per default
37  dimensionmap[0] = 1; // height
38 }
39 
40 PointType::PointType(unsigned int _types) : types(_types) {
41  dimensionmap[1] = dimensionmap[2] = dimensionmap[3] = dimensionmap[4] = dimensionmap[5] = dimensionmap[6] = dimensionmap[7] = 1; // choose height per default
42  dimensionmap[0] = 1; // height
43 
44  pointdim = 3;
52 }
53 
55  return hasType(USE_REFLECTANCE);
56 }
58  return hasType(USE_AMPLITUDE);
59 }
61  return hasType(USE_DEVIATION);
62 }
64  return hasType(USE_TYPE);
65 }
67  return hasType(USE_COLOR);
68 }
70  return hasType(USE_TIME);
71 }
72 
74  return hasType(USE_INDEX);
75 }
76 
77 unsigned int PointType::getReflectance() {
78  return dimensionmap[1];
79 }
80 
81 unsigned int PointType::getAmplitude() {
82  return dimensionmap[2];
83 }
84 
85 unsigned int PointType::getDeviation() {
86  return dimensionmap[3];
87 }
88 
89 unsigned int PointType::getTime() {
90  return dimensionmap[6];
91 }
92 
93 unsigned int PointType::getIndex() {
94  return dimensionmap[7];
95 }
96 
97 unsigned int PointType::getType() {
98  return dimensionmap[4];
99 }
100 
101 unsigned int PointType::getType(unsigned int type) {
102  if (type == USE_NONE ) {
103  return dimensionmap[0];
104  } else if (type == USE_HEIGHT) {
105  return dimensionmap[0];
106  } else if (type == USE_REFLECTANCE) {
107  return dimensionmap[1];
108  } else if (type == USE_AMPLITUDE) {
109  return dimensionmap[2];
110  } else if (type == USE_DEVIATION) {
111  return dimensionmap[3];
112  } else if (type == USE_TYPE) {
113  return dimensionmap[4];
114  } else if (type == USE_COLOR) {
115  return dimensionmap[5];
116  } else if (type == USE_TIME) {
117  return dimensionmap[6];
118  } else {
119  return 0;
120  }
121 }
122 
123 
124 unsigned int PointType::getPointDim() { return pointdim; }
125 
127  unsigned int types;
128  f.read(reinterpret_cast<char*>(&types), sizeof(unsigned int));
129  return PointType(types);
130 }
131 
132 void PointType::serialize(std::ofstream &f) {
133  f.write(reinterpret_cast<char*>(&types), sizeof(unsigned int));
134 }
135 
136 unsigned int PointType::toFlags() const { return types; }
137 
138 bool PointType::hasType(unsigned int type) {
139  return (types & type) == 0;
140 }
141 
142 
143 const unsigned int PointType::USE_NONE = 0;
144 const unsigned int PointType::USE_REFLECTANCE = 1;
145 const unsigned int PointType::USE_AMPLITUDE = 2;
146 const unsigned int PointType::USE_DEVIATION = 4;
147 const unsigned int PointType::USE_HEIGHT = 8;
148 const unsigned int PointType::USE_TYPE = 16;
149 const unsigned int PointType::USE_COLOR = 32;
150 const unsigned int PointType::USE_TIME = 64;
151 const unsigned int PointType::USE_INDEX = 128;
152 
153 
154 //void PointType::useScan(Scan* scan)
155 //{
156 // // clear pointers first
157 // m_xyz = 0; m_rgb = 0; m_reflectance = 0; m_amplitude = 0; m_type = 0; m_deviation = 0;
158 //
159 // // collectively load data to avoid unneccessary loading times due to split get("") calls
160 // unsigned int types = DATA_XYZ;
161 // if(hasColor()) types |= DATA_RGB;
162 // if(hasReflectance()) types |= DATA_REFLECTANCE;
163 // if(hasAmplitude()) types |= DATA_AMPLITUDE;
164 // if(hasType()) types |= DATA_TYPE;
165 // if(hasDeviation()) types |= DATA_DEVIATION;
166 // scan->get(types);
167 //
168 // // access data
169 // try {
170 // m_xyz = new DataXYZ(scan->get("xyz"));
171 // if(hasColor()) m_rgb = new DataRGB(scan->get("rgb"));
172 // if(hasReflectance()) m_reflectance = new DataReflectance(scan->get("reflectance"));
173 // if(hasAmplitude()) m_amplitude = new DataAmplitude(scan->get("amplitude"));
174 // if(hasType()) m_type = new DataType(scan->get("type"));
175 // if(hasDeviation()) m_deviation = new DataDeviation(scan->get("deviation"));
176 //
177 // // check if data is available, otherwise reset pointer to indicate that the scan doesn't prove this value
178 // if(m_rgb && !m_rgb->valid()) { delete m_rgb; m_rgb = 0; }
179 // if(m_reflectance && !m_reflectance->valid()) { delete m_reflectance; m_reflectance = 0; }
180 // if(m_amplitude && !m_amplitude->valid()) { delete m_amplitude; m_amplitude = 0; }
181 // if(m_type && !m_type->valid()) { delete m_type; m_type = 0; }
182 // if(m_deviation && !m_deviation->valid()) { delete m_deviation; m_deviation = 0; }
183 // } catch(runtime_error& e) {
184 // // unlock everything again
185 // clearScan();
186 // throw e;
187 // }
188 //}
189 //
190 //void PointType::clearScan()
191 //{
192 // // unlock data access
193 // if(m_xyz) delete m_xyz;
194 // if(hasColor() && m_rgb) delete m_rgb;
195 // if(hasReflectance() && m_reflectance) delete m_reflectance;
196 // if(hasAmplitude() && m_amplitude) delete m_amplitude;
197 // if(hasType() && m_type) delete m_type;
198 // if(hasDeviation() && m_deviation) delete m_deviation;
199 //
200 // // TODO: scan->clear() on all of these types
201 //}
202 //
203 //
204 //unsigned int PointType::getScanSize(Scan* scan)
205 //{
206 // return scan->size<DataXYZ>("xyz");
207 //}
PointType::getTime
unsigned int getTime()
Definition: point_type.cc:89
PointType::USE_DEVIATION
static const unsigned int USE_DEVIATION
Definition: point_type.h:31
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::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
point_type.h
Representation of a 3D point type.
PointType::hasColor
bool hasColor()
Definition: point_type.cc:66
PointType::hasReflectance
bool hasReflectance()
Definition: point_type.cc:54
PointType::USE_TIME
static const unsigned int USE_TIME
Definition: point_type.h:35
PointType
Definition: point_type.h:25
PointType::getType
unsigned int getType()
Definition: point_type.cc:97
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
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::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::hasType
bool hasType()
Definition: point_type.cc:63
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


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