PCB Environment 2

Loading...
Searching...
No Matches
Layer.hpp
1
2#ifndef GYM_PCB_LAYER_H
3#define GYM_PCB_LAYER_H
4
5#include "Defs.hpp"
6#include "Py.hpp"
7#include "Enums.hpp"
8
9 class Layer
10{
11 public:
12 void setNumber(uint N) { mNumber = N; }
13 void setType(SignalType t) { mType = t; }
14 uint getNumber() const { return mNumber; }
15 SignalType getType() const { return mType; }
16 bool hasType(SignalType t) const { return (mType & t); }
17 bool isSignal() const { return !!(mType & SignalType::SIGNAL); }
18 bool isPower() const { return !!(mType & SignalType::POWER); }
19 bool isGround() const { return !!(mType & SignalType::GROUND); }
20 std::string str() const;
21 PyObject *getPy() const;
22 public:
23 static bool rangesOverlap(uint z0, uint z1, uint Z0, uint Z1);
24 private:
25 uint mNumber;
26 SignalType mType{SignalType::ANY};
27};
28
29 inline uint cutLayersFromRange(uint &zmin, uint &zmax, uint C0, uint C1)
30{
31 assert(zmin <= zmax && C0 <= C1);
32 if (zmax < C0)
33 return (zmax - zmin) + 1;
34 if (C0 <= zmin && zmax <= C1)
35 return 0;
36 const uint dn = (C1 - C0) + 1;
37 if (zmin >= C0) // zmin is above the cut range (then it drops by dn) or inside (then its new number is C0 as the first non-cut layer)
38 zmin = (zmin > C1) ? (zmin - dn) : C0;
39 zmax = (zmax > C1) ? (zmax - dn) : (C0 - 1); // if zmax is above the cut range it drops by dn, if it is inside it becomes the layer below the first cut one
40 assert(zmin <= zmax);
41 return (zmax - zmin) + 1;
42}
43
44 inline bool adjustIndexForCutLayers(uint &z, uint C0, uint C1)
45{
46 if (C0 <= z && z <= C1)
47 return false;
48 if (z > C1)
49 z -= (C1 - C0) + 1;
50 return true;
51}
52
53 inline bool Layer::rangesOverlap(uint z0, uint z1, uint Z0, uint Z1)
54{
55 return (z1 >= Z0) && (z0 <= Z1);
56}
57
58#endif // GYM_PCB_LAYER_H
Layer
Definition Layer.hpp:10