added support for pillars
some new helper methods/classes
This commit is contained in:
82
wifi/estimate/ray3/Cylinder.h
Normal file
82
wifi/estimate/ray3/Cylinder.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef CYLINDER_H
|
||||
#define CYLINDER_H
|
||||
|
||||
|
||||
#include "../../../math/Matrix4.h"
|
||||
#include "Mesh.h"
|
||||
|
||||
namespace Ray3D {
|
||||
|
||||
/** walled cylinder */
|
||||
class Cylinder : public Mesh {
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
Cylinder() {
|
||||
;
|
||||
}
|
||||
|
||||
/** get a transformed version */
|
||||
Cylinder transformed(const Matrix4& mat) const {
|
||||
Cylinder res = *this;
|
||||
res.transform(mat);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** build */
|
||||
void add(const float rOuter, const float h, bool topAndBottom) {
|
||||
|
||||
const int tiles = 8;
|
||||
const float deg_per_tile = 360.0f / tiles;
|
||||
const float rad_per_tile = deg_per_tile / 180.0f * M_PI;
|
||||
|
||||
for (int i = 0; i < tiles; ++i) {
|
||||
|
||||
const float startRad = (i+0) * rad_per_tile;
|
||||
const float endRad = (i+1) * rad_per_tile;
|
||||
|
||||
const float xo0 = std::cos(startRad) * rOuter;
|
||||
const float yo0 = std::sin(startRad) * rOuter;
|
||||
const float xo1 = std::cos(endRad) * rOuter;
|
||||
const float yo1 = std::sin(endRad) * rOuter;
|
||||
const float cx = 0;
|
||||
const float cy = 0;
|
||||
|
||||
// outer
|
||||
addQuad(
|
||||
Point3(xo0, yo0, -h),
|
||||
Point3(xo1, yo1, -h),
|
||||
Point3(xo1, yo1, +h),
|
||||
Point3(xo0, yo0, +h)
|
||||
);
|
||||
|
||||
if (topAndBottom) {
|
||||
|
||||
// top
|
||||
addTriangle(
|
||||
Point3(cx, cy, h),
|
||||
Point3(xo0, yo0, h),
|
||||
Point3(xo1, yo1, h)
|
||||
);
|
||||
|
||||
// bottom
|
||||
addTriangle(
|
||||
Point3(cx, cy, -h),
|
||||
Point3(xo1, yo1, -h),
|
||||
Point3(xo0, yo0, -h)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CYLINDER_H
|
||||
@@ -28,6 +28,11 @@ namespace Ray3D {
|
||||
transform(mat);
|
||||
}
|
||||
|
||||
void translate(const Point3 pos) {
|
||||
const Matrix4 mPos = Matrix4::getTranslation(pos.x, pos.y, pos.z);
|
||||
transform(mPos);
|
||||
}
|
||||
|
||||
void transform(const Matrix4& mat) {
|
||||
|
||||
for (Triangle3& tria : trias) {
|
||||
@@ -53,6 +58,10 @@ namespace Ray3D {
|
||||
trias.push_back( Triangle3(p1,p3,p4) );
|
||||
}
|
||||
|
||||
void addTriangle(Point3 p1, Point3 p2, Point3 p3) {
|
||||
trias.push_back( Triangle3(p1,p2,p3) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Obstacle3.h"
|
||||
#include "Cube.h"
|
||||
#include "Tube.h"
|
||||
#include "Cylinder.h"
|
||||
#include "FloorplanMesh.h"
|
||||
|
||||
#include "OBJPool.h"
|
||||
@@ -219,6 +220,14 @@ namespace Ray3D {
|
||||
}
|
||||
}
|
||||
|
||||
// handle circle obstacles
|
||||
const Floorplan::FloorObstacleCircle* foc = dynamic_cast<const Floorplan::FloorObstacleCircle*>(fo);
|
||||
if (foc) {
|
||||
if (exportObstacles) {
|
||||
res.push_back(getPillar(f, foc));
|
||||
}
|
||||
}
|
||||
|
||||
// handle object obstacles
|
||||
const Floorplan::FloorObstacleObject* foo = dynamic_cast<const Floorplan::FloorObstacleObject*>(fo);
|
||||
if (foo) {
|
||||
@@ -267,6 +276,27 @@ namespace Ray3D {
|
||||
return getWall(f, fol, aboveDoor);
|
||||
}
|
||||
|
||||
Obstacle3D getPillar(const Floorplan::Floor* f, const Floorplan::FloorObstacleCircle* foc) const {
|
||||
|
||||
FloorPos fpos(f);
|
||||
|
||||
// attributes
|
||||
const float r = foc->radius;
|
||||
const float h = (foc->height > 0) ? (foc->height) : (fpos.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;
|
||||
|
||||
}
|
||||
|
||||
Obstacle3D getWall(const Floorplan::Floor* f, const Floorplan::FloorObstacleLine* fol, const Floorplan::FloorObstacleDoor* aboveDoor) const {
|
||||
|
||||
FloorPos fpos(f);
|
||||
@@ -310,6 +340,7 @@ namespace Ray3D {
|
||||
Obstacle3D obs = OBJPool::get().getObject(name);
|
||||
obs = obs.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) );
|
||||
obs = obs.translated(foo->pos + Point3(0,0,fpos.z1));
|
||||
obs.type = Obstacle3D::Type::OBJECT;
|
||||
|
||||
// std::vector<Triangle3> trias;
|
||||
// for (const OBJReader::Face& face : reader.getData().faces) {
|
||||
@@ -642,6 +673,11 @@ namespace Ray3D {
|
||||
}
|
||||
}
|
||||
|
||||
static Obstacle3D::Type getType(const Floorplan::FloorObstacleCircle* c) {
|
||||
(void) c;
|
||||
return Obstacle3D::Type::WALL;
|
||||
}
|
||||
|
||||
/** used to model ceiling thickness */
|
||||
struct FloorPos {
|
||||
float fh;
|
||||
|
||||
Reference in New Issue
Block a user