PCB Environment 2

Loading...
Searching...
No Matches
NavImage.hpp
1#ifndef GYM_PCB_NAVIMAGE
2#define GYM_PCB_NAVIMAGE
3
5
6#include "Rasterizer.hpp"
7
8 class PCBoard;
9 class NavGrid;
10 class NavPoint;
11 class Pin;
12 class Connection;
13 class Track;
14 class Via;
15
16#define NAV_IMAGE_NUM_CHANS 8
17
18#define NAV_IMAGE_CHAN_TRACK_T 0
19#define NAV_IMAGE_CHAN_TRACK_B 3
20#define NAV_IMAGE_CHAN_TRACK_M 6
21#define NAV_IMAGE_CHAN_PIN_T 1
22#define NAV_IMAGE_CHAN_PIN_B 4
23#define NAV_IMAGE_CHAN_RATSNEST_T 2
24#define NAV_IMAGE_CHAN_RATSNEST_B 5
25#define NAV_IMAGE_CHAN_VIA 7
26
32 template<typename chan_t> struct NavPixel
33{
34 chan_t Chan[NAV_IMAGE_NUM_CHANS];
35 void setFloat(const NavPixel<float>&, float coverage);
36 void addPoint(const NavPoint&, char z, chan_t vTB, chan_t vM);
37 void addPin(char z, chan_t);
38 void addRatsNest(char z, chan_t);
39 void addTrack(char z, chan_t vTB, chan_t vM);
40 void addVia(chan_t);
41 void zero();
42 bool isNonzero() const;
43};
44
47 template<typename chan_t> class NavImage : public UniformGrid25
48{
49 constexpr static const chan_t FullCoverage = std::is_same_v<chan_t, float> ? 1 : 144;
50 public:
51 NavImage(const NavImage<chan_t>&);
52 NavImage(const NavGrid&);
53 NavImage(uint w, uint h, const Bbox_2&, uint numLayers);
54 ~NavImage();
55 size_t sizeInBytes() const { return getNumPoints2D() * sizeof(NavPixel<chan_t>); }
56 int checkFit(const UniformGrid25&) const; // -1/0/1 for </=/>
57
58 NavPixel<chan_t>& at(uint i) { return mData[i]; }
59 NavPixel<chan_t>& at(uint x, uint y) { return mData[y * mSize[0] + x]; }
60 const NavPixel<chan_t>& at(uint x, uint y) const { return mData[y * mSize[0] + x]; }
61
63 void draw1To1(const NavGrid&);
64 void drawDownscale(const NavGrid&);
65 void drawStatic(const PCBoard&);
66 void drawDynamic(const PCBoard&);
67 void drawRatsNest(const PCBoard&, const bool all);
68 void draw(const Pin&);
69 void draw(const Connection&);
70 void draw(const Track&);
71 void drawRatsNest(const Connection&);
72
73 static chan_t getLayerMCoverage(uint d);
74
75 PyObject *movePy(); // transfers ownership of mData to PyObject
76 private:
77 NavPixel<chan_t> *mData;
78 uint mLayerB;
79 chan_t mLayerMCoverage; // e.g. (1 / number of inner layers)
80
81 private:
82 void allocate();
83 char ZLabel(uint z) const;
84
85 static Real computeEdgeLen(uint w, uint h, const Bbox_2&);
86
87 void draw(const Via&);
88 void drawCopper(const Segment_25&);
89};
90
91#endif // GYM_PCB_NAVIMAGE
Connection
Definition Connection.hpp:17
NavGrid
The grid-representation of the board.
Definition NavGrid.hpp:61
NavImage::draw1To1
void draw1To1(const NavGrid &)
WARNING: draw1To1() does not set via channel.
NavPoint
Definition NavPoint.hpp:116
PCBoard
Definition PCBoard.hpp:36
Pin
Definition Pin.hpp:18
Segment_25
Definition Geometry.hpp:155
Track
Definition Track.hpp:21
Via
Definition Via.hpp:10
NavPixel
Definition NavImage.hpp:33