Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SCANPOINT_HPP
00009 #define SCANPOINT_HPP
00010
00011
00012 #include <cassert>
00013 #include "../BasicDatatypes.hpp"
00014
00015 namespace datatypes
00016 {
00017
00018 class Point2D;
00019 class Point3D;
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class ScanPoint
00037 {
00038 public:
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 enum Flags
00049 {
00050 FlagGround = 0x0001,
00051 FlagDirt = 0x0002,
00052 FlagRain = 0x0004,
00053 FlagThresholdSwitching = 0x0010,
00054
00055 FlagReflector = 0x0020,
00056 FlagLeftCovered = 0x0100,
00057 FlagRightCovered = 0x0200,
00058 FlagBackground = 0x0400,
00059 FlagMarker = 0x0800,
00060 FlagTransparent = 0x1000,
00061 MaskInvalid = FlagGround | FlagDirt | FlagRain | FlagBackground,
00062 MaskCovered = FlagLeftCovered | FlagRightCovered
00063 };
00064
00065 protected:
00066
00067 double m_x;
00068 double m_y;
00069 double m_z;
00070
00071
00072 double m_dist;
00073 double m_hAngle;
00074 double m_vAngle;
00075
00076
00077 double m_echoWidth;
00078
00079
00080 UINT16 m_flags;
00081 UINT8 m_sourceId;
00082 UINT8 m_channel;
00083 UINT8 m_subchannel;
00084
00085 public:
00086 ScanPoint();
00087 void clear();
00088
00089 double getX() const { return m_x; }
00090 double getY() const { return m_y; }
00091 double getZ() const { return m_z; }
00092
00093 double getDist() const { return m_dist; }
00094 double getHAngle() const { return m_hAngle; }
00095 double getVAngle() const { return m_vAngle; }
00096
00097 double getEchoWidth() const { return m_echoWidth; }
00098 UINT16 getFlags() const { return m_flags; }
00099 UINT8 getSourceId() const { return m_sourceId; }
00100 UINT8 getLayer() const { return m_channel; }
00101 UINT8 getEchoNum() const { return m_subchannel; }
00102
00104 bool isValid() const { return (m_flags & MaskInvalid) == 0; }
00106 bool isMarked() const { return (m_flags & FlagMarker); }
00108 bool isGround() const { return m_flags & FlagGround; }
00110 bool isBackground() const { return m_flags & FlagBackground; }
00112 bool isDirt() const { return m_flags & FlagDirt; }
00114 bool isRain() const { return m_flags & FlagRain; }
00116 bool isLeftCovered() const { return m_flags & FlagLeftCovered; }
00118 bool isRightCovered() const { return m_flags & FlagRightCovered; }
00120 bool isReflector() const { return m_flags & FlagReflector; }
00122 bool isThresholdSwitching() const { return m_flags & FlagThresholdSwitching; }
00124 bool isTransparent() const { return m_flags & FlagTransparent; }
00125
00131 double getDist(const ScanPoint& other) const;
00132
00140 double getDist2D(const ScanPoint& other) const;
00141
00143 Point3D toPoint3D() const;
00144
00146 Point2D toPoint2D() const;
00147
00148
00149
00150 static double getDistanceBetweenScanpoints(const ScanPoint& pt1, const ScanPoint& pt2);
00151
00152
00153 void setPoint3D (const Point3D& pt);
00154 void setCartesian (double x, double y, double z);
00155 void setPolar (double dist, double hAngle, double vAngle);
00156
00157
00158 void addCartesianOffset (double xOffset, double yOffset, double zOffset);
00159
00160
00161 void addPolarOffset (double distOffset, double hAngleOffset, double vAngleOffset);
00162
00164 void setEchoWidth (double echoWidth);
00165
00166 void setSourceId (UINT8 id) { m_sourceId = id; }
00167
00168 void setLayer (UINT8 ch) { m_channel = ch; }
00169 void setEchoNum (UINT8 sub) { m_subchannel = sub; }
00170
00172 void setFlags (UINT16 flags)
00173 {
00174 m_flags = flags;
00175 }
00177 void setMarker (bool isMarked = true)
00178 {
00179 if (isMarked)
00180 m_flags |= FlagMarker;
00181 else
00182 m_flags &= ~FlagMarker;
00183 }
00185 void setBackground (bool isBackground = true)
00186 {
00187 if (isBackground)
00188 m_flags |= FlagBackground;
00189 else
00190 m_flags &= ~FlagBackground;
00191 }
00193 void setGround (bool isGround = true)
00194 {
00195 if (isGround)
00196 m_flags |= FlagGround;
00197 else
00198 m_flags &= ~FlagGround;
00199 }
00201 void setDirt (bool isDirt = true)
00202 {
00203 if (isDirt)
00204 m_flags |= FlagDirt;
00205 else
00206 m_flags &= ~FlagDirt;
00207 }
00209 void setRain (bool isRain = true)
00210 {
00211 if (isRain)
00212 m_flags |= FlagRain;
00213 else
00214 m_flags &= ~FlagRain;
00215 }
00217 void setLeftCovered (bool isLeftCovered = true)
00218 {
00219 if (isLeftCovered)
00220 m_flags |= FlagLeftCovered;
00221 else
00222 m_flags &= ~FlagLeftCovered;
00223 }
00225 void setRightCovered (bool isRightCovered = true)
00226 {
00227 if (isRightCovered)
00228 m_flags |= FlagRightCovered;
00229 else
00230 m_flags &= ~FlagRightCovered;
00231 }
00233 void setNotCovered () { m_flags &= ~MaskCovered; }
00234
00236 void setReflector (bool isReflector = true)
00237 {
00238 if (isReflector)
00239 m_flags |= FlagReflector;
00240 else
00241 m_flags &= ~FlagReflector;
00242 }
00243
00245 void setValid() { m_flags &= ~MaskInvalid; }
00246
00247 friend bool operator==(const ScanPoint &, const ScanPoint &);
00248
00249 std::string toString() const;
00250
00251 private:
00253 void updatePolar();
00254
00256 void updateCartesian();
00257
00258 };
00259
00261 std::ostream& operator<<(std::ostream& os, const ScanPoint& point);
00262
00264 bool operator==(const ScanPoint &p1, const ScanPoint &p2);
00265
00267 bool operator!=(const ScanPoint &p1, const ScanPoint &p2);
00268
00269 }
00270
00271 #endif // SCANPOINT_HPP