OdbDesignLib
OdbDesign ODB++ Parsing Library
ContourPolygon.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 #include <memory>
6 #include "../../odbdesign_export.h"
7 #include "../../IProtoBuffable.h"
8 #include "../../ProtoBuf/common.pb.h"
9 #include "../../odbdesign_export.h"
10 
11 
12 namespace Odb::Lib::FileModel::Design
13 {
14  struct ODBDESIGN_EXPORT ContourPolygon : public IProtoBuffable<Odb::Lib::Protobuf::ContourPolygon>
15  {
17  {
18  m_polygonParts.clear();
19  }
20 
21  struct ODBDESIGN_EXPORT PolygonPart : public IProtoBuffable<Odb::Lib::Protobuf::ContourPolygon::PolygonPart>
22  {
23  enum class Type
24  {
25  Segment,
26  Arc
27  };
28 
29  Type type;
30 
31  // Segment/Arc
32  float endX, endY;
33 
34  // Arc
35  float xCenter, yCenter;
36  bool isClockwise;
37 
38  // Inherited via IProtoBuffable
39  std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon::PolygonPart> to_protobuf() const override;
40  void from_protobuf(const Odb::Lib::Protobuf::ContourPolygon::PolygonPart& message) override;
41 
42  typedef std::vector<std::shared_ptr<PolygonPart>> Vector;
43 
44  inline static const char* SEGMENT_RECORD_TOKEN = "OS";
45  inline static const char* ARC_RECORD_TOKEN = "OC";
46 
47  }; // struct PolygonPart
48 
49  enum class Type
50  {
51  Island,
52  Hole
53  };
54 
55  Type type;
56  float xStart, yStart;
57 
58  PolygonPart::Vector m_polygonParts;
59 
60  // Inherited via IProtoBuffable
61  std::unique_ptr<Odb::Lib::Protobuf::ContourPolygon> to_protobuf() const override;
62  void from_protobuf(const Odb::Lib::Protobuf::ContourPolygon& message) override;
63 
64  typedef std::vector<std::shared_ptr<ContourPolygon>> Vector;
65 
66  inline static const char* BEGIN_RECORD_TOKEN = "OB";
67  inline static const char* END_RECORD_TOKEN = "OE";
68  inline static const char* ISLAND_TYPE_TOKEN = "I";
69  inline static const char* HOLE_TYPE_TOKEN = "H";
70 
71  }; // struct ContourPolygon
72 }