]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Extend gen plot for parking slot
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 19 Jan 2022 21:55:42 +0000 (22:55 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 19 Jan 2022 21:56:37 +0000 (22:56 +0100)
incl/bcar.hh
incl/pslot.hh
src/bcar.cc
src/gen_for_gnuplot.cc
src/pslot.cc

index f5ca9286c41e8092fc7bb2ba5a7228f5ae2d7265..c2265a59c566c9ac56332b70bae0dc167e1eace7 100644 (file)
@@ -144,6 +144,9 @@ public:
 
        double h() const;
 
+       /*! Generate output for plotting with gnuplot. */
+       void gen_gnuplot_to(std::ostream& out);
+
        friend std::ostream& operator<<(std::ostream& out, Line const& li);
 };
 
index 843d9f920cb47a5b2d701da78d3bfae03a216629..fbadd41495cffa3d8ae023c799817a915a1168f3 100644 (file)
@@ -161,6 +161,9 @@ public:
         */
        PoseRange recompute_entry(PoseRange p);
 
+       /*! Generate output for plotting with gnuplot. */
+       void gen_gnuplot_to(std::ostream& out);
+
        friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
 };
 
index 6f6f77e2a0261bb1c7ca3f9cfca4e370f654905d..4c8307c42f5a442702ff3fcb24706d7723b9ab4a 100644 (file)
@@ -270,6 +270,14 @@ Line::h() const
        return atan2(this->_e.y() - this->_b.y(), this->_e.x() - this->_b.x());
 }
 
+void
+Line::gen_gnuplot_to(std::ostream& out)
+{
+       this->b().gen_gnuplot_to(out);
+       this->e().gen_gnuplot_to(out);
+       out << std::endl;
+}
+
 std::ostream&
 operator<<(std::ostream& out, Line const& li)
 {
index d719e064ed9d10279882a68631d7bb3ee149c30f..a2b02e41f05333afde98471f5168a19d726983fc 100644 (file)
@@ -67,7 +67,20 @@ public:
 };
 
 void
-gen_pl_script(std::vector<M>& ms)
+gpl_slot(bcar::ParkingSlot& s, std::string fn)
+{
+       if (fn.compare("") == 0) {
+               return;
+       }
+       using namespace std;
+       ofstream f;
+       f.open(fn);
+       s.gen_gnuplot_to(f);
+       f.close();
+}
+
+void
+gen_pl_script(std::vector<M>& ms, std::string with_slot)
 {
        using namespace std;
        ofstream f;
@@ -78,6 +91,9 @@ gen_pl_script(std::vector<M>& ms)
        for (auto& m: ms) {
                f << " '" << m.fn << "'" << " w l,";
        }
+       if (with_slot.compare("") != 0) {
+               f << " '" << with_slot << "' w l";
+       }
        f << endl;
        f << "pause -1" << endl;
        f.close();
@@ -90,6 +106,10 @@ main()
        cout << fixed;
        cerr << fixed;
 
+       bcar::ParkingSlot s(bcar::Point(0, 0), 0, 2.5, 6);
+       string sn("slot");
+       gpl_slot(s, sn);
+
        INIT_V
        P(LF_POINT)
        P(LFM_POINT)
@@ -102,6 +122,6 @@ main()
                        m.gpl();
                }
        }
-       gen_pl_script(V);
+       gen_pl_script(V, sn);
        return 0;
 }
index 1d84e28ab1593aa5f5a84e21b91d3e97784dbd07..6a9a9bb25c573e5881d09c3b3986ac4a8f5728b5 100644 (file)
@@ -411,6 +411,14 @@ ParkingSlot::recompute_entry(PoseRange p)
        return p;
 }
 
+void
+ParkingSlot::gen_gnuplot_to(std::ostream& out)
+{
+       this->rear().gen_gnuplot_to(out);
+       this->curb().gen_gnuplot_to(out);
+       this->front().gen_gnuplot_to(out);
+}
+
 std::ostream&
 operator<<(std::ostream& o, ParkingSlot const& s)
 {