#ifndef OBSTACLE3_H #define OBSTACLE3_H #include #include "../../../geo/Triangle3.h" #include "../../../geo/Sphere3.h" #include "../../../floorplan/v2/Floorplan.h" namespace Ray3D { /** * 3D obstacle * based on multiple triangles * has a material and a type */ struct Obstacle3D { enum class Type { UNKNOWN, GROUND_INDOOR, GROUND_OUTDOOR, STAIR, HANDRAIL, DOOR, WALL, WINDOW, OBJECT, }; Type type; Floorplan::Material mat; std::vector triangles; /** empty ctor */ Obstacle3D() : type(Type::UNKNOWN), mat() {;} /** ctor */ Obstacle3D(Type type, Floorplan::Material mat) : type(type), mat(mat) {;} /** translated copy */ Obstacle3D translated(const Point3 pos) const { Obstacle3D copy = *this; for (Triangle3& tria : copy.triangles) { tria += pos; } return copy; } /** rotated [around (0,0,0)] copy */ Obstacle3D rotated_deg(const Point3 rot) const { Obstacle3D copy = *this; for (Triangle3& tria : copy.triangles) { tria.p1 = tria.p1.rot(rot.x/180.0f*M_PI, rot.y/180.0f*M_PI, rot.z/180.0f*M_PI); tria.p2 = tria.p2.rot(rot.x/180.0f*M_PI, rot.y/180.0f*M_PI, rot.z/180.0f*M_PI); tria.p3 = tria.p3.rot(rot.x/180.0f*M_PI, rot.y/180.0f*M_PI, rot.z/180.0f*M_PI); } return copy; } /** get all triangle-edge-points (x,y) within the obstacle */ std::vector getPoints2D() const { std::vector res; for (const Triangle3& tria : triangles) { res.push_back(tria.p1.xy()); res.push_back(tria.p2.xy()); res.push_back(tria.p3.xy()); } return res; } /** get all triangle-edge-points (x,y,z) within the obstacle */ std::vector getPoints3D() const { std::vector res; for (const Triangle3& tria : triangles) { res.push_back(tria.p1); res.push_back(tria.p2); res.push_back(tria.p3); } return res; } }; } #endif // OBSTACLE3_H