OdbDesignLib
OdbDesign ODB++ Parsing Library
ContourPolygon.cpp
1 #include "ContourPolygon.h"
2 
3 namespace 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  return pPolygonPartMessage;
41  }
42 
43  void ContourPolygon::PolygonPart::from_protobuf(const Odb::Lib::Protobuf::ContourPolygon::PolygonPart& message)
44  {
45  endX = message.endx();
46  endY = message.endy();
47  xCenter = message.xcenter();
48  yCenter = message.ycenter();
49  isClockwise = message.isclockwise();
50  }
51 }