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 
9 class PlaneSettings {
10 public:
11  PlaneSettings(const json &j);
12  PlaneSettings()
13  {
14  }
15  enum class Style { ROUND, SQUARE, MITER };
16  uint64_t min_width = 0.2_mm;
17  Style style = Style::ROUND;
18  uint64_t extra_clearance = 0;
19  bool keep_orphans = false;
20 
21  enum class ConnectStyle { SOLID, THERMAL };
22  ConnectStyle connect_style = ConnectStyle::SOLID;
23 
24  uint64_t thermal_gap_width = 0.2_mm;
25  uint64_t thermal_spoke_width = 0.2_mm;
26 
27  enum class TextStyle { EXPAND, BBOX };
28  TextStyle text_style = TextStyle::EXPAND;
29 
30  enum class FillStyle { SOLID, HATCH };
31  FillStyle fill_style = FillStyle::SOLID;
32  uint64_t hatch_border_width = 0.5_mm;
33  uint64_t hatch_line_width = 0.2_mm;
34  uint64_t hatch_line_spacing = 0.5_mm;
35 
36  json serialize() const;
37 };
38 
39 class Plane : public PolygonUsage {
40 public:
41  class Fragment {
42  public:
43  Fragment()
44  {
45  }
46  Fragment(const json &j);
47  bool orphan = false;
48  ClipperLib::Paths paths; // first path is outline, others are holes
49  bool contains(const Coordi &c) const; // checks if point is in area defined by paths
50  json serialize() const;
51  };
52 
53  Plane(const UUID &uu, const json &j, class Board &brd);
54  Plane(const UUID &uu);
55  UUID uuid;
56  uuid_ptr<Net> net;
57  uuid_ptr<Polygon> polygon;
58  bool from_rules = true;
59  int priority = 0;
60  PlaneSettings settings;
61 
62  std::deque<Fragment> fragments;
63  unsigned int revision = 0;
64 
65  Type get_type() const override;
66  UUID get_uuid() const override;
67  std::string get_name() const;
68 
69  json serialize() const;
70 };
71 } // namespace horizon
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
libzip::uint64_t
zip_uint64_t uint64_t
zip_uint64_t_t typedef.
Definition: zip.hpp:108