moved from ray3 to floorplan/3D
worked on new wall models refactoring
This commit is contained in:
156
floorplan/3D/Builder.h
Normal file
156
floorplan/3D/Builder.h
Normal file
@@ -0,0 +1,156 @@
|
||||
#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 "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 = true;
|
||||
|
||||
//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<Obstacle3D> triangulize() {
|
||||
|
||||
// TODO: filtering??
|
||||
std::vector<Floorplan::Floor*> floors = map->floors;
|
||||
|
||||
std::vector<Obstacle3D> res;
|
||||
|
||||
// get the to-be-exported floors (either "all" or "user defined")
|
||||
//const std::vector<Floorplan::Floor*>& 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<Obstacle3D> 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<Obstacle3D> tmp = getWalls(f);
|
||||
res.insert(res.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
if (exportHandrails) {
|
||||
Handrails rails;
|
||||
const std::vector<Obstacle3D> tmp = rails.getHandrails(f);
|
||||
res.insert(res.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
if (exportObjects) {
|
||||
Objects objs;
|
||||
const std::vector<Obstacle3D> tmp = objs.getObjects(f);
|
||||
res.insert(res.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
if (exportPillars) {
|
||||
Pillars pillars;
|
||||
const std::vector<Obstacle3D> tmp = pillars.getPillars(f);
|
||||
res.insert(res.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
// for (const Floorplan::FloorObstacle* fo : f->obstacles) {
|
||||
// std::vector<Obstacle3D> tmp = getWalls(f);
|
||||
// res.insert(res.end(), tmp.begin(), tmp.end());
|
||||
// }
|
||||
}
|
||||
|
||||
// // stairs
|
||||
if (f->stairs.enabled && exportStairs) {
|
||||
Stairs stairs;
|
||||
const std::vector<Obstacle3D> tmp = stairs.getStairs(f);
|
||||
res.insert(res.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** just get all walls */
|
||||
std::vector<Obstacle3D> getWalls(const Floorplan::Floor* f) {
|
||||
|
||||
WallsViaCuttedQuads walls;
|
||||
|
||||
for (const Floorplan::FloorObstacle* obs : f->obstacles) {
|
||||
const Floorplan::FloorObstacleLine* line = dynamic_cast<const Floorplan::FloorObstacleLine*>(obs);
|
||||
if (line) {walls.add(f, line, nullptr);}
|
||||
}
|
||||
|
||||
return walls.get();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FLOORPLAN_3D_BUILDER_H
|
||||
Reference in New Issue
Block a user