Horizon
polygon.hpp
1 #pragma once
2 #include "util/uuid.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include "common.hpp"
5 #include "junction.hpp"
6 #include "util/uuid_ptr.hpp"
7 #include <deque>
8 #include <map>
9 #include <fstream>
10 
11 namespace horizon {
12 using json = nlohmann::json;
13 
14 
15 class PolygonUsage : public UUIDProvider {
16 public:
17  enum class Type { INVALID, PLANE, KEEPOUT };
18  virtual Type get_type() const = 0;
19  virtual UUID get_uuid() const = 0;
20  virtual ~PolygonUsage(){};
21 };
22 
27 class Polygon : public UUIDProvider {
28 public:
29  class Vertex {
30  public:
31  enum class Type { LINE, ARC };
32 
33  Vertex(const json &j);
34  Vertex(const Coordi &c);
35  Vertex()
36  {
37  }
38  json serialize() const;
39  bool remove = false;
40 
41  Type type = Type::LINE;
42  Coordi position;
43  Coordi arc_center;
48  bool arc_reverse = false;
49  };
50 
51 
52  Polygon(const UUID &uu, const json &j);
53  Polygon(const UUID &uu);
54  UUID get_uuid() const;
55 
56  Vertex *append_vertex(const Coordi &pos = Coordi());
57  std::pair<unsigned int, unsigned int> get_vertices_for_edge(unsigned int edge);
63  Polygon remove_arcs(unsigned int precision = 16) const;
64 
68  bool has_arcs() const;
69  bool is_valid() const;
70 
71  UUID uuid;
72  std::deque<Vertex> vertices;
73  int layer = 0;
74  std::string parameter_class;
75 
76  bool temp = false;
78  json serialize() const;
79 };
80 } // namespace horizon
horizon::Polygon
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
horizon::uuid_ptr
Definition: uuid_ptr.hpp:9
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::PolygonUsage
Definition: polygon.hpp:15
horizon::Polygon::Vertex
Definition: polygon.hpp:29
horizon::Polygon::Vertex::arc_reverse
bool arc_reverse
false: counter clockwise true: clockwise
Definition: polygon.hpp:48
horizon::Coord< int64_t >
horizon::Polygon::remove_arcs
Polygon remove_arcs(unsigned int precision=16) const
Definition: polygon.cpp:55
horizon::Polygon::has_arcs
bool has_arcs() const
Definition: polygon.cpp:116
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::UUIDProvider
Interface for objects that have a UUID.
Definition: uuid_provider.hpp:9