libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
TwoDGrid.hpp
1 #ifndef TWODGRID_HPP
2 #define TWODGRID_HPP
3 
4 #include <vector>
5 
6 #include <Eigen/Core>
7 
8 #include "API/Grids/BaseGrid.hpp"
9 
10 #include "API/Grids/TwoDCell.hpp"
11 
12 
23 namespace API
24 {
25  class TwoDGrid : public BaseGrid
26  {
27  public:
28  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
29  TwoDGrid();
30  TwoDGrid( Eigen::Vector2i size, std::vector<double> envSize );
31  TwoDGrid( double samplingRate, std::vector<double> envSize );
32 
33  ~TwoDGrid();
34 
35  void createAllCells();
36 
37  Eigen::Vector2d getCellSize() { return _cellSize; }
38 
39  TwoDCell* getCell(const Eigen::Vector2i& cell);
40  TwoDCell* getCell(int x, int y );
41  TwoDCell* getCell(Eigen::Vector2d pos);
42  TwoDCell* getCell(double* pos);
43  TwoDCell* getCell(unsigned int index);
44 
45  bool isCellCoordInGrid(const Eigen::Vector2i& coord);
46 
47  Eigen::Vector2i getCellCoord(TwoDCell* ptrCell);
48  int getNumberOfCells();
49  TwoDCell* getNeighbour(const Eigen::Vector2i& pos, int i);
50  Eigen::Vector2d getCoordinates(TwoDCell* cell);
51 
52  virtual void draw();
53 
54  protected:
55  virtual TwoDCell* createNewCell(unsigned int index,unsigned int x,unsigned int y );
56  Eigen::Vector2d computeCellCorner(int x, int y );
57 
58  Eigen::Vector2d _originCorner;
59  Eigen::Vector2d _cellSize;
60 
61  unsigned int _nbCellsX;
62  unsigned int _nbCellsY;
63 
64  };
65 }
66 
67 #endif // TWODGRID_HPP
virtual TwoDCell * createNewCell(unsigned int index, unsigned int x, unsigned int y)
Virtual function that creates a new Cell.
Definition: TwoDGrid.cpp:261
bool isCellCoordInGrid(const Eigen::Vector2i &coord)
Is a Coord inside the Grid (used to debug)
Definition: TwoDGrid.cpp:230
TwoDCell * getNeighbour(const Eigen::Vector2i &pos, int i)
Get Neighboor Cell.
Definition: TwoDGrid.cpp:304
void createAllCells()
Creates All Cells.
Definition: TwoDGrid.cpp:115
Eigen::Vector2i getCellCoord(TwoDCell *ptrCell)
Get place in grid.
Definition: TwoDGrid.cpp:240
Eigen::Vector2d computeCellCorner(int x, int y)
Computes the corner of a cell.
Definition: TwoDGrid.cpp:278
Definition: TwoDCell.hpp:19
Definition: BaseGrid.hpp:15
~TwoDGrid()
Destructor.
Definition: TwoDGrid.cpp:32
Definition: TwoDGrid.hpp:25
EIGEN_MAKE_ALIGNED_OPERATOR_NEW TwoDGrid()
Constructor.
Definition: TwoDGrid.cpp:24
int getNumberOfCells()
Get Number Of Cells.
Definition: TwoDGrid.cpp:295
Eigen::Vector2d getCoordinates(TwoDCell *cell)
Retrive the X Y Z coordinate of the cell from its index.
Definition: TwoDGrid.cpp:336