PCB Environment 2

Loading...
Searching...
No Matches
Net.hpp
1
2#ifndef GYM_PCB_NET_H
3#define GYM_PCB_NET_H
4
5#include "Defs.hpp"
6#include "Color.hpp"
7#include "Connection.hpp"
8#include "Layer.hpp"
9#include <set>
10#include <string>
11
12 class CloneEnv;
13 class PCBoard;
14 class Pin;
15 class NavGrid;
16 class Track;
17
18 class Net
19{
20 public:
21 Net(const std::string &name);
22 ~Net();
23 Net *clone(CloneEnv&) const;
24
26 PCBoard *getBoard() const { return mBoard; }
27 std::string name() const { return mName; }
28 uint id() const { return mId; }
29 const Color& getColor() const { return mColor; }
30
31 const std::set<Pin *>& getPins() const { return mPins; }
32 uint numPins() const { return mPins.size(); }
33 bool contains(const Pin *T) const { return mPins.find(const_cast<Pin *>(T)) != mPins.end(); }
34 bool empty() const { return mPins.empty(); }
35
36 uint numConnections() const { return mConnections.size(); }
37 const std::vector<Connection *>& connections() const { return mConnections; }
38 Connection *connection(uint i) const { return mConnections.at(i); }
39 Connection *getConnectionBetween(const Pin&, const Pin&) const;
40
41 // Return if the track is valid for this net (0x1) and board (0x2, if this is not set the track must not be used).
42 uint validateTrack(const Track&) const;
43
44 Real getMinTrackWidth() const { return mMinTrackWidth; }
45 Real getMinClearance() const { return mMinClearance; }
47 bool hasViaExtent() const { return mViaHeight != 0; }
48 uint getViaStartLayer() const { return mViaStartLayer; }
49 uint getViaHeight() const { return mViaHeight; }
50 Real getViaDiameter() const { return mViaDiameter; }
51 bool buriedViasOK() const { return mBuriedViasOK; }
52 uint32_t getLayerMask() const { return mLayerMask; }
53 bool isGroundOrPower() const { return mSignalType & SignalType::POWER_GROUND; }
54 bool isGround() const { return mSignalType == SignalType::GROUND; }
55 SignalType signalType() const { return mSignalType; }
56
57 void insert(Pin&);
58 void remove(Pin&);
59 Connection *addConnection(Pin *sourcePin, const Point_25& source, Pin *targetPin, const Point_25& target);
61 void autocreateConnections();
62 void sortConnections();
63
64 void setMinTrackWidth(Real);
65 void setMinClearance(Real c);
66 void setViaExtent(uint start, uint h) { mViaStartLayer = start; mViaHeight = h; }
67 void setViaDiameter(Real d);
68 void setLayerMask(uint32_t m);
69 void setLayerMaskFromSignalType();
70 void setSignalType(SignalType t) { mSignalType = t; }
71
72 static SignalType getLikelySignalTypeForName(const std::string&);
73
74 void setBoard(PCBoard *board) { mBoard = board; }
76 void setId(uint id);
77 void setColor(const Color &c) { mColor = c; }
79 void setColorAuto(bool singleColorPerType = false);
80
82 bool extract(Component&);
84 bool pruneConnections(std::set<Connection *> &keep);
85
86 std::string str() const;
87 PyObject *getConnectionsPy(uint depth, bool asNumpy) const;
88 PyObject *getPinsPy() const;
89 PyObject *getPy(uint depth, bool asNumpy) const;
90
91 private:
92 std::set<Pin *> mPins;
93 std::vector<Connection *> mConnections; // These are owned by the net!
94 const std::string mName;
95 PCBoard *mBoard{0};
96 uint mId;
97 uint mViaStartLayer{0};
98 uint mViaHeight{0};
99 bool mBuriedViasOK{false};
100 Real mViaDiameter{0.0};
101 Real mMinTrackWidth{0.0};
102 Real mMinClearance{0.0};
103 uint32_t mLayerMask{0xffffffff};
104 Color mColor;
105 SignalType mSignalType{SignalType::ANY};
106
107 private:
108 void removeConnectionsWithNonmemberPins();
109 void rebuildPinSetFromConnections();
110};
111
112#endif // GYM_PCB_NET_H
CloneEnv
Definition Clone.hpp:17
Color
Definition Color.hpp:9
Component
Definition Component.hpp:18
NavGrid
The grid-representation of the board.
Definition NavGrid.hpp:61
Net::getBoard
PCBoard * getBoard() const
Board-wide unique name and ID.
Definition Net.hpp:26
Net::setColorAuto
void setColorAuto(bool singleColorPerType=false)
Colorize according to signal type and net number/id.
Net::setId
void setId(uint id)
NOTE: connection ID = (net ID << 16) | connection index, so net ID must be < 0x7fff.
Net::autocreateConnections
void autocreateConnections()
Create 2-pin connections from the set of pins.
Net::hasViaExtent
bool hasViaExtent() const
FIXME: via extent is not handled in A*.
Definition Net.hpp:47
Net::pruneConnections
bool pruneConnections(std::set< Connection * > &keep)
Remove all connections not in @keep and return whether the net is then empty.
Net::extract
bool extract(Component &)
Remove all connections connected to @Component and return whether the net is then empty.
PCBoard
Definition PCBoard.hpp:36
Pin
Definition Pin.hpp:18
Track
Definition Track.hpp:21