modified lib GPC for header only
worked on 3d traytracing
This commit is contained in:
@@ -12,54 +12,87 @@ TEST(RayTrace3, test) {
|
||||
//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";
|
||||
std::string file = "/apps/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");
|
||||
std::ofstream outOBJ("/tmp/vm/map.obj");
|
||||
outOBJ << fac.toOBJ();
|
||||
outOBJ.close();
|
||||
|
||||
const int gs_cm = 100;
|
||||
const int gs_cm = 50;
|
||||
|
||||
WiFiRaytrace3D rt(map, gs_cm, ap->pos);
|
||||
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
|
||||
const DataMap3Signal& dms = rt.estimate();
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> end = std::chrono::high_resolution_clock::now();
|
||||
auto result = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
|
||||
std::cout << "it took: " << result << " msec" << std::endl;
|
||||
|
||||
const char sep = ';';
|
||||
if (1 == 1) {
|
||||
|
||||
std::ofstream out("/mnt/vm/rays.xyz.txt");
|
||||
auto lambda = [&] (const float x, const float y, const float z, const DataMap3SignalEntry& e) {
|
||||
const char sep = ' ';
|
||||
int lines = 0;
|
||||
|
||||
const float min = -120;
|
||||
const float max = -40;
|
||||
float rssi = e.getMaxRSSI();
|
||||
if (rssi > max) {rssi = max;}
|
||||
std::stringstream tmp;
|
||||
|
||||
if (rssi > -100) {
|
||||
const float v = ((rssi - min) / (max-min)) * 255;
|
||||
out
|
||||
<< x << sep << y << sep << z << sep
|
||||
<< v << sep << v << sep << v
|
||||
<< "\n";
|
||||
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 (z < 1.0 || z > 1.0) {return;}
|
||||
|
||||
if (rssi > -100) {
|
||||
++lines;
|
||||
const int v = ((rssi - min) / (max-min)) * 255; // color
|
||||
tmp
|
||||
<< x << sep << y << sep << z << sep
|
||||
<< v << sep << v << sep << v
|
||||
<< "\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
dms.forEach(lambda);
|
||||
|
||||
std::ofstream out("/tmp/vm/grid.ply");
|
||||
out << "ply\n";
|
||||
out << "format ascii 1.0\n";
|
||||
out << "comment VCGLIB generated\n";
|
||||
out << "element vertex " << lines << "\n";
|
||||
out << "property float x\n";
|
||||
out << "property float y\n";
|
||||
out << "property float z\n";
|
||||
out << "property uchar red\n";
|
||||
out << "property uchar green\n";
|
||||
out << "property uchar blue\n";
|
||||
out << "element face 0\n";
|
||||
out << "property list uchar int vertex_indices\n";
|
||||
out << "end_header\n";
|
||||
out << tmp.str();
|
||||
out.close();
|
||||
|
||||
std::cout << "lines: " << lines << std::endl;
|
||||
|
||||
|
||||
std::ofstream outHits("/tmp/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();
|
||||
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user