/* * © Copyright 2014 – Urheberrechtshinweis * Alle Rechte vorbehalten / All Rights Reserved * * Programmcode ist urheberrechtlich geschuetzt. * Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner. * Keine Verwendung ohne explizite Genehmigung. * (vgl. § 106 ff UrhG / § 97 UrhG) */ #ifndef FLOORPLAN_3D_DOORS_H #define FLOORPLAN_3D_DOORS_H #include "Walls.h" #include "misc.h" #include "primitives/Cube.h" namespace Floorplan3D { class Doors { Cube::Part cubeParts = (Cube::Part) 63; // leftright,topbottom,rearfront public: std::vector getDoors(const Floorplan::Floor* floor) { std::vector res; for (const Floorplan::FloorObstacle* o: floor->obstacles) { const Floorplan::FloorObstacleWall* wall = dynamic_cast(o); if (wall) { for (const Floorplan::FloorObstacleWallDoor* door : wall->doors) { res.push_back(getDoor(floor, wall, door)); } } } return res; } Obstacle3D getDoor(const Floorplan::Floor* f, const Floorplan::FloorObstacleWall* wall, const Floorplan::FloorObstacleWallDoor* door) { FloorPos fpos(f); const float thickness_m = 0.1; const Point2 from = door->getStart(wall); const Point2 to = door->getEnd(wall); const Point2 cen2 = (from+to)/2; const float rad = std::atan2(to.y - from.y, to.x - from.x); const float deg = rad * 180 / M_PI; // cube's destination center const double height = door->height; const double cenZ = (fpos.z1 + height/2); const Point3 pos(cen2.x, cen2.y, cenZ); // div by 2.01 to prevent overlapps and z-fighting const float sx = from.getDistance(to) / 2; const float sy = thickness_m / 2; const float sz = height / 2.01f; // prevent overlaps const Point3 size(sx, sy, sz); const Point3 rot(0,0,deg); // build Cube cube(pos, size, rot, cubeParts); // done Obstacle3D res(Obstacle3D::Type::DOOR, door->material); res.triangles = cube.getTriangles(); return res; } }; } #endif // FLOORPLAN_3D_DOORS_H