From 6f06984c4ea80486fe9f830012c621a7c214efa0 Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Thu, 27 Jul 2017 18:41:48 +0200 Subject: [PATCH] adjusted some models due to indoor changes --- mapview/2D/MV2DElementStair.h | 20 +++++++++++++++++--- mapview/3DGrid/GridModel.h | 2 +- mapview/model/MMFloor.h | 2 +- mapview/model/MMFloorStair.h | 4 ++-- mapview/model/MMFloorStairs.h | 7 ++++--- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/mapview/2D/MV2DElementStair.h b/mapview/2D/MV2DElementStair.h index e7f982c..566c4cf 100644 --- a/mapview/2D/MV2DElementStair.h +++ b/mapview/2D/MV2DElementStair.h @@ -7,11 +7,24 @@ #include "MapViewElementHelper.h" #include +/** is the given stair's end connected to ANY of the floorplan's floors? */ +static inline bool stairEndConnected(const Floorplan::IndoorMap* map, const Floorplan::Floor* floor, const Floorplan::Stair* stair) { + const int stairEnd_cm = std::round( (floor->atHeight + stair->getParts().back().end.z) * 100 ); + std::vector floorsAtHeight_cm; + for (const Floorplan::Floor* f : map->floors) { + const int height_cm = std::round(f->atHeight*100); + floorsAtHeight_cm.push_back(height_cm); + } + const bool connected = std::find(floorsAtHeight_cm.begin(), floorsAtHeight_cm.end(), stairEnd_cm) != floorsAtHeight_cm.end(); + return connected; +} + class MV2DElementStair : public MV2DElement, public HasMoveableNodes { private: bool sel = false; + Floorplan::IndoorMap* map; Floorplan::Floor* floor; Floorplan::Stair* stair; //int selPart = -1; @@ -19,8 +32,8 @@ private: public: - /** ctor with the AP to render/edit */ - MV2DElementStair(Floorplan::Floor* floor, Floorplan::Stair* stair) : floor(floor), stair(stair) {;} + /** ctor with the stair to render/edit */ + MV2DElementStair(Floorplan::IndoorMap* map, Floorplan::Floor* floor, Floorplan::Stair* stair) : map(map), floor(floor), stair(stair) {;} /** get the element's 3D bounding box */ @@ -116,7 +129,8 @@ public: // LINT disconnected end if (i == (int) parts.size() - 1) { - if (quad.p3.z != floor->getEndingZ()) { + //if (quad.p3.z != floor->getEndingZ()) { + if (!stairEndConnected(map, floor, stair)) { p.drawLine(quad.p3, quad.p4); } } diff --git a/mapview/3DGrid/GridModel.h b/mapview/3DGrid/GridModel.h index 20a3d09..db1fbb2 100644 --- a/mapview/3DGrid/GridModel.h +++ b/mapview/3DGrid/GridModel.h @@ -21,7 +21,7 @@ class GridModel { private: - int gridSize_cm = 30; // TODO + int gridSize_cm = 20; // TODO Grid grid; Floorplan::IndoorMap* im; diff --git a/mapview/model/MMFloor.h b/mapview/model/MMFloor.h index adc978b..8082bb5 100644 --- a/mapview/model/MMFloor.h +++ b/mapview/model/MMFloor.h @@ -44,7 +44,7 @@ public: new MMFloorBeacons(this, floor); new MMFloorFingerprints(this, floor); new MMFloorPOIs(this, floor); - new MMFloorStairs(this, floor); + new MMFloorStairs(this, map, floor); new MMFloorElevators(this, floor); new MMFloorGroundTruthPoints(this, floor); diff --git a/mapview/model/MMFloorStair.h b/mapview/model/MMFloorStair.h index c43f6c6..98a1aa6 100644 --- a/mapview/model/MMFloorStair.h +++ b/mapview/model/MMFloorStair.h @@ -28,8 +28,8 @@ private: public: /** ctor with the underlying model */ - MMFloorStair(MapLayer* parent, Floorplan::Floor* floor, Floorplan::StairFreeform* stair) : - MapModelElement(parent), floor(floor), stair(stair), mv2d(floor, stair), mv3d(floor, stair) { + MMFloorStair(MapLayer* parent, Floorplan::IndoorMap* map, Floorplan::Floor* floor, Floorplan::StairFreeform* stair) : + MapModelElement(parent), floor(floor), stair(stair), mv2d(map, floor, stair), mv3d(floor, stair) { ; diff --git a/mapview/model/MMFloorStairs.h b/mapview/model/MMFloorStairs.h index 7298da2..c138719 100644 --- a/mapview/model/MMFloorStairs.h +++ b/mapview/model/MMFloorStairs.h @@ -13,17 +13,18 @@ class MMFloorStairs : public MapLayer { private: + Floorplan::IndoorMap* map; Floorplan::Floor* floor; public: /** ctor with the underlying model */ - MMFloorStairs(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_STAIRS), floor(floor) { + MMFloorStairs(MapLayer* parent, Floorplan::IndoorMap* map, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_STAIRS), map(map), floor(floor) { // add all floors for (Floorplan::Stair* stair : floor->stairs) { if (dynamic_cast(stair)) { - addElement( new MMFloorStair(this, floor, (Floorplan::StairFreeform*)stair) ); + addElement( new MMFloorStair(this, map, floor, (Floorplan::StairFreeform*)stair) ); } } @@ -35,7 +36,7 @@ public: floor->stairs.push_back(stair); // add to myself as element - MMFloorStair* mm = new MMFloorStair(this, floor, stair); + MMFloorStair* mm = new MMFloorStair(this, map, floor, stair); addElement(mm); return mm;