diff --git a/geo/Triangle3.h b/geo/Triangle3.h index f86c4b4..ca09888 100644 --- a/geo/Triangle3.h +++ b/geo/Triangle3.h @@ -136,6 +136,14 @@ public: } + /** perform some sanity checks */ + bool isValid() const { + if (p1 == p2) {return false;} + if (p1 == p3) {return false;} + if (p2 == p3) {return false;} + return true; + } + /* int rayIntersectsTriangle(float *p, float *d, float *v0, float *v1, float *v2) { diff --git a/wifi/estimate/ray3/ModelFactory.h b/wifi/estimate/ray3/ModelFactory.h index 234c433..adbe864 100644 --- a/wifi/estimate/ray3/ModelFactory.h +++ b/wifi/estimate/ray3/ModelFactory.h @@ -339,6 +339,13 @@ namespace Ray3D { const std::string& name = foo->file; Obstacle3D obs = OBJPool::get().getObject(name); + + // perform sanity checks + if (!obs.isValid()) { + throw std::runtime_error("invalid obstacle-data detected"); + } + + // apply scaling/rotation/translation obs = obs.scaled(foo->scale); obs = obs.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) ); obs = obs.translated(foo->pos + Point3(0,0,fpos.z1)); diff --git a/wifi/estimate/ray3/Obstacle3.h b/wifi/estimate/ray3/Obstacle3.h index ff84594..cfbfc71 100644 --- a/wifi/estimate/ray3/Obstacle3.h +++ b/wifi/estimate/ray3/Obstacle3.h @@ -89,6 +89,14 @@ namespace Ray3D { return res; } + /** perform sanity checks */ + bool isValid() const { + for (const Triangle3& t : triangles) { + if (!t.isValid()) {return false;} + } + return true; + } + }; }