PCB Environment: /home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Loaders/Factory.hpp Source File

PCB Environment 2

Loading...
Searching...
No Matches
Factory.hpp
1
2#ifndef GYM_PCB_LOADERS_FACTORY_H
3#define GYM_PCB_LOADERS_FACTORY_H
4
5#include "Py.hpp"
6#include "Units.hpp"
7#include "Math/Misc.hpp"
8#include "Loaders/Topology.hpp"
9#include <cstdint>
10#include <map>
11#include <set>
12#include <string>
13
14class PCBoard;
15
16 class NetOverrides
17{
18public:
19 void load(PyObject *);
20 Micrometers traceWidth(const std::string &net, Micrometers) const;
21 Micrometers viaDiameter(const std::string &net, Micrometers) const;
22 Micrometers clearance(const std::string &net, Micrometers) const;
23 std::string str() const;
24private:
25 std::map<Micrometers, Micrometers> mTraceWidths;
26 std::map<Micrometers, Micrometers> mViaDiameters;
27 std::map<Micrometers, Micrometers> mClearances;
28 std::map<std::string, Micrometers> mNetTraceWidths;
29 std::map<std::string, Micrometers> mNetViaDiameters;
30 std::map<std::string, Micrometers> mNetClearances;
31private:
32 void set(std::map<std::string, Micrometers>&,
33 std::map<Micrometers, Micrometers>&, PyObject *);
34};
35
36 class PCBFactory
37{
38public:
39 PCBFactory();
40 const std::string& getData() const { return mData; }
41 PCBoard *create(const std::string &data);
42 PCBoard *loadAndCreate(const std::string &filePath);
43 void setUnitLength_nm(Nanometers nm) { mUnitLength_nm = nm; }
44 Nanometers getUnitLength_nm(Nanometers Default) const { return (mUnitLength_nm.value() > 0.0) ? mUnitLength_nm : Default; }
45 void setForceDesignRes(bool b) { mForceDesignRes = b; }
46 bool designResForced() const { return mForceDesignRes; }
47 void setFixedTrackParams(bool b) { mFixedTrackParams = b; }
48 Real hasFixedTrackParams() const { return mFixedTrackParams; }
49 void setNetOverrides(PyObject *over) { mNetOverrides.load(over); }
50 const NetOverrides& getNetOverrides() const { return mNetOverrides; }
51 void setTopologies(PyObject *);
52 const NetTopology *getTopology(const std::string &net) const;
53 void setAutocreateConnections(bool b) { mAutocreateConnections = b; }
54 bool autocreateConnections() const { return mAutocreateConnections; }
55 void setLockRoutedConnections(bool b) { mLockRoutedConnections = b; }
56 void setLoadFanout(bool b) { mLoadFanout = b; }
57 bool getLoadFanout() const { return mLoadFanout; }
58 void setLoadTracks(PyObject *);
59 bool getLoadTracksForNet(const std::string &name) const { return mLoadTracksAll || mLoadTracksNets.contains(name); }
60 void setRectifySegmentsDegrees(Real deg) { mRectifySegmentsRadians = math::Radians(deg); }
61 Real getRectifySegmentsRadians() const { return mRectifySegmentsRadians; }
62 void setLoadPolygonsAsBoxes(bool b) { mLoadPolygonsAsBoxes = b; }
63 bool loadPolygonsAsBoxes() const { return mLoadPolygonsAsBoxes; }
64 void setLayoutAreaMinMargin(float v) { mLayoutAreaMinMargin = v; } // relative if < 0, absolute if >= 0
65 void setLayoutAreaMaxMargin(float v) { mLayoutAreaMaxMargin = v; } // relative if < 0, absolute if >= 0
66 float getLayoutAreaMinMargin() const { return mLayoutAreaMinMargin; }
67 float getLayoutAreaMaxMargin() const { return mLayoutAreaMaxMargin; }
68 void setIgnoreLayoutBounds(bool b) { mIgnoreLayoutBounds = b; }
69 bool ignoreLayoutBounds() const { return mIgnoreLayoutBounds; }
70 bool checkPinIntersections() const { return mCheckPinIntersections; }
71private:
72 void loadOverrides();
73 void lockRoutedConnections(PCBoard&);
74 Nanometers mUnitLength_nm{0.0};
75 Real mRectifySegmentsRadians{math::Radians(0.125)};
76 bool mForceDesignRes{false};
77 bool mFixedTrackParams{false};
78 bool mLoadTracksAll{false};
79 bool mLoadFanout{false};
80 bool mLoadPolygonsAsBoxes{false};
81 float mLayoutAreaMinMargin{0.0f};
82 float mLayoutAreaMaxMargin{std::numeric_limits<float>::infinity()};
83 bool mIgnoreLayoutBounds{true};
84 bool mCheckPinIntersections{false};
85 bool mAutocreateConnections{true};
86 bool mLockRoutedConnections{false};
87 bool loadFile(const std::string &path);
88 std::string mData;
89 std::string mFormat{"dsn"};
90 std::set<std::string> mLoadTracksNets;
91 std::map<std::string, NetTopology> mTopologies;
92 NetOverrides mNetOverrides;
93 PCBoard *create();
94 PCBoard *createDSN();
95};
96inline const NetTopology *PCBFactory::getTopology(const std::string &net) const
97{
98 auto I = mTopologies.find(net);
99 if (I != mTopologies.end())
100 return &I->second;
101 return 0;
102}
103
104#endif // GYM_PCB_LOADERS_FACTORY_H
NetOverrides
Definition Factory.hpp:17
PCBoard
Definition PCBoard.hpp:36
NetTopology
Definition Topology.hpp:12