1 #include "ContourPolygon.h"
3 namespace Odb::Lib::FileModel::Design
5 std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon> ContourPolygon::to_protobuf()
const
7 std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon> pContourPolygonMessage(
new Odb::Lib::Protobuf::ContourPolygon);
8 pContourPolygonMessage->set_type((Odb::Lib::Protobuf::ContourPolygon::Type) type);
9 pContourPolygonMessage->set_xstart(xStart);
10 pContourPolygonMessage->set_ystart(yStart);
11 for (
const auto& pPolygonPart : m_polygonParts)
13 pContourPolygonMessage->add_polygonparts()->CopyFrom(*pPolygonPart->to_protobuf());
15 return pContourPolygonMessage;
18 void ContourPolygon::from_protobuf(
const Odb::Lib::Protobuf::ContourPolygon& message)
20 type = (Type) message.type();
21 xStart = message.xstart();
22 yStart = message.ystart();
23 for (
const auto& polygonPartMessage : message.polygonparts())
25 std::shared_ptr<PolygonPart> pPolygonPart(
new PolygonPart);
26 pPolygonPart->from_protobuf(polygonPartMessage);
27 m_polygonParts.push_back(pPolygonPart);
32 std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon::PolygonPart> ContourPolygon::PolygonPart::to_protobuf()
const
34 std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon::PolygonPart> pPolygonPartMessage(
new Odb::Lib::Protobuf::ContourPolygon::PolygonPart);
35 pPolygonPartMessage->set_endx(endX);
36 pPolygonPartMessage->set_endy(endY);
37 pPolygonPartMessage->set_xcenter(xCenter);
38 pPolygonPartMessage->set_ycenter(yCenter);
39 pPolygonPartMessage->set_isclockwise(isClockwise);
40 return pPolygonPartMessage;
43 void ContourPolygon::PolygonPart::from_protobuf(
const Odb::Lib::Protobuf::ContourPolygon::PolygonPart& message)
45 endX = message.endx();
46 endY = message.endy();
47 xCenter = message.xcenter();
48 yCenter = message.ycenter();
49 isClockwise = message.isclockwise();