11 enum class Orientation { LEFT, RIGHT, UP, DOWN };
15 enum class ObjectType {
64 enum class PatchType { OTHER, TRACK, PAD, PAD_TH, VIA, PLANE, HOLE_PTH, HOLE_NPTH, BOARD_EDGE, TEXT, N_TYPES };
66 extern const LutEnumStr<PatchType> patch_type_lut;
67 extern const LutEnumStr<ObjectType> object_type_lut;
68 extern const LutEnumStr<Orientation> orientation_lut;
78 template <
typename T>
class Coord {
91 Coord(T ix, T iy) : x(ix), y(iy)
97 Coord(std::vector<T> v) : x(v.at(0)), y(v.at(1))
128 bool operator==(
const Coord<T> &a)
const
130 return a.x == x && a.y == y;
132 bool operator!=(
const Coord<T> &a)
const
134 return !(a == *
this);
136 bool operator<(
const Coord<T> &a)
const
150 return Coord<T>(std::min(a.x, b.x), std::min(a.y, b.y));
158 return Coord<T>(std::max(a.x, b.x), std::max(a.y, b.y));
173 const float x2 = x * cos(a) - y * sin(a);
174 const float y2 = x * sin(a) + y * cos(a);
184 return x * a.x + y * a.y;
187 T cross(
const Coord<T> &other)
const
189 return (x * other.y) - (y * other.x);
197 return x * x + y * y;
202 return x > a.x && y > a.y && x < b.x && y < b.y;
205 void operator+=(
const Coord<T> a)
210 void operator-=(
const Coord<T> a)
223 std::array<T, 2> as_array()
const
230 typedef Coord<float> Coordf;
231 typedef Coord<int64_t> Coordi;
232 typedef Coord<double> Coordd;
239 Color(
double ir,
double ig,
double ib) : r(ir), g(ig), b(ib)
244 static Color new_from_int(
unsigned int ir,
unsigned ig,
unsigned ib)
246 return Color(ir / 255.0, ig / 255.0, ib / 255.0);
248 Color() : r(0), g(0), b(0)
258 bool operator<(
const ColorI &other)
const
260 return hashify() < other.hashify();
263 Color to_color()
const
265 return Color::new_from_int(r, g, b);
271 return r | (g << 8) | (b << 16);
275 constexpr
int64_t operator"" _mm(
long double i)
279 constexpr
int64_t operator"" _mm(
unsigned long long int i)
290 enum class CopyMode { DEEP, SHALLOW };
Class SHAPE.
Definition: shape.h:59
Definition: common.hpp:234
Your typical coordinate class.
Definition: common.hpp:78
T dot(const Coord< T > &a) const
Definition: common.hpp:182
T mag_sq() const
Definition: common.hpp:195
static Coord< T > max(const Coord< T > &a, const Coord< T > &b)
Definition: common.hpp:156
static Coord< T > min(const Coord< T > &a, const Coord< T > &b)
Definition: common.hpp:148
static Coord< float > euler(float r, float phi)
Definition: common.hpp:166
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
zip_uint32_t uint32_t
zip_uint32_t typedef.
Definition: zip.hpp:98
zip_uint8_t uint8_t
zip_uint8_t typedef.
Definition: zip.hpp:78
Definition: common.hpp:253
Definition: common.hpp:284