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
2018-10-25 11:50:12 +02:00

62 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* © 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_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