started with eval
This commit is contained in:
46
Plotty.h
46
Plotty.h
@@ -1,19 +1,33 @@
|
||||
#ifndef PLOTTY_H
|
||||
#define PLOTTY_H
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
#include <Indoor/floorplan/v2/FloorplanHelper.h>
|
||||
|
||||
#include <KLib/misc/gnuplot/Gnuplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementPoints.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementColorPoints.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementLines.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotPlot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotPlotElementHistogram.h>
|
||||
|
||||
class Plotty {
|
||||
|
||||
public:
|
||||
|
||||
Floorplan::IndoorMap* map;
|
||||
K::Gnuplot gp;
|
||||
K::GnuplotSplot splot;
|
||||
K::GnuplotSplotElementPoints points;
|
||||
K::GnuplotSplotElementColorPoints cpoints;
|
||||
K::GnuplotSplotElementLines lines;
|
||||
K::GnuplotSplotElementLines pathReal;
|
||||
K::GnuplotSplotElementLines pathEst;
|
||||
K::GnuplotSplotElementLines mapOutline;
|
||||
|
||||
public:
|
||||
|
||||
Plotty(Floorplan::IndoorMap* map) {
|
||||
Plotty(Floorplan::IndoorMap* map) : map(map) {
|
||||
|
||||
//gp << "set view equal xy\n";
|
||||
|
||||
@@ -25,25 +39,39 @@ public:
|
||||
gp << "set palette model RGB functions r(gray),g(gray),b(gray)\n";
|
||||
|
||||
// draw floorplan
|
||||
splot.add(&lines);
|
||||
mapOutline.setColorHex("#888888");
|
||||
splot.add(&mapOutline);
|
||||
for (Floorplan::Floor* floor : map->floors) {
|
||||
for (Floorplan::FloorObstacle* obs : floor->obstacles) {
|
||||
Floorplan::FloorObstacleLine* line = dynamic_cast<Floorplan::FloorObstacleLine*>(obs);
|
||||
if (line) {
|
||||
const K::GnuplotPoint3 p1(line->from.x, line->from.y, floor->atHeight);
|
||||
const K::GnuplotPoint3 p2(line->to.x, line->to.y, floor->atHeight);
|
||||
lines.addSegment(p1, p2);
|
||||
mapOutline.addSegment(p1, p2);
|
||||
}
|
||||
}
|
||||
for (Floorplan::Stair* s : floor->stairs) {
|
||||
for (const Floorplan::StairPart& sp : s->getParts()) {
|
||||
const K::GnuplotPoint3 p1(sp.start.x, sp.start.y, sp.start.z + floor->atHeight);
|
||||
const K::GnuplotPoint3 p2(sp.end.x, sp.end.y, sp.end.z + floor->atHeight);
|
||||
lines.addSegment(p1, p2);
|
||||
mapOutline.addSegment(p1, p2);
|
||||
}
|
||||
}
|
||||
for (Floorplan::FloorOutlinePolygon* poly : floor->outline) {
|
||||
gp << "set object polygon from ";
|
||||
for (size_t i = 0; i < poly->poly.points.size(); ++i) {
|
||||
if (i > 0) {gp << " to ";}
|
||||
const Point2 pt = poly->poly.points[i];
|
||||
gp << pt.x << "," << pt.y << "," << floor->atHeight << " ";
|
||||
}
|
||||
gp << " fs solid fc rgb " << ( poly->outdoor ? "'#ddffdd'" : "'#dddddd'");
|
||||
gp << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
splot.add(&pathReal); pathReal.setLineWidth(2); pathReal.setColorHex("#0000ff");
|
||||
splot.add(&pathEst);
|
||||
|
||||
splot.add(&points);
|
||||
points.setPointType(7);
|
||||
points.setPointSize(0.5);
|
||||
@@ -93,6 +121,14 @@ public:
|
||||
gp << "set title '" << title << "'\n";
|
||||
}
|
||||
|
||||
void setGroundTruth(const std::vector<int> indices) {
|
||||
const std::vector<Point3> path = FloorplanHelper::getGroundTruth(map, indices);
|
||||
pathReal.clear();
|
||||
for (const Point3& p : path) {
|
||||
pathReal.add(K::GnuplotPoint3(p.x, p.y, p.z));
|
||||
}
|
||||
}
|
||||
|
||||
void plot() {
|
||||
gp.draw(splot);
|
||||
gp.flush();
|
||||
|
||||
Reference in New Issue
Block a user