work on raytracing
This commit is contained in:
66
tests/ray/TestRayTrace3.cpp
Normal file
66
tests/ray/TestRayTrace3.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "../Tests.h"
|
||||
#include "../../wifi/estimate/ray3/WifiRayTrace3D.h"
|
||||
#include "../../floorplan/v2/FloorplanReader.h"
|
||||
#include <fstream>
|
||||
|
||||
TEST(RayTrace3, test) {
|
||||
|
||||
|
||||
//std::string file = "/mnt/data/workspaces/raytest2.xml";
|
||||
//Floorplan::IndoorMap* map = Floorplan::Reader::readFromFile(file);
|
||||
//Floorplan::AccessPoint* ap = map->floors[0]->accesspoints[0];
|
||||
|
||||
std::string file = "/mnt/data/workspaces/IndoorMap/maps/SHL39.xml";
|
||||
Floorplan::IndoorMap* map = Floorplan::Reader::readFromFile(file);
|
||||
Floorplan::AccessPoint* ap = map->floors[0]->accesspoints[4];
|
||||
|
||||
ModelFactory fac(map);
|
||||
std::ofstream outOBJ("/mnt/vm/map.obj");
|
||||
outOBJ << fac.toOBJ();
|
||||
outOBJ.close();
|
||||
|
||||
const int gs_cm = 100;
|
||||
|
||||
WiFiRaytrace3D rt(map, gs_cm, ap->pos);
|
||||
const DataMap3Signal& dms = rt.estimate();
|
||||
|
||||
const char sep = ';';
|
||||
|
||||
std::ofstream out("/mnt/vm/rays.xyz.txt");
|
||||
auto lambda = [&] (const float x, const float y, const float z, const DataMap3SignalEntry& e) {
|
||||
|
||||
const float min = -120;
|
||||
const float max = -40;
|
||||
float rssi = e.getMaxRSSI();
|
||||
if (rssi > max) {rssi = max;}
|
||||
|
||||
if (rssi > -100) {
|
||||
const float v = ((rssi - min) / (max-min)) * 255;
|
||||
out
|
||||
<< x << sep << y << sep << z << sep
|
||||
<< v << sep << v << sep << v
|
||||
<< "\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
dms.forEach(lambda);
|
||||
out.close();
|
||||
|
||||
std::ofstream outHits("/mnt/vm/hits.xyz.txt");
|
||||
for (const Point3 hit : rt.getHitEnter()) {
|
||||
outHits << hit.x << sep << hit.y << sep << hit.z << sep << 0 << sep << 255 << sep << 0 << "\n";
|
||||
}
|
||||
for (const Point3 hit : rt.getHitLeave()) {
|
||||
outHits << hit.x << sep << hit.y << sep << hit.z << sep << 0 << sep << 0 << sep << 255 << "\n";
|
||||
}
|
||||
for (const Point3 hit : rt.getHitStop()) {
|
||||
outHits << hit.x << sep << hit.y << sep << hit.z << sep << 0 << sep << 0 << sep << 0 << "\n";
|
||||
}
|
||||
outHits.close();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user