62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
/*
|
||
* © 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
|