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 "fab_output_settings.hpp"
13 #include "nlohmann/json_fwd.hpp"
14 #include "plane.hpp"
15 #include "pool/pool.hpp"
16 #include "track.hpp"
17 #include "util/uuid.hpp"
18 #include "util/warning.hpp"
19 #include "via.hpp"
20 #include "via_padstack_provider.hpp"
21 #include <fstream>
22 #include <map>
23 #include <vector>
24 
25 namespace horizon {
26 using json = nlohmann::json;
27 
28 class Board : public ObjectProvider, public LayerProvider {
29 private:
30  Board(const UUID &uu, const json &, Block &block, Pool &pool, ViaPadstackProvider &vpp);
31  // unsigned int update_nets();
32  bool propagate_net_segments();
33  std::map<UUID, uuid_ptr<Net>> net_segments;
34  std::map<int, Layer> layers;
35 
36  void delete_dependants();
37  void vacuum_junctions();
38 
39 public:
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);
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  const std::map<int, Layer> &get_layers() const override;
56  void set_n_inner_layers(unsigned int n);
57  unsigned int get_n_inner_layers() const;
58  void update_plane(Plane *plane, class CanvasPatch *ca = nullptr,
59  class CanvasPads *ca_pads = nullptr); // when ca is given, patches will be read from it
60  void update_planes();
61 
62  UUID uuid;
63  Block *block;
64  std::string name;
65  std::map<UUID, Polygon> polygons;
66  std::map<UUID, BoardHole> holes;
67  std::map<UUID, BoardPackage> packages;
68  std::map<UUID, Junction> junctions;
69  std::map<UUID, Track> tracks;
70  std::map<UUID, Track> airwires;
71  std::map<UUID, Via> vias;
72  std::map<UUID, Text> texts;
73  std::map<UUID, Line> lines;
74  std::map<UUID, Arc> arcs;
75  std::map<UUID, Plane> planes;
76  std::map<UUID, Dimension> dimensions;
77 
78  std::vector<Warning> warnings;
79 
80  BoardRules rules;
81  FabOutputSettings fab_output_settings;
82 
83  class StackupLayer {
84  public:
85  StackupLayer(int l, const json &j);
86  StackupLayer(int l);
87  json serialize() const;
88  int layer;
89  uint64_t thickness = 0.035_mm;
90  uint64_t substrate_thickness = .1_mm;
91  };
92  std::map<int, StackupLayer> stackup;
93 
94  ClipperLib::Paths obstacles;
95  ClipperLib::Path track_path;
96 
97  json serialize() const;
98 
99 private:
100  unsigned int n_inner_layers = 0;
101  ClipperLib::Paths get_thermals(class Plane *plane, class CanvasPads *ca) const;
102 };
103 } // namespace horizon
Interface for classes that store objects identified by UUID (e.g. Line or Junction) ...
Definition: object_provider.hpp:10
a class to store JSON values
Definition: json.hpp:161
Definition: canvas_patch.hpp:6
Definition: board.hpp:28
Definition: fab_output_settings.hpp:10
Definition: board_rules.hpp:18
Definition: via_padstack_provider.hpp:13
A block is one level of hierarchy in the netlist.
Definition: block.hpp:25
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:18
Definition: block.cpp:7
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: board_package.hpp:17
Definition: board.hpp:83