From 91e598a828355c5bf67dfde1152b47409434c6a0 Mon Sep 17 00:00:00 2001 From: Markus Bullmann Date: Wed, 19 Jun 2019 16:43:29 +0200 Subject: [PATCH] Opened windows --- code/Plotty.h | 63 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/code/Plotty.h b/code/Plotty.h index 734aae5..bd53f4a 100644 --- a/code/Plotty.h +++ b/code/Plotty.h @@ -525,6 +525,8 @@ public: void plot() { + splot.getObjects().reOrderByZIndex(); + this->mapOutlineConcrete.getStroke().setColor(settings.outlineColor); this->mapOutlineDrywall.getStroke().setColor(settings.outlineColor); this->mapOutlineGlass.getStroke().setColor(settings.outlineColor); @@ -578,7 +580,7 @@ public: // K::GnuplotPoint3(bbox.getMin().x, bbox.getMin().y, bbox.getMin().z), // K::GnuplotPoint3(bbox.getMax().x, bbox.getMax().y, bbox.getMax().z) // ); - + splot.getAxisX().setRange(K::GnuplotAxis::Range(bbox.getMin().x, bbox.getMax().x)); splot.getAxisY().setRange(K::GnuplotAxis::Range(bbox.getMin().y, bbox.getMax().y)); splot.getAxisZ().setRange(K::GnuplotAxis::Range(0 /*bbox.getMin().z*/, bbox.getMax().z)); @@ -627,9 +629,8 @@ public: // plot obstacles? if (settings.obstacles) { for (Floorplan::FloorObstacle* obs : floor->obstacles) { - //Floorplan::FloorObstacleLine* line = dynamic_cast(obs); - Floorplan::FloorObstacleWall* line = dynamic_cast(obs); - if (line) { + Floorplan::FloorObstacleWall* wall = dynamic_cast(obs); + if (wall) { if (floor->atHeight < settings.minZ) {continue;} if (floor->atHeight > settings.maxZ) {continue;} @@ -652,20 +653,48 @@ public: const float v = 140 + vo; - // drawing outlines as polygon is a hack for correct depth-order in gnuplot - K::GnuplotColor color = (settings.outlineColorCustom) ? (settings.outlineColor) : (K::GnuplotColor::fromRGB(v,v,v)); - K::GnuplotFill filler = K::GnuplotFill(K::GnuplotFillStyle::EMPTY_BORDER, color); - K::GnuplotStroke stroke(K::GnuplotDashtype::NONE, 6, color); - //K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(K::GnuplotFill::NONE(), stroke); - K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(filler, stroke); - //K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(K::GnuplotFill::NONE(), K::GnuplotStroke::NONE()); - gpol->add(K::GnuplotCoordinate3(line->from.x, line->from.y, floor->atHeight, K::GnuplotCoordinateSystem::FIRST)); - gpol->add(K::GnuplotCoordinate3(line->to.x, line->to.y, floor->atHeight, K::GnuplotCoordinateSystem::FIRST)); - gpol->close(); - gpol->setZIndex(floor->atHeight); // above the ground polygon - //gpol->setFront(true); - splot.getObjects().add(gpol); + // New wall type with integrated doors + std::vector pts; + pts.push_back(wall->from); + for (const Floorplan::FloorObstacleWallDoor* door : wall->doors) { + pts.push_back(door->getStart(wall)); + pts.push_back(door->getEnd(wall)); + } + for (const Floorplan::FloorObstacleWallWindow* win : wall->windows) { + pts.push_back(win->getStart(wall)); + pts.push_back(win->getEnd(wall)); + } + pts.push_back(wall->to); + + auto comp = [&](const Point2 p1, const Point2 p2) { + return wall->from.getDistance(p1) < wall->from.getDistance(p2); + }; + std::sort(pts.begin(), pts.end(), comp); + + + for (size_t i = 0; i < pts.size(); i += 2) { + Point2 start = pts[i]; + Point2 end = pts[i + 1]; + + // draw line + // drawing obstacles as polygon is a hack for correct depth-order in gnuplot + K::GnuplotColor color = (settings.outlineColorCustom) ? (settings.outlineColor) : (K::GnuplotColor::fromRGB(v, v, v)); + K::GnuplotFill filler = K::GnuplotFill(K::GnuplotFillStyle::EMPTY_BORDER, color); + K::GnuplotStroke stroke(K::GnuplotDashtype::NONE, 6, color); + //K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(K::GnuplotFill::NONE(), stroke); + K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(filler, stroke); + //K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(K::GnuplotFill::NONE(), K::GnuplotStroke::NONE()); + + gpol->add(K::GnuplotCoordinate3(start.x, start.y, floor->atHeight, K::GnuplotCoordinateSystem::FIRST)); + gpol->add(K::GnuplotCoordinate3(end.x, end.y, floor->atHeight, K::GnuplotCoordinateSystem::FIRST)); + gpol->close(); + gpol->setZIndex(floor->atHeight); // above the ground polygon + //gpol->setFront(true); + splot.getObjects().add(gpol); + } + + } }