removed gridSize from the template arguments

- not needed and code much cleaner
some minor changes
new test-cases
This commit is contained in:
2016-01-25 15:53:12 +01:00
parent 9947dced15
commit 5aedce47f1
16 changed files with 167 additions and 66 deletions

View File

@@ -11,7 +11,7 @@
#include "../../misc/Debug.h"
template <int gridSize_cm, typename T> class GridFactory {
template <typename T> class GridFactory {
/** logging name */
static constexpr const char* name = "GridFac";
@@ -19,19 +19,21 @@ template <int gridSize_cm, typename T> class GridFactory {
private:
/** the grid to build into */
Grid<gridSize_cm, T>& grid;
Grid<T>& grid;
public:
/** ctor with the grid to fill */
GridFactory(Grid<gridSize_cm, T>& grid) : grid(grid) {;}
GridFactory(Grid<T>& grid) : grid(grid) {;}
/** add the given floor at the provided height (in cm) */
void addFloor(const Floor& floor, const float z_cm) {
Log::add(name, "adding floor at height " + std::to_string(z_cm));
const float gridSize_cm = grid.getGridSize_cm();
// build grid-points
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) {
@@ -55,6 +57,8 @@ public:
Log::add(name, "connecting all adjacent nodes at height " + std::to_string(z_cm));
const int gridSize_cm = grid.getGridSize_cm();
// connect adjacent grid-points
for (int idx = 0; idx < grid.getNumNodes(); ++idx) {
@@ -132,6 +136,8 @@ public:
int idx2 = -1;
const int idx3 = n2.getIdx();
const int gridSize_cm = grid.getGridSize_cm();
// move upards in gridSize steps
for (int z = gridSize_cm; z < zDiff; z+= gridSize_cm) {
@@ -161,11 +167,13 @@ public:
}
/** add the inverted version of the given z-layer */
void addInverted(const Grid<gridSize_cm, T>& gIn, const float z_cm) {
void addInverted(const Grid<T>& gIn, const float z_cm) {
// get the original grid's bbox
BBox3 bb = gIn.getBBox();
const int gridSize_cm = grid.getGridSize_cm();
// build new grid-points
for(int x_cm = bb.getMin().x; x_cm <= bb.getMax().x; x_cm += gridSize_cm) {
for (int y_cm = bb.getMin().y; y_cm < bb.getMax().y; y_cm += gridSize_cm) {