OdbDesignLib
OdbDesign ODB++ Parsing Library
 
Loading...
Searching...
No Matches
ContourPolygon.cpp
1#include "ContourPolygon.h"
2
3namespace Odb::Lib::FileModel::Design
4{
5 std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon> ContourPolygon::to_protobuf() const
6 {
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)
12 {
13 pContourPolygonMessage->add_polygonparts()->CopyFrom(*pPolygonPart->to_protobuf());
14 }
15 return pContourPolygonMessage;
16 }
17
18 void ContourPolygon::from_protobuf(const Odb::Lib::Protobuf::ContourPolygon& message)
19 {
20 type = (Type) message.type();
21 xStart = message.xstart();
22 yStart = message.ystart();
23 for (const auto& polygonPartMessage : message.polygonparts())
24 {
25 std::shared_ptr<PolygonPart> pPolygonPart(new PolygonPart);
26 pPolygonPart->from_protobuf(polygonPartMessage);
27 m_polygonParts.push_back(pPolygonPart);
28 }
29 }
30
31 // Inherited via IProtoBuffable
32 std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon::PolygonPart> ContourPolygon::PolygonPart::to_protobuf() const
33 {
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 pPolygonPartMessage->set_type(static_cast<Odb::Lib::Protobuf::ContourPolygon::PolygonPart::Type>(type));
41 return pPolygonPartMessage;
42 }
43
44 void ContourPolygon::PolygonPart::from_protobuf(const Odb::Lib::Protobuf::ContourPolygon::PolygonPart& message)
45 {
46 endX = message.endx();
47 endY = message.endy();
48 xCenter = message.xcenter();
49 yCenter = message.ycenter();
50 isClockwise = message.isclockwise();
51 type = static_cast<Type>(message.type());
52 }
53}