1#ifndef GYM_PCB_CONNECTION_H
2#define GYM_PCB_CONNECTION_H
18 constexpr static const bool EndpointsOnMaskedLayersOK =
true;
22 Connection(
const Connection&,
const Point_25 &source,
const Point_25 &target);
25 void setId(
int id) { mId = id; }
26 int id()
const {
return mId; }
27 std::string name()
const;
28 bool hasNet()
const {
return !!mNet; }
29 Net *net()
const {
return mNet; }
31 const Point_25& source()
const {
return mSource; }
32 const Point_25& target()
const {
return mTarget; }
33 Pin *sourcePin()
const {
return mSourcePin; }
34 Pin *targetPin()
const {
return mTargetPin; }
35 Pin *otherPin(
const Pin *)
const;
37 Component *sourceComponent()
const {
return mSourcePin ? mSourcePin->getParent() : 0; }
38 Component *targetComponent()
const {
return mTargetPin ? mTargetPin->getParent() : 0; }
40 Vector_2 vector2()
const {
return target().xy() - source().xy(); }
41 Segment_2 segment2()
const {
return Segment_2(source().xy(), target().xy()); }
43 void detachSourcePin();
44 void detachTargetPin();
48 bool hasTracks()
const {
return !mTracks.empty(); }
49 uint numTracks()
const {
return mTracks.size(); }
50 const std::vector<Track *>& getTracks()
const {
return mTracks; }
51 Track& getTrack(uint i)
const {
return *mTracks.at(i); }
54 Track *popTrack(uint index);
57 bool isRouted()
const {
return mIsRouted; }
58 bool _isRouted()
const;
59 void setRouted(
bool b) { mIsRouted = b; }
60 bool checkRouted() { setRouted(_isRouted());
return isRouted(); }
67 bool isLocked()
const {
return mLocked; }
68 void setLocked(
bool b) { mLocked = b; }
95 void makeDirectTrack(Real minSquaredLen, uint viaLocation);
113 Real clearance()
const {
return mClearance; }
114 Real defaultWidth()
const {
return mWidth; }
115 Real defaultViaDiameter()
const {
return mViaDiameter; }
116 Real defaultViaRadius()
const {
return mViaDiameter * 0.5; }
118 void setClearance(Real c) { mClearance = c; }
119 void setDefaultWidth(
float w) { mWidth = w; }
120 void setDefaultViaDiameter(Real d) { mViaDiameter = d; }
122 bool canRouteOnLayer(uint n)
const {
return mLayerMask & (1 << n); }
123 uint32_t getLayerMask()
const {
return mLayerMask; }
125 void setLayerMask(uint32_t);
127 void setParametersFrom(
const Connection&);
129 float referenceLen()
const {
return mReferenceLen; }
130 void setReferenceLen(
float v) { assert(mReferenceLen == 0.0f && v > 0.0f); mReferenceLen = v; }
132 Bbox_2 tracksBbox()
const;
134 Bbox_2 bboxAroundComps()
const;
136 Real squared_distance()
const {
return CGAL::squared_distance(mSource.xy(), mTarget.xy()); }
137 Real distance()
const {
return std::sqrt(squared_distance()); }
138 Real distance45()
const {
return geo::distance45(mSource.xy(), mTarget.xy()); }
144 template<
class Container>
static void sort_name(Container&);
164 Color getColor()
const;
166 std::string str()
const;
176 PyObject *
getPy(uint depth,
bool asNumpy)
const;
183 std::vector<Track *> mTracks;
187 uint32_t mLayerMask{0xffffffff};
189 bool mIsRouted{
false};
191 float mReferenceLen{0.0f};
192 Color mColor{Color::TRANSPARENT};
195 void mergeTrack(Track *);
196 void deleteEmptyTracks();
197 void updateEndpointForLayerMask(
bool target);
200inline void Connection::setParametersFrom(
const Connection &X)
202 setClearance(X.clearance());
203 setDefaultWidth(X.defaultWidth());
204 setDefaultViaDiameter(X.defaultViaDiameter());
205 setLayerMask(X.getLayerMask());
207inline Pin *Connection::otherPin(
const Pin *P)
const
209 assert(mSourcePin == P || mTargetPin == P);
210 return (mSourcePin == P) ? mTargetPin : mSourcePin;
213inline Track *Connection::popTrack(uint index)
216 const auto T = mTracks.at(index);
217 mTracks.erase(mTracks.begin() + index);
221template<
class Container>
void Connection::sort_name(Container &A)
225 [](
const Connection *
const L,
const Connection *
const R) ->
bool { return L->name() < R->name(); });
Definition Component.hpp:18
Definition Connection.hpp:17
void appendTrack(Track *T)
PyObject * getEndsPy() const
std::vector< std::pair< Point_25, Point_25 > > getRatsNest() const
PyObject * getTracksPy(bool asNumpy) const
uint numNecessaryVias() const
bool arePinsOnNet(const Net *) const
PyObject * getPy(uint depth, bool asNumpy) const
bool isOrderedXMajor() const
void makeDirectTrack45(Real minSquaredLen, uint viaLocation, float bendLocation)
bool intersects(const Connection &) const
void setColor(Color c)
Definition Connection.hpp:163
bool checkRasterization(const NavGrid &) const
bool isRasterized_allOrNone() const
bool updateForRemovedLayers(uint removedZMin, uint removedZMax)
The grid-representation of the board.
Definition NavGrid.hpp:61
Definition Geometry.hpp:131