This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/floorplan/3D/Pillars.h
frank 8dd1ba0be6 moved from ray3 to floorplan/3D
worked on new wall models
refactoring
2018-07-24 08:13:16 +02:00

52 lines
1.1 KiB
C++

#ifndef FLOORPLAN_3D_PILLARS_H
#define FLOORPLAN_3D_PILLARS_H
#include "Obstacle3.h"
#include "misc.h"
#include "primitives/Cylinder.h"
namespace Floorplan3D {
class Pillars {
public:
std::vector<Obstacle3D> getPillars(const Floorplan::Floor* f) {
std::vector<Obstacle3D> res;
for (const Floorplan::FloorObstacle* o: f->obstacles) {
const Floorplan::FloorObstacleCircle* circ = dynamic_cast<const Floorplan::FloorObstacleCircle*>(o);
if (circ) {
res.push_back(getPillar(f, circ));
}
}
return res;
}
Obstacle3D getPillar(const Floorplan::Floor* f, const Floorplan::FloorObstacleCircle* foc) {
FloorPos fpos(f);
// attributes
const float r = foc->radius;
const float h = (foc->height > 0) ? (foc->height) : (fpos.height); // use either floor's height or user height
const Point3 pos(foc->center.x, foc->center.y, fpos.z1 + h/2);
// build
Cylinder cyl;
cyl.add(r, h/2, true);
cyl.translate(pos);
// done
Obstacle3D res(getType(foc), foc->material);
res.triangles = cyl.getTriangles();
return res;
}
};
}
#endif // FLOORPLAN_3D_PILLARS_H