current state
This commit is contained in:
104
plots/Plotty.h
104
plots/Plotty.h
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
#include <Indoor/floorplan/v2/FloorplanHelper.h>
|
||||
#include <Indoor/geo/BBoxes3.h>
|
||||
|
||||
#include <KLib/misc/gnuplot/Gnuplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplot.h>
|
||||
@@ -11,6 +12,7 @@
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementLines.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotPlot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotPlotElementHistogram.h>
|
||||
#include <KLib/misc/gnuplot/objects/GnuplotObjects.h>
|
||||
|
||||
struct Color {
|
||||
|
||||
@@ -99,6 +101,7 @@ public:
|
||||
K::GnuplotSplotElementLines mapOutlineGlass;
|
||||
K::GnuplotSplotElementLines mapOutlineDrywall;
|
||||
K::GnuplotSplotElementLines mapOutlineConcrete;
|
||||
K::GnuplotSplotElementLines mapBBoxes;
|
||||
|
||||
std::string codeFile;
|
||||
|
||||
@@ -130,9 +133,11 @@ public:
|
||||
mapOutlineConcrete.getStroke().getColor().setHexStr("#888888"); mapOutlineConcrete.getStroke().setWidth(2);
|
||||
mapOutlineDrywall.getStroke().getColor().setHexStr("#888888");
|
||||
mapOutlineGlass.getStroke().getColor().setHexStr("#888888"); mapOutlineGlass.getStroke().setType(K::GnuplotDashtype::DASHED);
|
||||
mapBBoxes.getStroke().setWidth(2);
|
||||
splot.add(&mapOutlineConcrete);
|
||||
splot.add(&mapOutlineDrywall);
|
||||
splot.add(&mapOutlineGlass);
|
||||
splot.add(&mapBBoxes);
|
||||
|
||||
splot.add(&particles); particles.setPointSize(0.20); //particles.setColorHex("#777777");
|
||||
|
||||
@@ -149,6 +154,52 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void addBBoxes(const BBoxes3& boxes, const K::GnuplotColor& c) {
|
||||
for (const BBox3& bb : boxes.get()) {
|
||||
addBBoxPoly(bb, c);
|
||||
}
|
||||
}
|
||||
|
||||
void addBBox(const BBox3& bb) {
|
||||
|
||||
// floor
|
||||
mapBBoxes.add({bb.getMin().x, bb.getMin().y, bb.getMin().z});
|
||||
mapBBoxes.add({bb.getMax().x, bb.getMin().y, bb.getMin().z});
|
||||
mapBBoxes.add({bb.getMax().x, bb.getMax().y, bb.getMin().z});
|
||||
mapBBoxes.add({bb.getMin().x, bb.getMax().y, bb.getMin().z});
|
||||
mapBBoxes.add({bb.getMin().x, bb.getMin().y, bb.getMin().z});
|
||||
mapBBoxes.splitFace(); mapBBoxes.splitFace();
|
||||
|
||||
// ceil
|
||||
mapBBoxes.add({bb.getMin().x, bb.getMin().y, bb.getMax().z});
|
||||
mapBBoxes.add({bb.getMax().x, bb.getMin().y, bb.getMax().z});
|
||||
mapBBoxes.add({bb.getMax().x, bb.getMax().y, bb.getMax().z});
|
||||
mapBBoxes.add({bb.getMin().x, bb.getMax().y, bb.getMax().z});
|
||||
mapBBoxes.add({bb.getMin().x, bb.getMin().y, bb.getMax().z});
|
||||
mapBBoxes.splitFace(); mapBBoxes.splitFace();
|
||||
|
||||
// up
|
||||
mapBBoxes.addSegment({bb.getMin().x, bb.getMin().y, bb.getMin().z}, {bb.getMin().x, bb.getMin().y, bb.getMax().z});
|
||||
mapBBoxes.addSegment({bb.getMax().x, bb.getMin().y, bb.getMin().z}, {bb.getMax().x, bb.getMin().y, bb.getMax().z});
|
||||
mapBBoxes.addSegment({bb.getMin().x, bb.getMax().y, bb.getMin().z}, {bb.getMin().x, bb.getMax().y, bb.getMax().z});
|
||||
mapBBoxes.addSegment({bb.getMax().x, bb.getMax().y, bb.getMin().z}, {bb.getMax().x, bb.getMax().y, bb.getMax().z});
|
||||
|
||||
}
|
||||
|
||||
void addBBoxPoly(const BBox3& bb, K::GnuplotColor c) {
|
||||
|
||||
K::GnuplotObjectPolygon* poly = new K::GnuplotObjectPolygon();
|
||||
poly->add(K::GnuplotCoordinate3(bb.getMin().x, bb.getMin().y, bb.getMin().z, K::GnuplotCoordinateSystem::FIRST));
|
||||
poly->add(K::GnuplotCoordinate3(bb.getMax().x, bb.getMin().y, bb.getMin().z, K::GnuplotCoordinateSystem::FIRST));
|
||||
poly->add(K::GnuplotCoordinate3(bb.getMax().x, bb.getMax().y, bb.getMin().z, K::GnuplotCoordinateSystem::FIRST));
|
||||
poly->add(K::GnuplotCoordinate3(bb.getMin().x, bb.getMax().y, bb.getMin().z, K::GnuplotCoordinateSystem::FIRST));
|
||||
poly->close();
|
||||
poly->setStroke(K::GnuplotStroke::NONE());
|
||||
poly->setFill(K::GnuplotFill(K::GnuplotFillStyle::SOLID, c));
|
||||
splot.getObjects().add(poly);
|
||||
|
||||
}
|
||||
|
||||
void setGroundTruth(const Point3 pos_m) {
|
||||
gp << "set arrow 998 from " << pos_m.x << "," << pos_m.y << "," << pos_m.z << " to " << pos_m.x << "," << pos_m.y << "," << pos_m.z+1 << " front \n";
|
||||
}
|
||||
@@ -202,7 +253,25 @@ public:
|
||||
addPolygon(points, c.toHEX(), front, fill);
|
||||
}
|
||||
|
||||
void addPolygon(const std::vector<Point3>& points, const std::string& color, bool front = false, bool fill = true) {
|
||||
void addRectangleW(const Point3 p1, const Point3 p2, const K::GnuplotColor c, const float w, bool front = false) {
|
||||
std::vector<Point3> points = {
|
||||
Point3(p1.x, p1.y, p1.z),
|
||||
Point3(p2.x, p1.y, p1.z),
|
||||
Point3(p2.x, p2.y, p1.z),
|
||||
Point3(p1.x, p2.y, p1.z),
|
||||
Point3(p1.x, p1.y, p1.z),
|
||||
};
|
||||
K::GnuplotObjectPolygon* poly = new K::GnuplotObjectPolygon();
|
||||
poly->getStroke().setWidth(w);
|
||||
poly->getStroke().setColor(c);
|
||||
poly->setFront(front);
|
||||
for (const Point3 p : points) {
|
||||
poly->add(K::GnuplotCoordinate3(p.x, p.y, p.z, K::GnuplotCoordinateSystem::FIRST));
|
||||
}
|
||||
splot.getObjects().add(poly);
|
||||
}
|
||||
|
||||
void addPolygon(const std::vector<Point3>& points, const std::string& color, bool front = false, bool fill = true, const float alpha = 1) {
|
||||
|
||||
for (const Point3 p : points) {
|
||||
if (p.z < settings.minZ) {return;}
|
||||
@@ -216,6 +285,7 @@ public:
|
||||
for (const Point3 p : points) {
|
||||
poly->add(K::GnuplotCoordinate3(p.x, p.y, p.z, K::GnuplotCoordinateSystem::FIRST));
|
||||
poly->setZIndex(p.z); // manual depth ordering
|
||||
poly->getFill().setAlpha(alpha);
|
||||
}
|
||||
poly->setFront(front);
|
||||
|
||||
@@ -240,16 +310,16 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void addFloorRect(const Point3 pos_m, const float size, Color c) {
|
||||
void addFloorRect(const Point3 pos_m, const float size, Color c, float ratio = 1.0) {
|
||||
|
||||
const Point3 p1 = pos_m + Point3(-size, -size, 0);
|
||||
const Point3 p2 = pos_m + Point3(+size, -size, 0);
|
||||
const Point3 p3 = pos_m + Point3(+size, +size, 0);
|
||||
const Point3 p4 = pos_m + Point3(-size, +size, 0);
|
||||
const Point3 p1 = pos_m + Point3(-size, -size/ratio, 0);
|
||||
const Point3 p2 = pos_m + Point3(+size, -size/ratio, 0);
|
||||
const Point3 p3 = pos_m + Point3(+size, +size/ratio, 0);
|
||||
const Point3 p4 = pos_m + Point3(-size, +size/ratio, 0);
|
||||
|
||||
std::vector<Point3> points = {p1,p2,p3,p4,p1};
|
||||
|
||||
addPolygon(points, c.toHEX());
|
||||
addPolygon(points, c.toHEX(), false, true);
|
||||
|
||||
// gp << "set object polygon from ";
|
||||
// for (size_t i = 0; i < points.size(); ++i) {
|
||||
@@ -279,11 +349,12 @@ public:
|
||||
}
|
||||
|
||||
void setView(const float degX, const float degY) {
|
||||
gp << "set view " << degX << "," << degY << "\n";
|
||||
//gp << "set view " << degX << "," << degY << "\n";
|
||||
splot.getView().setCamera(degX, degY);
|
||||
}
|
||||
|
||||
void setScale(const float x, const float y) {
|
||||
gp << "set multiplot layout 1,1 scale " << x << "," << y << "\n";
|
||||
void setScale(const float x, const float y, const float ox = 0, const float oy = 0) {
|
||||
gp << "set multiplot layout 1,1 scale " << x << "," << y << " offset " << ox << "," << oy << "\n";
|
||||
}
|
||||
|
||||
void writeCodeTo(const std::string& file) {
|
||||
@@ -292,9 +363,12 @@ public:
|
||||
|
||||
void noFrame() {
|
||||
gp << "unset border\n";
|
||||
gp << "unset xtics\n";
|
||||
gp << "unset ytics\n";
|
||||
gp << "unset ztics\n";
|
||||
// gp << "unset xtics\n";
|
||||
// gp << "unset ytics\n";
|
||||
// gp << "unset ztics\n";
|
||||
splot.getAxisX().setTicsVisible(false);
|
||||
splot.getAxisY().setTicsVisible(false);
|
||||
splot.getAxisZ().setTicsVisible(false);
|
||||
}
|
||||
|
||||
void writeEpsTex(const std::string file, K::GnuplotSize size = K::GnuplotSize(8.5, 5.1)) {
|
||||
@@ -357,7 +431,9 @@ public:
|
||||
// plot the floor's outline
|
||||
if (settings.outline) {
|
||||
for (Floorplan::FloorOutlinePolygon* poly : floor->outline) {
|
||||
K::GnuplotColor color = (poly->outdoor) ? (K::GnuplotColor::fromRGB(200, 240, 200)) : (K::GnuplotColor::fromRGB(210,210,210));
|
||||
K::GnuplotColor color = K::GnuplotColor::fromRGB(210,210,210);
|
||||
if (poly->outdoor) {color = K::GnuplotColor::fromRGB(200, 240, 200);}
|
||||
//if (poly->method == Floorplan::OutlineMethod::REMOVE) {color = K::GnuplotColor::fromRGB(245,245,245);}
|
||||
K::GnuplotFill filler(K::GnuplotFillStyle::SOLID, color);
|
||||
K::GnuplotObjectPolygon* gpol = new K::GnuplotObjectPolygon(filler, K::GnuplotStroke::NONE());
|
||||
for (Point2 pt : poly->poly.points) {
|
||||
|
||||
Reference in New Issue
Block a user