Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

path.h

00001 
00009 #ifndef PATH_H
00010 #define PATH_H
00011 
00012 #include <string>
00013 #include <vector>
00014 #include "ConMath.h"
00015 
00016 
00017 #include "config.h"
00018 #include "entity.h"
00019 #include "LineContext.h"
00020 
00038 class Path : public Entity{
00039 public:
00040 
00042   typedef enum {
00044     INIT_ERROR,
00047     RESULT_PAST_PATH,
00049     RESULT_BEHIND_PATH,
00051     NOT_ON_PATH,
00053     PROTECTION_FAULT,
00055     INVALID_COORD
00056   } Error;
00057 
00059   class Point{
00061     static const double UNDEFINED_LENGTH;
00062     public:
00064       Point() : s(UNDEFINED_LENGTH){};
00066       Point(const Vector& position, const double d = UNDEFINED_LENGTH) : s(d), p(position){};
00068       ~Point(){};
00069 
00071       const Vector& getPosition() const { return p; };
00073       Point& operator =(const Point& i){
00074         p = i.p;
00075         s = i.s;
00076         index = i.index;
00077         return (*this);
00078       }
00080       double s;
00083       int index;
00085       Vector p;
00086   };
00087 
00088   /*****************************
00089    * TRAVERSAL
00090    ******************************/
00091 
00095   void Step(Point &in_pt, const double delta) const;
00096   
00104   virtual void Jump(Point &in_pt, const double dist) const;
00105 
00106   /*****************************
00107    GLOBAL MANIPULATION
00108    *****************************/
00109 
00115   void Reduce(const double dist, LineContext *lc_array);
00116 
00117   
00122   virtual void Splice(const double begin, const double end);
00123 
00131   static Path Combine(const Path& p1, const Path& p2);
00132     
00133   /*****************************
00134    GLOBAL PROPERTIES
00135    *****************************/
00136 
00138   virtual double Length(void) const;
00140   virtual double Curvature(void) const;
00141 
00145   virtual LineContext * ClosestDistance(LineContext *lc_array) const;
00146 
00151   virtual Intersection Collide(const double radius, LineContext *lc_array) const;
00152 
00158   virtual double GetDistance(const Path& path, Point &ret1, Point &ret2) const;
00159 
00162   void SetProtectedLength(const double len);
00163 
00164 
00165   /*****************************
00166    POINT ACQUISITION FUNCTIONS
00167    *****************************/
00168   
00172   virtual Point ProjectPoint(const Vector &p) const;
00173 
00178   virtual Point GetPoint(const Vector& p) const;
00179 
00183   virtual Point GetPoint(const double d) const;
00184 
00188   Point operator [](const double s) const;
00189 
00193   Point operator [](const Vector& v) const;
00194 
00195 
00196   /*****************************
00197    PROPERTIES OF PATH AT A POINT
00198    *****************************/
00199 
00203   virtual Vector Tangent(const Point& p) const;
00204 
00208   virtual Vector Tangent(const double d) const;
00209 
00210   /*****************************
00211    PATH CONSTRUCTION
00212    *****************************/
00213 
00216   void AddSample(const Vector& pos);
00217 
00220   Path& operator +=(const Vector& v);
00221 
00224   Path& operator +=(const Path& app);
00225 
00228   Path operator +(const Path& app) const;
00229   
00233   virtual Path Subsection(const double begin, const double end) const;
00234 
00235   /*****************************
00236    AUXILIARY
00237    *****************************/
00238 
00241   void Render(const double color[]) const;
00242 
00244   void Render(void) const;
00245 
00248   virtual ConStruct ToConstruct() const;
00249 
00253   void SetColor(const Vector& color, double opacity);
00254 
00257   virtual Path Clone(void) const;
00258 
00260   static const double BEGIN;
00261 
00263   static const double END;
00264 
00265 
00267   Path();
00268 
00270   Path(const Path& path);
00271 
00273   Path(const ConStruct& con);
00274 
00276   virtual ~Path();
00277 
00278 protected:  
00280   double fixed_length;
00281 
00283   struct Samples{
00285     std::vector<Vector> points;
00287     std::vector<double> s;
00289     int refcount;
00291     double color[4];
00292   };
00293 
00295   Samples *samples;
00296   
00297 private:
00301   int GetIndex(const double s) const;
00302 };
00303 
00304 //AbstractFactory for paths
00305 //If you do not know what this is, stop working with this code
00306 //read "Design Patterns" and come back later
00307 
00308 class PathFactory{
00309 public:
00310   virtual Path CreatePath(const ConStruct& con) const = 0;
00311 protected:
00312   PathFactory();
00313   virtual ~PathFactory();
00314 };
00315 #endif

Generated on Fri Jan 12 14:15:02 2007 for Construct by  doxygen 1.4.3-20050530