worked on grid creation

fixed some issues with stairs
fixed/added LINT
This commit is contained in:
k-a-z-u
2017-07-27 18:40:56 +02:00
parent 3a92199777
commit c21925e86f
5 changed files with 114 additions and 38 deletions

View File

@@ -60,7 +60,7 @@ namespace Floorplan {
if (i.type == Type::ERROR) {++err;}
}
if (err > 0) {
throw Exception("detected floorplan errors");
// throw Exception("detected floorplan errors");
}
}
@@ -94,7 +94,7 @@ namespace Floorplan {
// check stairs
for (const Stair* s : floor->stairs) {
checkStair(res, floor, s);
checkStair(res, map, floor, s);
}
// check elevators
@@ -169,7 +169,14 @@ namespace Floorplan {
}
static void checkStair(Issues& res, const Floor* floor, const Stair* stair) {
static void checkStair(Issues& res, const IndoorMap* map, const Floor* floor, const Stair* stair) {
// list of all heights where there is a floor;
std::vector<int> floorAtHeight_cm;
for (const Floor* f : map->floors) {
const int floorZ_cm = std::round(f->atHeight * 100);
floorAtHeight_cm.push_back(floorZ_cm); // integer height in cm
}
if (stair->getParts().empty()) {
res.push_back(Issue(Type::ERROR, floor, "stair does not contain any parts! [empty stair]"));
@@ -182,13 +189,20 @@ namespace Floorplan {
const Floorplan::Quad3& quadS = quads.front();
const Floorplan::Quad3& quadE = quads.back();
// disconnected start?
// start == end?
if (quadS.p1.z == quadE.p3.z) {
res.push_back(Issue(Type::ERROR, floor, "stair start and end must not belong to the same floor!"));
}
// disconnected start? (MUST belong to the floor the stair is attached to)
if (quadS.p1.z != floor->getStartingZ()) {
res.push_back(Issue(Type::ERROR, floor, "stair is not connected to the starting floor's ground! [open stair start]"));
}
// disconnected end?
if (quadE.p3.z != floor->getEndingZ()) {
// disconnected end? (must be long to ANY other floor within the map)
//if (quadE.p3.z != floor->getEndingZ()) {
const int stairEndingZ_cm = std::round( quadE.p3.z * 100 );
if(std::find(floorAtHeight_cm.begin(), floorAtHeight_cm.end(), stairEndingZ_cm) == floorAtHeight_cm.end()) {
res.push_back(Issue(Type::ERROR, floor, "stair is not connected to the ending floor's ground! [open stair end]"));
}