estar/Grid.hpp

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2007 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_HPP
00022 #define ESTAR_GRID_HPP
00023 
00024 
00025 #include <estar/GridNode.hpp>
00026 #include <boost/shared_ptr.hpp>
00027 
00028 
00029 namespace estar {
00030   
00031   
00032   class Algorithm;
00033   class Kernel;
00034   template<typename value_t> class flexgrid;
00035   
00036   
00037   class Grid
00038   {
00039   public:
00040     typedef enum {
00041       FOUR,
00042       EIGHT,
00043       SIX
00044     } neighborhood_t;
00045     
00048     explicit Grid(neighborhood_t neighborhood);
00049     
00051     Grid(ssize_t xbegin, ssize_t xend,
00052          ssize_t ybegin, ssize_t yend,
00053          neighborhood_t neighborhood,
00054          double meta);
00055     
00061     void Init(ssize_t xbegin, ssize_t xend,
00062               ssize_t ybegin, ssize_t yend,
00063               double meta);
00064     
00081     size_t AddRange(ssize_t xbegin, ssize_t xend,
00082                     ssize_t ybegin, ssize_t yend,
00083                     double meta,
00084                     Algorithm & algo, Kernel const & kernel);
00085     
00097     bool AddNode(ssize_t ix, ssize_t iy, double meta,
00098                  Algorithm & algo, Kernel const & kernel);
00099     
00100     
00101     ssize_t GetXBegin() const;
00102     
00103     ssize_t GetXEnd() const;
00104     
00105     ssize_t GetYBegin() const;
00106     
00107     ssize_t GetYEnd() const;
00108 
00122     boost::shared_ptr<GridNode const> GetNode(ssize_t ix, ssize_t iy) const;
00123     
00124     boost::shared_ptr<GridCSpace const> GetCSpace() const { return m_cspace; }
00125     
00126     boost::shared_ptr<GridCSpace> GetCSpace() { return m_cspace; }
00127     
00132     int ComputeGradient(ssize_t ix, ssize_t iy,
00133                         double & gradx, double & grady) const;
00134     
00139     bool ComputeGradient(boost::shared_ptr<GridNode const> node,
00140                          double & gradx, double & grady) const;
00141     
00146     int ComputeStableScaledGradient(ssize_t ix, ssize_t iy,
00148                                     double stepsize,
00150                                     double & gx,
00152                                     double & gy,
00154                                     double & dx,
00156                                     double & dy) const;
00157 
00162     int ComputeStableScaledGradient(boost::shared_ptr<GridNode const> node,
00163                                     double stepsize,
00164                                     double & gx,
00165                                     double & gy,
00166                                     double & dx,
00167                                     double & dy) const;
00168     
00169     neighborhood_t GetNeighborhood() const { return m_neighborhood; }
00170     
00171   private:
00172     typedef GridCSpace::vertex_data_t vertex_data_t;
00173     typedef flexgrid<vertex_data_t> flexgrid_t;
00174 
00175     struct offset {
00176       offset(ssize_t _dx, ssize_t _dy): dx(_dx), dy(_dy) {}
00177       ssize_t dx, dy;
00178     };
00179     
00180     typedef std::vector<offset> nbor_offset_t;
00181     
00182     neighborhood_t const m_neighborhood;
00183     nbor_offset_t m_nbor_offset;
00184     
00185     boost::shared_ptr<flexgrid_t> m_flexgrid;
00186     boost::shared_ptr<GridCSpace> m_cspace;
00187     
00188     
00193     vertex_data_t DoAddNode(ssize_t ix, ssize_t iy, double meta);
00194     
00195     void InitNborStuff();
00196   };
00197   
00198   
00199 } // namespace estar
00200 
00201 #endif // ESTAR_GRID_HPP

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