libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
ThreeDGrid.hpp
1 #ifndef GRID_HPP
2 #define GRID_HPP
3 
4 #include <vector>
5 
6 
7 #include <Eigen/Core>
8 
9 #include "API/Grids/ThreeDCell.hpp"
10 #include "API/Grids/BaseGrid.hpp"
11 
22 namespace API
23 {
24  class ThreeDGrid : public BaseGrid
25  {
26 
27  public:
28  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
29 
30  ThreeDGrid();
31  ThreeDGrid( Eigen::Vector3i size, std::vector<double> envSize );
32  ThreeDGrid( double samplingRate, std::vector<double> envSize );
33  ThreeDGrid( const ThreeDGrid& grid );
34 
35  virtual ~ThreeDGrid();
36 
37  void createAllCells();
38 
39  Eigen::Vector3d getCellSize() { return _cellSize; }
40 
41  unsigned int getXNumberOfCells() const {return _nbCellsX;}
42  unsigned int getYNumberOfCells() const {return _nbCellsY;}
43  unsigned int getZNumberOfCells() const {return _nbCellsZ;}
44 
45  ThreeDCell* getCell(unsigned int x, unsigned int y, unsigned int z) const;
46  ThreeDCell* getCell(Eigen::Vector3i cell) const;
47  ThreeDCell* getCell(const Eigen::Vector3d& pos) const;
48  ThreeDCell* getCell(double* pos) const;
49 
50  Eigen::Vector3i getCellCoord(ThreeDCell* ptrCell) const;
51  ThreeDCell* getNeighbour(const Eigen::Vector3i& pos, unsigned int i) const;
52  Eigen::Vector3d getCoordinates(ThreeDCell* cell) const;
53 
54  unsigned int getXlineOfCell(unsigned int ith);
55  unsigned int getYlineOfCell(unsigned int ith);
56  unsigned int getZlineOfCell(unsigned int ith);
57 
58  virtual void draw();
59 
60  bool writeToXmlFile(std::string file);
61  bool loadFromXmlFile(std::string file);
62 
63  protected:
64  virtual ThreeDCell* createNewCell(unsigned int index, unsigned int x, unsigned int y, unsigned int z );
65  Eigen::Vector3d computeCellCorner(unsigned int x, unsigned int y, unsigned int z);
66 
67  Eigen::Vector3d _originCorner;
68  Eigen::Vector3d _cellSize;
69 
70  unsigned int _nbCellsX;
71  unsigned int _nbCellsY;
72  unsigned int _nbCellsZ;
73  };
74 }
75 
76 #endif // GRID_HPP
bool loadFromXmlFile(std::string file)
Reads the grid from an xml file.
Definition: ThreeDGrid.cpp:523
virtual ThreeDCell * createNewCell(unsigned int index, unsigned int x, unsigned int y, unsigned int z)
Virtual function that creates a new Cell.
Definition: ThreeDGrid.cpp:299
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ThreeDGrid()
Constructor.
Definition: ThreeDGrid.cpp:21
ThreeDCell * getNeighbour(const Eigen::Vector3i &pos, unsigned int i) const
Get Neighboor Cell.
Definition: ThreeDGrid.cpp:335
Eigen::Vector3d computeCellCorner(unsigned int x, unsigned int y, unsigned int z)
Computes the corner of a cell.
Definition: ThreeDGrid.cpp:317
Definition: ThreeDGrid.hpp:24
void createAllCells()
Creates All Cells.
Definition: ThreeDGrid.cpp:145
Definition: BaseGrid.hpp:15
Definition: ThreeDCell.hpp:25
bool writeToXmlFile(std::string file)
Writes the grid to en xml file.
Definition: ThreeDGrid.cpp:445
ThreeDCell * getCell(unsigned int x, unsigned int y, unsigned int z) const
Retruns the Cell at (x,y,z)
Definition: ThreeDGrid.cpp:188
Eigen::Vector3d getCoordinates(ThreeDCell *cell) const
Retrive the X Y Z coordinate of the cell from its index.
Definition: ThreeDGrid.cpp:372
Eigen::Vector3i getCellCoord(ThreeDCell *ptrCell) const
Get place in grid.
Definition: ThreeDGrid.cpp:272
virtual void draw()
Draw a openGl view of the grid.
Definition: ThreeDGrid.cpp:403
virtual ~ThreeDGrid()
Destructor.
Definition: ThreeDGrid.cpp:29