00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef SFLPS_H
00038 #define SFLPS_H
00039
00040 #undef SFEXPORT
00041 #if defined(MS_WINDOWS) && !defined(SF_STATIC)
00042 #ifdef MAKE_LIBRARY
00043 #define _declspec( dllexport )
00044 #else
00045 #define _declspec( dllimport )
00046 #endif
00047 #else
00048 #define SFEXPORT
00049 #endif
00050
00053
00064 class SfArtifact : public SfDrawable
00065 {
00066 public:
00068 ArPose p;
00069
00070 typedef enum
00071 {
00072 Robot,
00073 Point,
00074 Wall,
00075 Wallset,
00076 Corridor,
00077 Goal
00078 } Type;
00079 Type type;
00080
00081 int id;
00082 int newflags;
00084
00085 void print() {}
00086
00087 void moveObj(ArPose *q) { p.setX(q->getX() + p.getX()); p.setY(q->getY() + p.getY());
00088 p.setTh(p.getTh() + q->getTh());
00089 newflags = -1; }
00090
00091 void moveObj(double x, double y, double th)
00092 { p.setX(p.getX()+x); p.setY(p.getY()+y);
00093 p.setTh(p.getTh() + th); newflags = -1; }
00095 SfArtifact();
00097
00098 private:
00099 static int newid;
00100 };
00101
00102
00103
00104
00105
00106
00109
00110
00111 class SfRobot : public ArRobot, public SfArtifact
00112 {
00113 public:
00114 SfRobot();
00115 virtual ~SfRobot() {}
00116
00117 void print() {}
00118 void draw(SfWin *w);
00119
00120 };
00121
00122
00125 class SfPoint : public SfArtifact
00126 {
00127 public:
00129 SfPoint(double x, double y, double th)
00130 { p.setX(x); p.setY(y); p.setTh(th); type = Point; }
00132 SfPoint()
00133 { p.setX(0); p.setY(0); p.setTh(0); type = Point; }
00134 void print() {}
00135 void draw(SfWin *w);
00137
00138 };
00139
00142 class SfGoal : public SfArtifact
00143 {
00144 public:
00146 SfGoal(double x, double y, double th, const char *name, bool useHeading)
00147 { p.setX(x); p.setY(y); p.setTh(th); type = Goal; myName = name; myUseHeading = useHeading; }
00149 SfGoal()
00150 { p.setX(0); p.setY(0); p.setTh(0); type = Goal; myUseHeading = false; }
00151 void print() {}
00152 ArPose getPose(void) { return p; }
00153 bool useHeading(void) { return myUseHeading; }
00154 const char *getName(void) { return myName.c_str(); };
00155 void draw(SfWin *w);
00157
00158 private:
00159 std::string myName;
00160 bool myUseHeading;
00161 };
00162
00163
00165 class SfCorridor : public SfArtifact
00166 {
00167 public:
00169 SfCorridor(double x, double y, double th, double w, double l)
00170 { p.setX(x); p.setY(y); p.setTh(th); width = w; length = l; type = Corridor; }
00172 SfCorridor()
00173 { p.setX(0); p.setY(0); p.setTh(0); width = 0; length = 0; type = Corridor; }
00175 virtual ~SfCorridor() {}
00177 double width, length;
00178 void print() {}
00179 void draw(SfWin *w);
00180 };
00181
00182
00183
00185 class SfWall : public SfArtifact
00186 {
00187 public:
00189 SfWall(double x1, double y1, double x2, double y2)
00190 {
00191 v.x1 = x1; v.x2 = x2; v.y1 = y1; v.y2 = y2;
00192 length = makeWall(&p,x1,y1,x2,y2);
00193 type = Wall;
00194 }
00196 SfWall()
00197 {
00198 v.x1 = v.x2 = v.y1 = v.y2 = 0;
00199 length = makeWall(&p,0,0,0,0);
00200 type = Wall;
00201 }
00203 virtual ~SfWall() {}
00205 double length;
00207
00208 void print() { }
00209 void draw(SfWin *w);
00210
00211 private:
00212 double makeWall(ArPose *p, double x1, double y1, double x2, double y2);
00213 };
00214
00215
00216
00217
00218
00219
00220 class SfWallset : public SfArtifact
00221 {
00222 public:
00223 SfVector *walls;
00224 int n;
00225 virtual ~SfWallset () {}
00226 SfWallset(double x, double y, double th, int n)
00227 { p.setX(x); p.setY(y); p.setTh(th); walls = new SfVector[n]; type = Wallset; }
00228 SfWallset(int n)
00229 { p.setX(0); p.setY(0); p.setTh(0); walls = new SfVector[n]; type = Wallset; }
00230 void print() {}
00231 void draw(SfWin *w)
00232 {
00233 }
00234 };
00235
00236
00237
00238
00239
00240
00241
00243 #define SfARTIFACTS SfArtifactList::current()
00244
00245
00247
00256 class SfArtifactList : public SfDrawable
00257 {
00258 public:
00260 static SfArtifactList *current();
00261 static void current(SfArtifactList *a);
00262 SfArtifactList();
00263 virtual ~SfArtifactList() {};
00264 void draw(SfWin *w);
00265 void add(SfArtifact *a)
00266 { arts->push_front(a); }
00267 void remove(SfArtifact *a)
00268 { arts->remove(a); }
00269 void RemoveWalls();
00270 void SetOrigin(double x, double y);
00271 void SetWidth(double w)
00272 { bounds.x2 = bounds.x1+w; }
00273 void SetHeight(double h)
00274 { bounds.y2 = bounds.y1+h; }
00277 SfVector &Bounds(void)
00278 { return bounds; }
00279 std::list<SfArtifact *> *Artifacts()
00280 { return arts; }
00281
00282 private:
00283 static SfArtifactList *_current;
00284 std::list<SfArtifact *> *arts;
00285 SfVector bounds;
00286 };
00287
00288
00291 ArPose *sfLoadWorldFile(char *name);
00293 void sfRemoveWorld();
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 class SfVectorSystem : public SfVector, public ArPose
00306
00307 {
00308 public:
00309 SfVectorSystem(SfVector &v) { Set(v); };
00310 SfVectorSystem(ArPose &p) { Set(p); };
00311 void Set(SfVector &v);
00312 void Set(ArPose &p);
00313 void ToLocal(double &x, double &y)
00314 { x-=x1; y-=y1; double temp = x; x = cs*x + sn*y; y = cs*y - sn*temp;};
00315 void ToGlobal(double &x, double &y)
00316 { double temp = x; x = cs*x - sn*y; y = cs*y + sn*temp; x+=x1; y+=y1;};
00317 private:
00318 double sn, cs;
00319 };
00320
00321
00322 #endif // SFLPS_H