Polygon2D.h 1.33 KB
Newer Older
1 2 3 4 5
#pragma once

#include <QPolygonF>
#include <QPointF>

6 7
#include "ros_bridge/include/MessageGroups.h"
#include "ros_bridge/include/MessageBaseClass.h"
8 9 10 11
#include "ros_bridge/include/JsonMethodes.h"

namespace MsgGroupsNS = ROSBridge::MessageGroups;
namespace PolyStampedNS = ROSBridge::JsonMethodes::PolygonStamped;
12

13
typedef ROSBridge::MessageBaseClass<QString> ROSMsg;
14

15 16 17
template <class PointType = QPointF, template <class, class...> class ContainerType = QVector>
class Polygon2DTemplate : public ROSMsg{ //
    typedef ROSBridge::JsonMethodes::Polygon::Polygon<PointType, ContainerType> Poly;
18
public:
19
    typedef MsgGroupsNS::PolygonStampedGroup Group; // has no header
20

21 22
    Polygon2DTemplate(){}
    Polygon2DTemplate(const Polygon2DTemplate &other) : ROSMsg(), _polygon(other._polygon){}
23

24 25
    Polygon2DTemplate& operator=(const Polygon2DTemplate& other) {
        this->_polygon = other._polygon;
26 27 28
        return *this;
    }

29 30
    const Poly &polygon() const {return _polygon;}
          Poly &polygon()       {return _polygon;}
31

32 33 34 35 36 37 38 39
  const ContainerType<PointType> &path() const {return _polygon.points();}
        ContainerType<PointType> &path()       {return _polygon.points();}

    virtual Polygon2DTemplate*Clone() const { // ROSMsg
        return new Polygon2DTemplate(*this);
    }
private:
    Poly _polygon;
40 41

};
42 43

typedef Polygon2DTemplate<> Polygon2D;