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); PlaneSettings()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: Fragment()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 void clear(); get_revision() const64 unsigned int get_revision() const 65 { 66 return revision; 67 } 68 69 Type get_type() const override; 70 UUID get_uuid() const override; 71 std::string get_name() const; 72 73 json serialize() const; 74 75 private: 76 unsigned int revision = 0; 77 }; 78 } // namespace horizon 79