initial version

This commit is contained in:
2016-01-21 11:10:55 +01:00
parent 8818a9b216
commit a7dc0cabbb
21 changed files with 1397 additions and 0 deletions

55
grid/factory/GridFactory.h Executable file
View File

@@ -0,0 +1,55 @@
#ifndef GRIDFACTORY_H
#define GRIDFACTORY_H
#include <string>
#include "../../floorplan/Floor.h"
#include "../../geo/Units.h"
#include "../GridNodeBBox.h"
#include "../Grid.h"
template <int gridSize_cm, typename T> class GridFactory {
private:
Grid<gridSize_cm, T>& grid;
public:
/** ctor with the grid to fill */
GridFactory(Grid<gridSize_cm, T>& grid) : grid(grid) {;}
/** add the given floor at the provided height (in cm) */
void addFloor(const Floor& floor, const float z_cm) {
for(int x_cm = 0; x_cm < floor.getWidth_cm(); x_cm += gridSize_cm) {
for (int y_cm = 0; y_cm < floor.getDepth_cm(); y_cm += gridSize_cm) {
// check intersection with the floorplan
GridNodeBBox bbox(GridPoint(x_cm, y_cm, z_cm), gridSize_cm);
if (intersects(bbox, floor)) {continue;}
// add to the grid
grid.add(T(x_cm, y_cm, z_cm));
}
}
int i = 0;
}
private:
/** does the bbox intersect with any of the floor's walls? */
bool intersects(const GridNodeBBox& bbox, const Floor& floor) {
for (const Line2D l : floor.getObstacles()) {
if (bbox.intersects(l)) {return true;}
}
return false;
}
};
#endif // GRIDFACTORY_H