119 lines
2.3 KiB
C
119 lines
2.3 KiB
C
|
|
/**
|
|||
|
|
* GraphicDefines.h
|
|||
|
|
*
|
|||
|
|
* @brief: 自动驾驶绘图相关定义
|
|||
|
|
* @author: zhanke
|
|||
|
|
* @history: 2024-08-21, create file
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef GRAPHICDEFINES_H
|
|||
|
|
#define GRAPHICDEFINES_H
|
|||
|
|
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
|
|||
|
|
namespace graphic
|
|||
|
|
{
|
|||
|
|
struct AutoPoint
|
|||
|
|
{
|
|||
|
|
AutoPoint() = default;
|
|||
|
|
|
|||
|
|
AutoPoint(const AutoPoint& point)
|
|||
|
|
{
|
|||
|
|
this->x = point.x;
|
|||
|
|
this->y = point.y;
|
|||
|
|
this->yaw = point.yaw;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AutoPoint& operator=(const AutoPoint& point)
|
|||
|
|
{
|
|||
|
|
this->x = point.x;
|
|||
|
|
this->y = point.y;
|
|||
|
|
this->yaw = point.yaw;
|
|||
|
|
return *this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AutoPoint(double x, double y)
|
|||
|
|
{
|
|||
|
|
this->x = x;
|
|||
|
|
this->y = y;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AutoPoint(double x, double y, double yaw)
|
|||
|
|
{
|
|||
|
|
this->x = x;
|
|||
|
|
this->y = y;
|
|||
|
|
this->yaw = yaw;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
double x = 0.0;
|
|||
|
|
double y = 0.0;
|
|||
|
|
double yaw = 0.0;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
using AutoPointList = std::vector<AutoPoint>;
|
|||
|
|
|
|||
|
|
struct AutoLine
|
|||
|
|
{
|
|||
|
|
AutoLine() = default;
|
|||
|
|
AutoLine(AutoPoint p1, AutoPoint p2)
|
|||
|
|
{
|
|||
|
|
point1 = p1;
|
|||
|
|
point2 = p2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::string tag;
|
|||
|
|
std::string index;
|
|||
|
|
AutoPoint point1;
|
|||
|
|
AutoPoint point2;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
struct AutoRect
|
|||
|
|
{
|
|||
|
|
AutoRect() = default;
|
|||
|
|
AutoRect(AutoPoint p1, AutoPoint p2) { topLeft = p1, bottomRight = p2; }
|
|||
|
|
|
|||
|
|
bool contains(const AutoPoint& p)
|
|||
|
|
{
|
|||
|
|
return topLeft.x <= p.x && topLeft.y <= p.y && bottomRight.x >= p.x && bottomRight.y >= p.y;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AutoPoint topLeft;
|
|||
|
|
AutoPoint bottomRight;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
struct AutoPolygon
|
|||
|
|
{
|
|||
|
|
AutoPolygon() = default;
|
|||
|
|
|
|||
|
|
AutoPolygon(const AutoPolygon& polygon)
|
|||
|
|
{
|
|||
|
|
this->index = polygon.index;
|
|||
|
|
this->tag1 = polygon.tag1;
|
|||
|
|
this->tag2 = polygon.tag2;
|
|||
|
|
this->tag3 = polygon.tag3;
|
|||
|
|
this->pointList = polygon.pointList;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AutoPolygon& operator=(const AutoPolygon& polygon)
|
|||
|
|
{
|
|||
|
|
this->index = polygon.index;
|
|||
|
|
this->tag1 = polygon.tag1;
|
|||
|
|
this->tag2 = polygon.tag2;
|
|||
|
|
this->tag3 = polygon.tag3;
|
|||
|
|
this->pointList = polygon.pointList;
|
|||
|
|
return *this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void addPoint(double x, double y) { pointList.emplace_back(AutoPoint(x, y)); }
|
|||
|
|
|
|||
|
|
std::string index;
|
|||
|
|
std::string tag1;
|
|||
|
|
std::string tag2;
|
|||
|
|
std::string tag3;
|
|||
|
|
AutoPointList pointList;
|
|||
|
|
};
|
|||
|
|
} // namespace graphic
|
|||
|
|
|
|||
|
|
#endif // GRAPHICDEFINES_H
|