initial commit before ownership transfer
This commit is contained in:
73
code/Vis.h
Normal file
73
code/Vis.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef VIS_H
|
||||
#define VIS_H
|
||||
|
||||
#include <KLib/misc/gnuplot/Gnuplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementLines.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementPoints.h>
|
||||
|
||||
#include <Indoor/geo/Length.h>
|
||||
#include <Indoor/floorplan/Floor.h>
|
||||
|
||||
class Vis {
|
||||
|
||||
public:
|
||||
|
||||
K::Gnuplot gp;
|
||||
K::GnuplotSplot splot;
|
||||
K::GnuplotSplotElementLines floors;
|
||||
K::GnuplotSplotElementPoints gridNodes;
|
||||
K::GnuplotSplotElementLines gridEdges;
|
||||
|
||||
public:
|
||||
|
||||
Vis() {
|
||||
|
||||
gp << "set hidden3d front\n";
|
||||
gp << "set view equal xy\n";
|
||||
gp << "set ticslevel 0\n";
|
||||
|
||||
// attach all layers
|
||||
splot.add(&floors);
|
||||
splot.add(&gridNodes);
|
||||
splot.add(&gridEdges);
|
||||
|
||||
}
|
||||
|
||||
/** add all obstacles of the given floor to the provided height */
|
||||
Vis& addFloor(const Floor& f, const LengthF height) {
|
||||
|
||||
// add each wall
|
||||
for (const Line2& l : f.getObstacles()) {
|
||||
const K::GnuplotPoint3 p1(l.p1.x, l.p1.y, height.cm());
|
||||
const K::GnuplotPoint3 p2(l.p2.x, l.p2.y, height.cm());
|
||||
floors.addSegment(p1, p2);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
}
|
||||
|
||||
/** add the grid to the plot */
|
||||
template <typename T> Vis& addGrid(Grid<T>& grid) {
|
||||
for (const T& n1 : grid) {
|
||||
const K::GnuplotPoint3 p1(n1.x_cm, n1.y_cm, n1.z_cm);
|
||||
gridNodes.add(p1);
|
||||
for (const T& n2 : grid.neighbors(n1)) {
|
||||
const K::GnuplotPoint3 p2(n2.x_cm, n2.y_cm, n2.z_cm);
|
||||
gridEdges.addSegment(p1, p2);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** show (plot) the current setup */
|
||||
void show() {
|
||||
gp.draw(splot);
|
||||
gp.flush();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // VIS_H
|
||||
Reference in New Issue
Block a user