00001 //---------------------------------------------------------------------- 00002 // The Motion Strategy Library (MSL) 00003 //---------------------------------------------------------------------- 00004 // 00005 // Copyright (c) 1998-2000 Iowa State University and Steve LaValle. 00006 // All Rights Reserved. 00007 // 00008 // Permission to use, copy, and distribute this software and its 00009 // documentation is hereby granted free of charge, provided that 00010 // (1) it is not a component of a commercial product, and 00011 // (2) this notice appears in all copies of the software and 00012 // related documentation. 00013 // 00014 // Iowa State University and the author make no representations 00015 // about the suitability or fitness of this software for any purpose. 00016 // It is provided "as is" without express or implied warranty. 00017 //---------------------------------------------------------------------- 00018 00019 #ifndef MSL_GEOM_H 00020 #define MSL_GEOM_H 00021 00022 #include <LEDA/file.h> 00023 #include <LEDA/array.h> 00024 #include <LEDA/list.h> 00025 #include <LEDA/matrix.h> 00026 #include <LEDA/point.h> 00027 #include <LEDA/polygon.h> 00028 #include <LEDA/stream.h> 00029 #include <LEDA/string.h> 00030 #include <LEDA/vector.h> 00031 00032 #include <LEDA/REDEFINE_NAMES.h> 00033 00034 // The world places objects using configuration (model uses state). 00035 // Each derived class can define Obst and Robot however it likes. 00036 // Methods such as "GeomToPolygons" can give output in whatever 00037 // format is requested. So far, only list<polygon> is shown, 00038 // but we could imagine an OpenInventor model, Geomview model, etc. 00039 00041 00054 class Geom { 00055 protected: 00056 string FilePath; 00057 public: 00059 Geom(string path); 00060 00062 virtual ~Geom() {}; 00063 00065 int NumBodies; 00066 00068 int GeomDim; 00069 00071 virtual bool CollisionFree(const vector &q) = 0; // Input is configuration 00072 00075 virtual double DistanceComp(const vector &q) = 0; // Distance in world 00076 00078 virtual list<polygon> EnvironmentToLedaPolygons() = 0; 00079 00081 virtual list<polygon> RobotToLedaPolygons(const vector &q) = 0; 00082 00084 vector MaxDeviates; 00085 00089 virtual vector ConfigurationDifference(const vector &q1, 00090 const vector &q2); 00091 }; 00092 00093 00095 class GeomLedaPolygonal: public Geom { 00096 protected: 00097 list<polygon> Obst; 00098 public: 00099 GeomLedaPolygonal(string path); 00100 virtual ~GeomLedaPolygonal() {}; 00101 virtual bool CollisionFree(const vector &q); // Input is configuration 00102 virtual double DistanceComp(const vector &q); // Distance in world 00103 // These two functions enable a "frame" to be displayed in using 00104 // LEDA polygons, even if Obst and Robot are represented using 00105 // other (including 3D) primitives). 00106 virtual list<polygon> EnvironmentToLedaPolygons(); 00107 virtual list<polygon> RobotToLedaPolygons(const vector &q); 00108 // Other methods could be added here that are similar to the two 00109 // above, but output the world in different formats, such 00110 // as: Geomview file, Open Inventor file, GL primitives, etc. 00111 }; 00112 00113 00115 class GeomLedaPolygonalRigid: public GeomLedaPolygonal { 00116 private: 00117 list<polygon> Robot; 00118 public: 00119 GeomLedaPolygonalRigid(string path); 00120 virtual ~GeomLedaPolygonalRigid() {}; 00121 virtual bool CollisionFree(const vector &q); // Input is configuration 00122 virtual double DistanceComp(const vector &q); // Distance in world 00123 virtual list<polygon> RobotToLedaPolygons(const vector &q); 00124 virtual vector ConfigurationDifference(const vector &q1, 00125 const vector &q2); 00126 }; 00127 00128 00129 #include <LEDA/UNDEFINE_NAMES.h> 00130 00131 #endif