removed gridSize from the template arguments
- not needed and code much cleaner some minor changes new test-cases
This commit is contained in:
@@ -11,8 +11,8 @@ TEST(GridImportance, a) {
|
||||
|
||||
|
||||
|
||||
Grid<20, GP> g;
|
||||
GridFactory<20, GP> gf(g);
|
||||
Grid<GP> g(20);
|
||||
GridFactory<GP> gf(g);
|
||||
FloorplanFactorySVG fpf(getDataFile("fp1.svg"), 6);
|
||||
|
||||
Floor f1 = fpf.getFloor("1");
|
||||
|
||||
@@ -51,13 +51,13 @@ public:
|
||||
|
||||
}
|
||||
|
||||
template <int gridSize_cm, typename T> Plot& showGrid(Grid<gridSize_cm, T>& g) {
|
||||
template <typename T> Plot& showGrid(Grid<T>& g) {
|
||||
addEdges(g);
|
||||
addNodes(g);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <int gridSize_cm, typename T> Plot& addEdges(Grid<gridSize_cm, T>& g) {
|
||||
template <typename T> Plot& addEdges(Grid<T>& g) {
|
||||
|
||||
// prevent adding edges twice
|
||||
std::set<size_t> done;
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
template <int gridSize_cm, typename T> Plot& addNodes(Grid<gridSize_cm, T>& g) {
|
||||
template <typename T> Plot& addNodes(Grid<T>& g) {
|
||||
|
||||
for (GP& n1 : g) {
|
||||
K::GnuplotPoint3 p1(n1.x_cm, n1.y_cm, n1.z_cm);
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
template <int gridSize_cm, typename T> Plot& build(Grid<gridSize_cm, T>& g) {
|
||||
template <typename T> Plot& build(Grid<T>& g) {
|
||||
|
||||
std::set<uint64_t> done;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
TEST(TestAll, Nav) {
|
||||
|
||||
|
||||
Grid<20, GP> g;
|
||||
Grid<GP> g(20);
|
||||
|
||||
// dijkstra mapper
|
||||
class TMP {
|
||||
Grid<20, GP>& grid;
|
||||
Grid<GP>& grid;
|
||||
public:
|
||||
TMP(Grid<20, GP>& grid) : grid(grid) {;}
|
||||
TMP(Grid<GP>& grid) : grid(grid) {;}
|
||||
int getNumNeighbors(const GP& node) const {return node.getNumNeighbors();}
|
||||
const GP* getNeighbor(const GP& node, const int idx) const {return &grid.getNeighbor(node, idx);}
|
||||
float getWeightBetween(const GP& n1, const GP& n2) const {
|
||||
@@ -29,7 +29,7 @@ TEST(TestAll, Nav) {
|
||||
}
|
||||
} tmp(g);
|
||||
|
||||
GridFactory<20, GP> gf(g);
|
||||
GridFactory<GP> gf(g);
|
||||
|
||||
// load floorplan
|
||||
FloorplanFactorySVG fpf(getDataFile("fp1.svg"), 6);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
TEST(Grid, add) {
|
||||
|
||||
Grid<20, GP> grid;
|
||||
Grid<GP> grid(20);
|
||||
ASSERT_EQ(0, grid.add(GP()));
|
||||
ASSERT_EQ(1, grid.add(GP()));
|
||||
ASSERT_EQ(2, grid.add(GP()));
|
||||
@@ -28,7 +28,7 @@ TEST(Grid, add) {
|
||||
|
||||
TEST(Grid, BBox) {
|
||||
|
||||
Grid<20, GP> grid;
|
||||
Grid<GP> grid(20);
|
||||
int idx = grid.add(GP(40,40,40));
|
||||
ASSERT_EQ(30, grid.getBBox(idx).getMin().x);
|
||||
ASSERT_EQ(50, grid.getBBox(idx).getMax().x);
|
||||
@@ -40,7 +40,7 @@ TEST(Grid, BBox) {
|
||||
|
||||
TEST(Grid, connectBiDir) {
|
||||
|
||||
Grid<1, GP> grid;
|
||||
Grid<GP> grid(1);
|
||||
|
||||
int idx1 = grid.add(GP( 0, 0, 0));
|
||||
int idx2 = grid.add(GP( 0, 1, 0));
|
||||
@@ -68,7 +68,7 @@ TEST(Grid, connectBiDir) {
|
||||
|
||||
TEST(Grid, disconnectBiDir) {
|
||||
|
||||
Grid<1, GP> grid;
|
||||
Grid<GP> grid(1);
|
||||
|
||||
int idx1 = grid.add(GP( 0, 0, 0));
|
||||
int idx2 = grid.add(GP( 0, 1, 0));
|
||||
@@ -111,7 +111,7 @@ TEST(Grid, disconnectBiDir) {
|
||||
|
||||
TEST(Grid, uid) {
|
||||
|
||||
Grid<20, GP> grid;
|
||||
Grid<GP> grid(20);
|
||||
|
||||
GP gp(20,40,60);
|
||||
uint64_t uid = grid.getUID(gp);
|
||||
@@ -125,7 +125,7 @@ TEST(Grid, uid) {
|
||||
|
||||
TEST(Grid, remove) {
|
||||
|
||||
Grid<1, GP> grid;
|
||||
Grid<GP> grid(1);
|
||||
|
||||
GP gp1( 0, 0, 0);
|
||||
GP gp2( 0, 1, 0);
|
||||
@@ -162,7 +162,7 @@ TEST(Grid, remove) {
|
||||
|
||||
TEST(Grid, neighborIter) {
|
||||
|
||||
Grid<1, GP> grid;
|
||||
Grid<GP> grid(1);
|
||||
|
||||
int idx1 = grid.add(GP( 0, 0, 0));
|
||||
int idx2 = grid.add(GP( 0, 1, 0));
|
||||
@@ -183,7 +183,7 @@ TEST(Grid, neighborIter) {
|
||||
|
||||
TEST(Grid, bbox) {
|
||||
|
||||
Grid<1, GP> grid;
|
||||
Grid<GP> grid(1);
|
||||
|
||||
grid.add(GP( 0, 0, 0));
|
||||
grid.add(GP( 0, 1, 0));
|
||||
@@ -206,7 +206,7 @@ TEST(Grid, bbox) {
|
||||
|
||||
TEST(Grid, nearest) {
|
||||
|
||||
Grid<20, GP> grid;
|
||||
Grid<GP> grid(20);
|
||||
|
||||
GP c1(20,20,20);
|
||||
GP c2(40,40,40);
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
TEST(GridFactory, create) {
|
||||
|
||||
Grid<20, GP> g;
|
||||
Grid<20, GP> gInv;
|
||||
Grid<GP> g(20);
|
||||
Grid<GP> gInv(20);
|
||||
|
||||
GridFactory<20, GP> gf(g);
|
||||
GridFactory<GP> gf(g);
|
||||
FloorplanFactorySVG fpf(getDataFile("fp1.svg"), 4);
|
||||
Floor f1 = fpf.getFloor("1");
|
||||
Floor f2 = fpf.getFloor("2");
|
||||
@@ -24,7 +24,7 @@ TEST(GridFactory, create) {
|
||||
gf.addStairs(s1_2, 20, 340);
|
||||
gf.removeIsolated();
|
||||
|
||||
GridFactory<20, GP> gfInv(gInv);
|
||||
GridFactory<GP> gfInv(gInv);
|
||||
gfInv.addInverted(g, 20);
|
||||
gfInv.addInverted(g, 340);
|
||||
|
||||
|
||||
44
tests/grid/TestImportance.cpp
Normal file
44
tests/grid/TestImportance.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "../Tests.h"
|
||||
|
||||
#include "../../grid/factory/GridImportance.h"
|
||||
#include "../../grid/factory/GridFactory.h"
|
||||
#include "../../floorplan/FloorplanFactorySVG.h"
|
||||
#include "../../nav/dijkstra/Dijkstra.h"
|
||||
#include "../../grid/walk/GridWalkWeighted.h"
|
||||
|
||||
#include "Plot.h"
|
||||
|
||||
TEST(Importance, Doors) {
|
||||
|
||||
|
||||
Grid<GP> g(20);
|
||||
GridFactory<GP> gf(g);
|
||||
|
||||
// load floorplan
|
||||
FloorplanFactorySVG fpf(getDataFile("fp1.svg"), 6);
|
||||
Floor f1 = fpf.getFloor("1");
|
||||
Floor f2 = fpf.getFloor("2");
|
||||
Stairs s1_2 = fpf.getStairs("1_2");
|
||||
|
||||
// build the grid
|
||||
gf.addFloor(f1, 20);
|
||||
//gf.addFloor(f2, 340);
|
||||
gf.addStairs(s1_2, 20, 340);
|
||||
gf.removeIsolated();
|
||||
|
||||
// calculate node importance based on the floorplan (walls, ...)
|
||||
GridImportance gi;
|
||||
gi.addImportance(g, 20);
|
||||
|
||||
|
||||
Plot p;
|
||||
p.gp << "set view 0,0\n";
|
||||
p.build(g);
|
||||
p.addFloor(f1, 20);
|
||||
p.fire();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
TEST(Walk, plot) {
|
||||
|
||||
Grid<20, GP> g;
|
||||
GridFactory<20, GP> gf(g);
|
||||
Grid<GP> g(20);
|
||||
GridFactory<GP> gf(g);
|
||||
|
||||
bool use3D = true;
|
||||
|
||||
@@ -40,9 +40,9 @@ TEST(Walk, plot) {
|
||||
|
||||
// dijkstra mapper
|
||||
class TMP {
|
||||
Grid<20, GP>& grid;
|
||||
Grid<GP>& grid;
|
||||
public:
|
||||
TMP(Grid<20, GP>& grid) : grid(grid) {;}
|
||||
TMP(Grid<GP>& grid) : grid(grid) {;}
|
||||
int getNumNeighbors(const GP& node) const {return node.getNumNeighbors();}
|
||||
const GP* getNeighbor(const GP& node, const int idx) const {return &grid.getNeighbor(node, idx);}
|
||||
float getWeightBetween(const GP& n1, const GP& n2) const {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
TEST(Dijkstra, build) {
|
||||
|
||||
Grid<1, GP> grid;
|
||||
Grid<GP> grid(1);
|
||||
|
||||
int idx1 = grid.add(GP( 0, 0, 0));
|
||||
int idx2 = grid.add(GP( 0, 1, 0));
|
||||
@@ -22,9 +22,9 @@ TEST(Dijkstra, build) {
|
||||
grid.connectBiDir(idx1, idx5);
|
||||
|
||||
class TMP {
|
||||
Grid<1, GP>& grid;
|
||||
Grid<GP>& grid;
|
||||
public:
|
||||
TMP(Grid<1, GP>& grid) : grid(grid) {;}
|
||||
TMP(Grid<GP>& grid) : grid(grid) {;}
|
||||
int getNumNeighbors(const GP& node) const {return node.getNumNeighbors();}
|
||||
const GP* getNeighbor(const GP& node, const int idx) const {return &grid.getNeighbor(node, idx);}
|
||||
float getWeightBetween(const GP& n1, const GP& n2) const {return ((Point3)n1 - (Point3)n2).length();}
|
||||
|
||||
Reference in New Issue
Block a user