Horizon
plane.hpp
1 #pragma once
2 #include "block/net.hpp"
3 #include "clipper/clipper.hpp"
4 #include "common/polygon.hpp"
5 
6 namespace horizon {
7 using json = nlohmann::json;
8 
10 public:
12  {
13  }
14 
15  ThermalSettings(const json &j);
16 
17  enum class ConnectStyle { SOLID, THERMAL, FROM_PLANE };
18  ConnectStyle connect_style = ConnectStyle::SOLID;
19 
20  uint64_t thermal_gap_width = 0.2_mm;
21  uint64_t thermal_spoke_width = 0.2_mm;
22  unsigned int n_spokes = 4;
23  int angle = 0;
24 
25  void serialize(json &j) const;
26 };
27 
29 public:
30  PlaneSettings(const json &j);
32  {
33  }
34  enum class Style { ROUND, SQUARE, MITER };
35  uint64_t min_width = 0.2_mm;
36  Style style = Style::ROUND;
37  uint64_t extra_clearance = 0;
38  bool keep_orphans = false;
39 
40  ThermalSettings thermal_settings;
41 
42  enum class TextStyle { EXPAND, BBOX };
43  TextStyle text_style = TextStyle::EXPAND;
44 
45  enum class FillStyle { SOLID, HATCH };
46  FillStyle fill_style = FillStyle::SOLID;
47  uint64_t hatch_border_width = 0.5_mm;
48  uint64_t hatch_line_width = 0.2_mm;
49  uint64_t hatch_line_spacing = 0.5_mm;
50 
51  json serialize() const;
52 };
53 
54 class Plane : public PolygonUsage {
55 public:
56  class Fragment {
57  public:
58  Fragment()
59  {
60  }
61  Fragment(const json &j);
62  bool orphan = false;
63  ClipperLib::Paths paths; // first path is outline, others are holes
64  bool contains(const Coordi &c) const; // checks if point is in area defined by paths
65  json serialize() const;
66  };
67 
68  Plane(const UUID &uu, const json &j, class Board *brd);
69  Plane(const UUID &uu);
70  UUID uuid;
71  uuid_ptr<Net> net;
72  uuid_ptr<Polygon> polygon;
73  bool from_rules = true;
74  int priority = 0;
75  PlaneSettings settings;
76 
77  std::deque<Fragment> fragments;
78  void clear();
79  unsigned int get_revision() const
80  {
81  return revision;
82  }
83  void load_fragments(const json &j);
84 
85  Type get_type() const override;
86  UUID get_uuid() const override;
87  std::string get_name() const;
88 
89  json serialize() const;
90  json serialize_fragments() const;
91 
92 private:
93  unsigned int revision = 0;
94 };
95 } // namespace horizon
Definition: board.hpp:47
Definition: plane.hpp:28
Definition: plane.hpp:56
Definition: plane.hpp:54
Definition: polygon.hpp:13
Definition: plane.hpp:9
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: uuid_ptr.hpp:8
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62