many changes :P
This commit is contained in:
66
tests/grid/Plot.h
Normal file
66
tests/grid/Plot.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef PLOT_H
|
||||
#define PLOT_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>
|
||||
|
||||
|
||||
class GP : public GridNode, public GridPoint {
|
||||
public:
|
||||
float imp = 1.0f;
|
||||
public:
|
||||
GP() : GridNode(), GridPoint() {;}
|
||||
GP(int x, int y, int z) : GridNode(), GridPoint(x,y,z) {;}
|
||||
|
||||
};
|
||||
|
||||
template <int gridSize_cm, typename T> void plot(Grid<gridSize_cm, T>& g) {
|
||||
|
||||
K::Gnuplot gp;
|
||||
K::GnuplotSplot splot;
|
||||
K::GnuplotSplotElementColorPoints points;
|
||||
K::GnuplotSplotElementLines lines;
|
||||
|
||||
gp << "set ticslevel 0\n";
|
||||
gp << "set view equal xyz\n";
|
||||
gp << "set cbrange[0.5:1.0]\n";
|
||||
gp << "set palette gray negative\n";
|
||||
|
||||
std::set<uint64_t> done;
|
||||
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < g.getNumNodes(); ++i) {
|
||||
const GP& n1 = g[i];
|
||||
points.add(K::GnuplotPoint3(n1.x_cm, n1.y_cm, n1.z_cm), n1.imp);
|
||||
|
||||
for (int n = 0; n < n1.getNumNeighbors(); ++n) {
|
||||
const GP& n2 = n1.getNeighbor(n, g);
|
||||
if (done.find(g.getUID(n2)) == done.end()) {
|
||||
K::GnuplotPoint3 p1(n1.x_cm, n1.y_cm, n1.z_cm);
|
||||
K::GnuplotPoint3 p2(n2.x_cm, n2.y_cm, n2.z_cm);
|
||||
lines.addSegment(p1, p2);
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
done.insert(g.getUID(n1));
|
||||
|
||||
}
|
||||
|
||||
points.setPointSize(1);
|
||||
//splot.add(&lines);
|
||||
splot.add(&points);
|
||||
|
||||
gp.draw(splot);
|
||||
gp.flush();
|
||||
|
||||
sleep(100);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // PLOT_H
|
||||
Reference in New Issue
Block a user