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

#include <QPolygonF>
#include <QPointF>

6
#include "ros_bridge/include/MessageGroups.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
7
#include "ros_bridge/include/GenericMessages.h"
8
#include "ros_bridge/include/MessageBaseClass.h"
9 10 11
#include "ros_bridge/include/JsonMethodes.h"

namespace MsgGroupsNS = ROSBridge::MessageGroups;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
12
namespace PolyStampedNS = ROSBridge::JsonMethodes::GeometryMsgs::PolygonStamped;
13

Valentin Platzgummer's avatar
Valentin Platzgummer committed
14
typedef ROSBridge::MessageBaseClass ROSMsg;
15

16 17
template <class PointType = QPointF, template <class, class...> class ContainerType = QVector>
class Polygon2DTemplate : public ROSMsg{ //
Valentin Platzgummer's avatar
Valentin Platzgummer committed
18
    typedef ROSBridge::GenericMessages::GeometryMsgs::GenericPolygon<PointType, ContainerType> Poly;
19
public:
20
    typedef MsgGroupsNS::PolygonStampedGroup Group; // has no header
21

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

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

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

33 34 35 36 37 38 39 40
  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;
41 42

};
43 44

typedef Polygon2DTemplate<> Polygon2D;