added sanity check to csv

refactoring for wifi models
adjusted obj/mtl parsing
This commit is contained in:
k-a-z-u
2018-06-26 11:58:36 +02:00
parent 657e72b4c5
commit ae3b95cb0e
6 changed files with 38 additions and 24 deletions

View File

@@ -5,6 +5,7 @@
#include <string> #include <string>
#include <fstream> #include <fstream>
#include "../misc/Debug.h" #include "../misc/Debug.h"
#include "../Exception.h"
class CSV { class CSV {
@@ -54,6 +55,12 @@ public:
Doc doc; Doc doc;
std::ifstream inp(file.c_str()); std::ifstream inp(file.c_str());
// sanity check
if (!inp) {
throw Exception("failed to open file: " + file);
}
int rowCnt = 0; int rowCnt = 0;
std::string line; std::string line;

View File

@@ -33,6 +33,7 @@ namespace WiFiOptimizer {
*/ */
struct LogDistCeiling : public Base { struct LogDistCeiling : public Base {
public: public:
/** /**
@@ -63,6 +64,30 @@ namespace WiFiOptimizer {
}; };
using APFilter = std::function<bool(const Stats& stats, const MACAddress& mac)>;
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 */ /** parameters for one AP when using the LogDistCeiling model */
struct APParams { struct APParams {
@@ -139,29 +164,6 @@ namespace WiFiOptimizer {
}; };
using APFilter = std::function<bool(const Stats& stats, const MACAddress& mac)>;
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: private:
Floorplan::IndoorMap* map; Floorplan::IndoorMap* map;

View File

@@ -1,6 +1,7 @@
#ifndef WIFIOPTIMIZERPERFLOOR_H #ifndef WIFIOPTIMIZERPERFLOOR_H
#define WIFIOPTIMIZERPERFLOOR_H #define WIFIOPTIMIZERPERFLOOR_H
#include "WiFiOptimizer.h"
#include "WiFiOptimizerLogDistCeiling.h" #include "WiFiOptimizerLogDistCeiling.h"
#include "../model/WiFiModelPerFloor.h" #include "../model/WiFiModelPerFloor.h"
#include "../../../floorplan/v2/FloorplanHelper.h" #include "../../../floorplan/v2/FloorplanHelper.h"

View File

@@ -205,7 +205,7 @@ namespace Ray3D {
for (const Obstacle3D& obs : elements) { for (const Obstacle3D& obs : elements) {
for (const Triangle3& tria : obs.triangles) { for (const Triangle3& tria : obs.triangles) {
(void) tria; (void) tria;
res << "3 " << vidx++ << " " << vidx++ << " " << vidx++ << "\n"; res << "3 " << (vidx++) << " " << (vidx++) << " " << (vidx++) << "\n";
} }
} }

View File

@@ -110,6 +110,9 @@ private:
} else if ("map_Ka" == token) { } else if ("map_Ka" == token) {
const std::string texFile = tokens[1]; const std::string texFile = tokens[1];
cur->textureFile = texFile; cur->textureFile = texFile;
} else if ("map_Kd" == token) {
const std::string texFile = tokens[1];
cur->textureFile = texFile;
} else if ("Kd" == token) { } else if ("Kd" == token) {
cur->diffuse.x = std::stof(tokens[1]); cur->diffuse.x = std::stof(tokens[1]);
cur->diffuse.y = std::stof(tokens[2]); cur->diffuse.y = std::stof(tokens[2]);

View File

@@ -129,6 +129,7 @@ private:
if ("vn" == token) {parseNormal(tokens);} if ("vn" == token) {parseNormal(tokens);}
if ("f" == token) {parseFace(tokens);} if ("f" == token) {parseFace(tokens);}
if ("g" == token) {newObject(tokens[1]);} if ("g" == token) {newObject(tokens[1]);}
if ("o" == token) {newObject(tokens[1]);}
} }