estar/GridNode.hpp

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2005 Roland Philippsen <roland dot philippsen at gmx net>
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00017  * USA
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 } // namespace estar
00094 
00095 #endif // ESTAR_GRID_NODE_HPP

doxygen SourceForge.net Logo
E* Interpolated Graph Replanner Wed Dec 12 18:55:40 2007