worked on floorplan (v2)

worked on grid-generation (v2)
new helper methods for geometry
new test cases
This commit is contained in:
2016-07-13 19:11:18 +02:00
parent cc21cbb0ea
commit 34e52cd7f0
26 changed files with 2083 additions and 272 deletions

View File

@@ -9,6 +9,8 @@ static inline std::string getDataFile(const std::string& name) {
return "/mnt/data/workspaces/Indoor/tests/data/" + name;
}
#endif
#endif // TESTS_H

4
tests/api/TestAPI.cpp Normal file
View File

@@ -0,0 +1,4 @@
#ifndef TESTAPI_CPP
#define TESTAPI_CPP
#endif // TESTAPI_CPP

View File

@@ -2,10 +2,17 @@
#include "../Tests.h"
#include "../../floorplan/v2/Floorplan.h"
#include "../../floorplan/v2/FloorplanReader.h"
#include "../../floorplan/v2/FloorplanWriter.h"
#include <cstdlib>
TEST(NewFloorplan, saveAndLoad) {
Floorplan::Reader r;
Floorplan::Writer w;
}
/*
TEST(NewFloorplan, saveAndLoad) {
std::string xml;
@@ -108,6 +115,7 @@ TEST(NewFloorplan, saveAndLoad) {
}
*/

61
tests/geo/TestBBox.cpp Normal file
View File

@@ -0,0 +1,61 @@
#ifdef WITH_TESTS
#include "../Tests.h"
#include "../../geo/BBox2.h"
TEST(BBox, noIntersect) {
BBox2 bb(Point2(1,1), Point2(3,3));
Line2 l1(Point2(0,0), Point2(9,0)); // below
Line2 l2(Point2(0,4), Point2(9,4)); // above
Line2 l3(Point2(0,0), Point2(0,9)); // left
Line2 l4(Point2(4,0), Point2(4,9)); // right
ASSERT_FALSE(bb.intersects(l1));
ASSERT_FALSE(bb.intersects(l2));
ASSERT_FALSE(bb.intersects(l3));
ASSERT_FALSE(bb.intersects(l4));
}
TEST(BBox, noDirectIntersect) {
BBox2 bb(Point2(1,1), Point2(3,3));
Line2 l1(Point2(0,1), Point2(9,1)); // lower
Line2 l2(Point2(0,3), Point2(9,3)); // upper
Line2 l3(Point2(1,0), Point2(1,9)); // left
Line2 l4(Point2(3,0), Point2(3,9)); // right
ASSERT_FALSE(bb.intersects(l1));
ASSERT_FALSE(bb.intersects(l2));
ASSERT_FALSE(bb.intersects(l3));
ASSERT_FALSE(bb.intersects(l4));
}
TEST(BBox, positiveIntersect) {
BBox2 bb(Point2(1,1), Point2(3,3));
Line2 l1(Point2(0,2), Point2(2,2)); // left hit
Line2 l2(Point2(2,2), Point2(4,2)); // right hit
Line2 l3(Point2(2,0), Point2(2,2)); // lower hit
Line2 l4(Point2(2,2), Point2(2,4)); // upper hit
ASSERT_TRUE(bb.intersects(l1));
ASSERT_TRUE(bb.intersects(l2));
ASSERT_TRUE(bb.intersects(l3));
ASSERT_TRUE(bb.intersects(l4));
}
#endif

View File

@@ -130,7 +130,7 @@ TEST(Walk, DISABLED_plot) {
for (int i = 0; i < 5000; ++i) {
pStates.clear();
for (GridWalkState<GP>& state : states) {
state = walk.getDestination(g, state, std::abs(dWalk(gen)), dTurn(gen));
state = walk.getDestination(g, state, std::abs(dWalk(gen)), dTurn(gen), Activity::UNKNOWN);
pStates.add(K::GnuplotPoint3(state.node->x_cm, state.node->y_cm, state.node->z_cm+10));
}
p.gp.draw(p.splot);