/* * © 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_BUILDER_H #define FLOORPLAN_3D_BUILDER_H #include "../v2/Floorplan.h" #include "FloorplanMesh.h" #include "Obstacle3.h" #include "Outline.h" #include "Stairs.h" #include "Handrails.h" #include "Objects.h" #include "Pillars.h" #include "Doors.h" #include "Walls.h" #include "WallsViaCubes.h" #include "WallsViaCuttedQuads.h" namespace Floorplan3D { class Builder { /** the to-be-exported map */ const Floorplan::IndoorMap* map; public: bool exportCeilings = true; bool exportObstacles = true; bool exportStairs = true; bool fancyStairs = true; bool exportHandrails = true; bool exportDoors = true; // bool exportAboveDoors = true; bool doorsOpen = false; bool exportObjects = true; bool exportPillars = true; bool exportWallTops = false; bool center = false; //Walls* walls = new WallsViaCubes(); //Walls* walls = new WallsViaCuttedQuads(); public: /** ctor */ Builder(const Floorplan::IndoorMap* map) : map(map) { } /** get the created mesh */ FloorplanMesh getMesh() { FloorplanMesh mesh; mesh.elements = triangulize(); if (center) { BBox3 bb = mesh.getBBox(); mesh -= Point3(bb.getCenter().x, bb.getCenter().y, 0); } return mesh; } private: /** get all triangles grouped by obstacle */ std::vector triangulize() { // TODO: filtering?? std::vector floors = map->floors; std::vector res; // get the to-be-exported floors (either "all" or "user defined") //const std::vector& floors = (exportFloors.empty()) ? (map->floors) : (exportFloors); // process each floor for (const Floorplan::Floor* f : floors) { if (!f->enabled) {continue;} // triangulize the floor itself (floor/ceiling) if (exportCeilings) { Outline out; const std::vector tmp = out.get(f); res.insert(res.end(), tmp.begin(), tmp.end()); } // process each obstacle within the floor if (f->obstacles.enabled) { if (1 == 1) { const std::vector tmp = getLines(f); res.insert(res.end(), tmp.begin(), tmp.end()); } if (1 == 1) { const std::vector tmp = getWalls(f); res.insert(res.end(), tmp.begin(), tmp.end()); } if (exportHandrails) { Handrails rails; const std::vector tmp = rails.getHandrails(f); res.insert(res.end(), tmp.begin(), tmp.end()); } if (exportObjects) { Objects objs; const std::vector tmp = objs.getObjects(f); res.insert(res.end(), tmp.begin(), tmp.end()); } if (exportPillars) { Pillars pillars; const std::vector tmp = pillars.getPillars(f); res.insert(res.end(), tmp.begin(), tmp.end()); } if (exportDoors) { Doors doors; const std::vector tmp = doors.getDoors(f); res.insert(res.end(), tmp.begin(), tmp.end()); } // for (const Floorplan::FloorObstacle* fo : f->obstacles) { // std::vector tmp = getWalls(f); // res.insert(res.end(), tmp.begin(), tmp.end()); // } } // // stairs if (f->stairs.enabled && exportStairs) { Stairs stairs; const std::vector tmp = stairs.getStairs(f); res.insert(res.end(), tmp.begin(), tmp.end()); } } return res; } /** just get all walls */ std::vector getWalls(const Floorplan::Floor* f) { WallsViaCuttedQuads walls; for (const Floorplan::FloorObstacle* obs : f->obstacles) { const Floorplan::FloorObstacleWall* wall = dynamic_cast(obs); if (wall) {walls.add(f, wall);} } return walls.get(); } /** get all old walls (lines) */ std::vector getLines(const Floorplan::Floor* f) { WallsViaCubes walls; for (const Floorplan::FloorObstacle* obs : f->obstacles) { const Floorplan::FloorObstacleLine* line = dynamic_cast(obs); if (line) { if (line->type == Floorplan::ObstacleType::WALL) { walls.add(f, line, nullptr); } } } return walls.get(); } }; } #endif // FLOORPLAN_3D_BUILDER_H