00001 // 00002 // Fields.hpp 00003 // 00004 // Created on: 30.08.2011 00005 // Author: wahnfla 00006 // 00007 00008 #ifndef FIELDS_HPP 00009 #define FIELDS_HPP 00010 00011 #include "Polygon2D.hpp" 00012 #include <vector> 00013 #include "../BasicDatatypes.hpp" 00014 #include "FieldDescription.hpp" 00015 #include "FieldParameter.hpp" 00016 00017 namespace datatypes 00018 { 00019 00020 00021 00022 // 00023 // 00024 // ******************************************************************************* 00025 // 00026 // 00027 class Fields : public BasicData 00028 { 00029 public: 00030 typedef std::vector<FieldParameter*> FieldVector; 00031 00032 Fields() {m_datatype = Datatype_Fields;} 00033 00034 virtual ~Fields() {} 00035 const UINT32 getUsedMemory() const; 00036 00037 void add(FieldParameter* field); 00038 00039 const FieldParameter& getField(UINT16 fieldNumber) const; 00040 00041 UINT16 getNumberOfValidFields(); 00042 00043 const FieldVector& getFields() const 00044 { 00045 return m_fields; 00046 } 00047 00048 private: 00049 00050 FieldVector m_fields; 00051 }; 00052 00053 // 00054 // 00055 // ******************************************************************************* 00056 // 00057 // Helper class for a point of a segmented field. 00058 // Note that as with all internal data structures, units 00059 // should be [rad] and [m]. 00060 // 00061 class FieldSegmentedPoint 00062 { 00063 public: 00064 FieldSegmentedPoint(double angle, double startDist, double endDist) : 00065 m_angle(angle), 00066 m_startDist(startDist), 00067 m_endDist(endDist) 00068 { 00069 } 00070 FieldSegmentedPoint() 00071 { 00072 m_angle = 0.0; 00073 m_startDist = 0.0; 00074 m_endDist = 0.0; 00075 } 00076 00077 double getAngle() const { return m_angle; } 00078 double getStartDist() const { return m_startDist; } 00079 double getEndDist() const { return m_endDist; } 00080 void setAngle(double angle) { m_angle = angle; } 00081 void setStartDist(double startDist) { m_startDist = startDist; } 00082 void setEndDist(double endDist) { m_endDist = endDist; } 00083 00084 private: 00085 double m_angle; 00086 double m_startDist; 00087 double m_endDist; 00088 }; 00089 00090 typedef std::vector<FieldSegmentedPoint> FieldSegmentedPoints; 00091 00092 // 00093 // 00094 // ******************************************************************************* 00095 // 00096 // 00097 class FieldSegmented : public FieldDescription 00098 { 00099 public: 00100 FieldSegmented() 00101 { 00102 m_fieldType = FieldDescription::Segmented; 00103 } 00104 00105 virtual ~FieldSegmented() {} 00106 00107 void addPoint(const FieldSegmentedPoint& point) 00108 { 00109 m_points.push_back(point); 00110 } 00111 00112 virtual const UINT32 getUsedMemory() const 00113 { 00114 return sizeof(*this) + (m_points.size() * sizeof(FieldSegmentedPoints)); 00115 } 00116 00117 UINT32 getNumberOfPoints(); 00118 void computePolygon(); 00119 FieldSegmentedPoints getPoints(); 00120 00121 private: 00122 FieldSegmentedPoints m_points; 00123 }; 00124 00125 // 00126 // 00127 // ******************************************************************************* 00128 // 00129 // 00130 class FieldRectangle : public FieldDescription 00131 { 00132 public: 00133 FieldRectangle() 00134 { 00135 m_fieldType = FieldDescription::Rectangle; 00136 } 00137 00138 virtual ~FieldRectangle() 00139 { 00140 } 00141 00142 virtual const UINT32 getUsedMemory() const 00143 { 00144 return sizeof(*this); 00145 } 00146 00147 void computePolygon(); 00148 double getLength() const; 00149 double getRefPointAngle() const; 00150 double getRefPointDist() const; 00151 double getRotAngle() const; 00152 double getWidth() const; 00153 void setLength(double length); 00154 void setRefPointAngle(double refPointAngle); 00155 void setRefPointDist(double refPointDist); 00156 void setRotAngle(double rotAngle); 00157 void setWidth(double width); 00158 00159 private: 00160 double m_refPointAngle; 00161 double m_refPointDist; 00162 double m_rotAngle; 00163 double m_width; 00164 double m_length; 00165 }; 00166 00167 // 00168 // 00169 // ******************************************************************************* 00170 // 00171 // 00172 class FieldRadial : public FieldDescription 00173 { 00174 public: 00175 00176 FieldRadial() 00177 { 00178 m_fieldType = FieldDescription::Radial; 00179 } 00180 00181 virtual ~FieldRadial() 00182 { 00183 } 00184 00185 virtual const UINT32 getUsedMemory() const 00186 { 00187 return sizeof(*this); 00188 } 00189 00190 UINT16 getFirstAngle() const; 00191 UINT16 getLastAngle() const; 00192 UINT32 getMaxDist() const; 00193 UINT32 getMinDist() const; 00194 void setFirstAngle(UINT16 m_firstAngle); 00195 void setLastAngle(UINT16 m_lastAngle); 00196 void setMaxDist(UINT32 m_maxDist); 00197 void setMinDist(UINT32 m_minDist); 00198 00199 void computePolygon(); 00200 00201 private: 00202 UINT16 m_firstAngle; 00203 UINT16 m_lastAngle; 00204 UINT32 m_minDist; 00205 UINT32 m_maxDist; 00206 00207 }; 00208 00209 // 00210 // 00211 // ******************************************************************************* 00212 // 00213 // 00214 class FieldDynamic : public FieldRectangle 00215 { 00216 public: 00217 FieldDynamic() 00218 { 00219 m_fieldType = FieldDescription::Dynamic; 00220 } 00221 00222 virtual ~FieldDynamic() 00223 { 00224 } 00225 00226 virtual const UINT32 getUsedMemory() const 00227 { 00228 return sizeof(*this); 00229 } 00230 00231 double getMaxLength() const; 00232 double getSpeedMax() const; 00233 void setMaxLength(double maxLength); 00234 void setSpeedMax(double speedMax); 00235 00236 private: 00237 double m_maxLength; 00238 double m_speedMax; 00239 }; 00240 00241 } // namespace datatypes 00242 00243 #endif // FIELDS