Horizon
board.hpp
1 #pragma once
2 #include "block/block.hpp"
3 #include "board_hole.hpp"
4 #include "board_package.hpp"
5 #include "board_rules.hpp"
6 #include "clipper/clipper.hpp"
7 #include "common/dimension.hpp"
8 #include "common/hole.hpp"
9 #include "common/junction.hpp"
10 #include "common/layer_provider.hpp"
11 #include "common/polygon.hpp"
12 #include "common/keepout.hpp"
13 #include "fab_output_settings.hpp"
14 #include "nlohmann/json_fwd.hpp"
15 #include "plane.hpp"
16 #include "pool/pool.hpp"
17 #include "track.hpp"
18 #include "util/uuid.hpp"
19 #include "util/warning.hpp"
20 #include "via.hpp"
21 #include "via_padstack_provider.hpp"
22 #include <fstream>
23 #include <map>
24 #include <vector>
25 
26 namespace horizon {
27 using json = nlohmann::json;
28 
29 class Board : public ObjectProvider, public LayerProvider {
30 private:
31  // unsigned int update_nets();
32  void propagate_nets();
33  std::map<int, Layer> layers;
34 
35  void delete_dependants();
36  void vacuum_junctions();
37 
38 public:
39  Board(const UUID &uu, const json &, Block &block, Pool &pool, ViaPadstackProvider &vpp);
40  static Board new_from_file(const std::string &filename, Block &block, Pool &pool, ViaPadstackProvider &vpp);
41  Board(const UUID &uu, Block &block);
42 
43  void expand(bool careful = false);
44  void expand_packages();
45 
46  Board(const Board &brd);
47  void operator=(const Board &brd);
48  void update_refs();
49  void update_airwires(bool fast = false, const std::set<UUID> &nets = {});
50  void disconnect_package(BoardPackage *pkg);
51 
52  void smash_package(BoardPackage *pkg);
53  void unsmash_package(BoardPackage *pkg);
54  Junction *get_junction(const UUID &uu) override;
55  Polygon *get_polygon(const UUID &uu) override;
56  const std::map<int, Layer> &get_layers() const override;
57  void set_n_inner_layers(unsigned int n);
58  unsigned int get_n_inner_layers() const;
59  void update_plane(Plane *plane, const class CanvasPatch *ca = nullptr,
60  const class CanvasPads *ca_pads = nullptr); // when ca is given, patches will be read from it
61  void update_planes();
62  std::vector<KeepoutContour> get_keepout_contours() const;
63 
64  UUID uuid;
65  Block *block;
66  std::string name;
67  std::map<UUID, Polygon> polygons;
68  std::map<UUID, BoardHole> holes;
69  std::map<UUID, BoardPackage> packages;
70  std::map<UUID, Junction> junctions;
71  std::map<UUID, Track> tracks;
72  std::map<UUID, Track> airwires;
73  std::map<UUID, Via> vias;
74  std::map<UUID, Text> texts;
75  std::map<UUID, Line> lines;
76  std::map<UUID, Arc> arcs;
77  std::map<UUID, Plane> planes;
78  std::map<UUID, Keepout> keepouts;
79  std::map<UUID, Dimension> dimensions;
80 
81  std::vector<Warning> warnings;
82 
83  BoardRules rules;
84  FabOutputSettings fab_output_settings;
85 
86  class StackupLayer {
87  public:
88  StackupLayer(int l, const json &j);
89  StackupLayer(int l);
90  json serialize() const;
91  int layer;
92  uint64_t thickness = 0.035_mm;
93  uint64_t substrate_thickness = .1_mm;
94  };
95  std::map<int, StackupLayer> stackup;
96 
97  class Colors {
98  public:
99  Color solder_mask;
100  Color substrate;
101  };
102  Colors colors;
103 
104  ClipperLib::Paths obstacles;
105  ClipperLib::Path track_path;
106 
107  enum ExpandFlags {
108  EXPAND_ALL = 0xff,
109  EXPAND_PROPAGATE_NETS = (1 << 0),
110  EXPAND_AIRWIRES = (1 << 1),
111  EXPAND_PACKAGES = (1 << 2)
112  };
113 
114  ExpandFlags expand_flags = EXPAND_ALL;
115  std::set<UUID> packages_expand;
116 
117  json serialize() const;
118 
119 private:
120  unsigned int n_inner_layers = 0;
121  ClipperLib::Paths get_thermals(class Plane *plane, const class CanvasPads *ca) const;
122 };
123 } // namespace horizon
Interface for classes that store objects identified by UUID (e.g. Line or Junction) ...
Definition: object_provider.hpp:10
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
Definition: board.hpp:97
a class to store JSON values
Definition: json.hpp:161
Definition: canvas_patch.hpp:6
Definition: board.hpp:29
Definition: fab_output_settings.hpp:10
Definition: board_rules.hpp:20
Definition: via_padstack_provider.hpp:13
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Definition: layer_provider.hpp:7
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: plane.hpp:39
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:19
Definition: block.cpp:9
Definition: canvas_pads.hpp:7
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
Definition: common.hpp:207
Definition: board_package.hpp:17
Definition: board.hpp:86