00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ESTAR_GRID_NODE_HPP
00022 #define ESTAR_GRID_NODE_HPP
00023
00024
00025 #include <estar/CSpace.hpp>
00026 #include <boost/shared_ptr.hpp>
00027
00028
00029 namespace estar {
00030
00031
00035 class GridNode
00036 {
00037 public:
00038 GridNode() {}
00039
00040 GridNode(ssize_t _ix, ssize_t _iy, vertex_t _vertex)
00041 : ix(_ix), iy(_iy), vertex(_vertex) {}
00042
00043 friend std::ostream & operator << (std::ostream & os, const GridNode & gn);
00044
00045 ssize_t ix, iy;
00046 vertex_t vertex;
00047 };
00048
00049
00055 struct grid_postransform {
00056 virtual ~grid_postransform() {}
00057 virtual std::pair<double, double>
00058 operator()(double ix, double iy) const = 0;
00059 };
00060
00061
00062 struct grid_bbox_compute {
00063 virtual ~grid_bbox_compute() {}
00064 virtual void operator()(double & x0, double & y0,
00065 double & x1, double & y1) const = 0;
00066 };
00067
00068
00072 class GridCSpace
00073 : public CustomCSpace<boost::shared_ptr<GridNode> >
00074 {
00075 public:
00076 GridCSpace(boost::shared_ptr<grid_postransform const> postransform,
00077 boost::shared_ptr<grid_bbox_compute const> bbox_compute)
00078 : m_postransform(postransform), m_bbox_compute(bbox_compute) {}
00079
00080 std::pair<double, double> ComputePosition(vertex_t vertex) const {
00081 boost::shared_ptr<GridNode const> const gg(Lookup(vertex));
00082 return (*m_postransform)(gg->ix, gg->iy);
00083 }
00084
00085 void ComputeBBox(double & x0, double & y0, double & x1, double & y1) const
00086 { (*m_bbox_compute)(x0, y0, x1, y1); }
00087
00088 protected:
00089 boost::shared_ptr<grid_postransform const> m_postransform;
00090 boost::shared_ptr<grid_bbox_compute const> m_bbox_compute;
00091 };
00092
00093 }
00094
00095 #endif // ESTAR_GRID_NODE_HPP