From ae3b95cb0ed9c557202492653de711abcea304e9 Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Tue, 26 Jun 2018 11:58:36 +0200 Subject: [PATCH] added sanity check to csv refactoring for wifi models adjusted obj/mtl parsing --- data/csv.h | 7 +++ .../radio/setup/WiFiOptimizerLogDistCeiling.h | 48 ++++++++++--------- sensors/radio/setup/WiFiOptimizerPerFloor.h | 1 + wifi/estimate/ray3/FloorplanMesh.h | 2 +- wifi/estimate/ray3/MTLReader.h | 3 ++ wifi/estimate/ray3/OBJReader.h | 1 + 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/data/csv.h b/data/csv.h index 2366b9a..4f65517 100644 --- a/data/csv.h +++ b/data/csv.h @@ -5,6 +5,7 @@ #include #include #include "../misc/Debug.h" +#include "../Exception.h" class CSV { @@ -54,6 +55,12 @@ public: Doc doc; std::ifstream inp(file.c_str()); + + // sanity check + if (!inp) { + throw Exception("failed to open file: " + file); + } + int rowCnt = 0; std::string line; diff --git a/sensors/radio/setup/WiFiOptimizerLogDistCeiling.h b/sensors/radio/setup/WiFiOptimizerLogDistCeiling.h index 63cdc5c..1f880b1 100644 --- a/sensors/radio/setup/WiFiOptimizerLogDistCeiling.h +++ b/sensors/radio/setup/WiFiOptimizerLogDistCeiling.h @@ -33,6 +33,7 @@ namespace WiFiOptimizer { */ struct LogDistCeiling : public Base { + public: /** @@ -63,6 +64,30 @@ namespace WiFiOptimizer { }; + using APFilter = std::function; + + static inline bool NONE(const Stats& stats, const MACAddress& mac) { + (void) stats; (void) mac; + return false; + } + + static inline bool MIN_2_FPS(const Stats& stats, const MACAddress& mac) { + (void) mac; + return stats.usedFingerprins < 2; + } + + static inline bool MIN_5_FPS(const Stats& stats, const MACAddress& mac) { + (void) mac; + return stats.usedFingerprins < 5; + } + + static inline bool MIN_10_FPS(const Stats& stats, const MACAddress& mac) { + (void) mac; + return stats.usedFingerprins < 10; + } + + + /** parameters for one AP when using the LogDistCeiling model */ struct APParams { @@ -139,29 +164,6 @@ namespace WiFiOptimizer { }; - using APFilter = std::function; - - const APFilter NONE = [] (const Stats& stats, const MACAddress& mac) { - (void) stats; (void) mac; - return false; - }; - - const APFilter MIN_2_FPS = [] (const Stats& stats, const MACAddress& mac) { - (void) mac; - return stats.usedFingerprins < 2; - }; - - const APFilter MIN_5_FPS = [] (const Stats& stats, const MACAddress& mac) { - (void) mac; - return stats.usedFingerprins < 5; - }; - - const APFilter MIN_10_FPS = [] (const Stats& stats, const MACAddress& mac) { - (void) mac; - return stats.usedFingerprins < 10; - }; - - private: Floorplan::IndoorMap* map; diff --git a/sensors/radio/setup/WiFiOptimizerPerFloor.h b/sensors/radio/setup/WiFiOptimizerPerFloor.h index bd59b6b..7d9d3c4 100644 --- a/sensors/radio/setup/WiFiOptimizerPerFloor.h +++ b/sensors/radio/setup/WiFiOptimizerPerFloor.h @@ -1,6 +1,7 @@ #ifndef WIFIOPTIMIZERPERFLOOR_H #define WIFIOPTIMIZERPERFLOOR_H +#include "WiFiOptimizer.h" #include "WiFiOptimizerLogDistCeiling.h" #include "../model/WiFiModelPerFloor.h" #include "../../../floorplan/v2/FloorplanHelper.h" diff --git a/wifi/estimate/ray3/FloorplanMesh.h b/wifi/estimate/ray3/FloorplanMesh.h index bf159e2..46ef4ba 100644 --- a/wifi/estimate/ray3/FloorplanMesh.h +++ b/wifi/estimate/ray3/FloorplanMesh.h @@ -205,7 +205,7 @@ namespace Ray3D { for (const Obstacle3D& obs : elements) { for (const Triangle3& tria : obs.triangles) { (void) tria; - res << "3 " << vidx++ << " " << vidx++ << " " << vidx++ << "\n"; + res << "3 " << (vidx++) << " " << (vidx++) << " " << (vidx++) << "\n"; } } diff --git a/wifi/estimate/ray3/MTLReader.h b/wifi/estimate/ray3/MTLReader.h index 3952d14..0007b74 100644 --- a/wifi/estimate/ray3/MTLReader.h +++ b/wifi/estimate/ray3/MTLReader.h @@ -110,6 +110,9 @@ private: } else if ("map_Ka" == token) { const std::string texFile = tokens[1]; cur->textureFile = texFile; + } else if ("map_Kd" == token) { + const std::string texFile = tokens[1]; + cur->textureFile = texFile; } else if ("Kd" == token) { cur->diffuse.x = std::stof(tokens[1]); cur->diffuse.y = std::stof(tokens[2]); diff --git a/wifi/estimate/ray3/OBJReader.h b/wifi/estimate/ray3/OBJReader.h index f4922d3..f9b6d27 100644 --- a/wifi/estimate/ray3/OBJReader.h +++ b/wifi/estimate/ray3/OBJReader.h @@ -129,6 +129,7 @@ private: if ("vn" == token) {parseNormal(tokens);} if ("f" == token) {parseFace(tokens);} if ("g" == token) {newObject(tokens[1]);} + if ("o" == token) {newObject(tokens[1]);} }