|
TraceMaker
C++ API of the engine
|
Classes | |
| struct | Polygon |
| struct | Point |
| struct | Box |
| class | PolygonIndex |
| struct | Shape |
Typedefs | |
| using | Ring = std::vector<Point> |
| closed, first point not repeated | |
| using | Rings = std::vector<Ring> |
| a region under the non-zero fill rule: outer rings and holes | |
| using | i128 = __int128 |
| GCC extension; exact products of nm coordinates. | |
Enumerations | |
| enum class | Corners { Round , Chamfer } |
Functions | |
| Rings | unite (const Rings &a) |
| Rings | subtract (const Rings &a, const Rings &b) |
| Rings | intersect (const Rings &a, const Rings &b) |
| Rings | even_odd (const Rings &loops) |
| Region of closed loops under the even-odd rule (a board outline with cut-outs). | |
| Rings | offset (const Rings &a, Coord delta, Corners corners, Coord max_error) |
| Grows (delta > 0) or shrinks a region; round corners stay within max_error of the true arc. | |
| Rings | shape_rings (const Shape &s, Coord grow, Coord max_error) |
| s grown by grow, every approximated arc outside the true one (KiCad's ERROR_OUTSIDE), so a knockout built from it is never smaller than the clearance asks. | |
| Ring | circle_ring (Point centre, Coord radius, Coord max_error) |
| Regular polygon around a circle with every edge outside it, chord error <= max_error. | |
| double | area (const Ring &r) |
| signed: outer rings positive, holes negative (as returned by these functions) | |
| double | area (const Rings &rs) |
| bool | contains (const Rings &rs, Point p) |
| Inside the region or on its boundary. | |
| std::vector< Polygon > | polygons (const Rings &rs) |
| The region as separate polygons (a fill's islands), each with its holes. | |
| Ring | fracture (const Polygon &p) |
| One ring with zero-width bridges from every hole to the outline, as KiCad writes a zone's filled_polygon (SHAPE_POLY_SET::Fracture). | |
| Coord | kiround (double v) |
| Rounds half away from zero, like KiCad's KiROUND. | |
| double | norm_deg (double a) |
| Normalises degrees to [0, 360). | |
| Point | rotate (Point p, double deg) |
| Rotates p by deg degrees the way KiCad does: positive angles turn counter-clockwise on screen in KiCad's y-down coordinates. | |
| i128 | orient (Point a, Point b, Point c) |
| Orientation of c relative to a→b: >0 left (counter-clockwise in y-up math terms), <0 right, 0 collinear. | |
| bool | segments_intersect (Point a, Point b, Point c, Point d) |
| True if closed segments ab and cd share at least one point. | |
| bool | point_seg_closer (Point p, Point a, Point b, Coord t) |
| True if the distance from p to segment ab is strictly less than t (t >= 0). | |
| bool | seg_seg_closer (Point a, Point b, Point c, Point d, Coord t) |
| True if the distance between segments ab and cd is strictly less than t (t >= 0). | |
| long double | point_seg_dist (Point p, Point a, Point b) |
| Distances in nm (not squared), for reporting (long double). | |
| long double | seg_seg_dist (Point a, Point b, Point c, Point d) |
| bool | point_in_polygon (Point p, const std::vector< Point > &poly) |
| Point in closed polygon (boundary counts as inside). | |
| bool | closer_than (const Shape &a, const Shape &b, Coord clearance) |
| True if the gap between the two shapes (distance between their surfaces, negative when they overlap) is strictly less than clearance. | |
| bool | closer_than_disk (const Shape &a, Point c, Coord r, Coord clearance) |
| Equivalent to closer_than(a, Shape::point(c, r), clearance), without allocating. | |
| double | gap (const Shape &a, const Shape &b) |
| Gap between two shapes in nm (negative = overlap depth bound; 0 when cores touch with r = 0). | |
| std::vector< Point > | arc_points (Point start, Point mid, Point end, Coord max_error=5 '000) |
| Flattens a circular arc through start/mid/end into points with sagitta error <= max_error. | |
| std::vector< Point > | circle_points (Point centre, Coord radius, Coord max_error=5 '000) |
| Circle outline as a closed polyline (first point repeated at the end). | |
| std::vector< Point > | convex_hull (std::vector< Point > pts) |
| Convex hull, counter-clockwise in a y-up frame, no repeated point (Andrew's monotone chain, 1979; exact integer orientation tests). | |
| using tmk::geom::i128 = __int128 |
| using tmk::geom::Ring = std::vector<Point> |
| using tmk::geom::Rings = std::vector<Ring> |
|
strong |
| std::vector< Point > tmk::geom::arc_points | ( | Point | start, |
| Point | mid, | ||
| Point | end, | ||
| Coord | max_error = 5 '000 ) |
Flattens a circular arc through start/mid/end into points with sagitta error <= max_error.
| double tmk::geom::area | ( | const Ring & | r | ) |
signed: outer rings positive, holes negative (as returned by these functions)
| double tmk::geom::area | ( | const Rings & | rs | ) |
| std::vector< Point > tmk::geom::circle_points | ( | Point | centre, |
| Coord | radius, | ||
| Coord | max_error = 5 '000 ) |
Circle outline as a closed polyline (first point repeated at the end).
Regular polygon around a circle with every edge outside it, chord error <= max_error.
True if the gap between the two shapes (distance between their surfaces, negative when they overlap) is strictly less than clearance.
clearance may be 0 (then: do they overlap or touch? no — strictly overlap).
Equivalent to closer_than(a, Shape::point(c, r), clearance), without allocating.
Convex hull, counter-clockwise in a y-up frame, no repeated point (Andrew's monotone chain, 1979; exact integer orientation tests).
Fewer than three distinct points are returned sorted.
Region of closed loops under the even-odd rule (a board outline with cut-outs).
One ring with zero-width bridges from every hole to the outline, as KiCad writes a zone's filled_polygon (SHAPE_POLY_SET::Fracture).
Holes are joined in order of their leftmost point, each by a horizontal bridge to the nearest edge on its left (the hole-elimination step of ear clipping; Eberly, 2002).
Gap between two shapes in nm (negative = overlap depth bound; 0 when cores touch with r = 0).
|
inline |
|
inline |
Grows (delta > 0) or shrinks a region; round corners stay within max_error of the true arc.
Point in closed polygon (boundary counts as inside).
True if the distance from p to segment ab is strictly less than t (t >= 0).
Distances in nm (not squared), for reporting (long double).
The region as separate polygons (a fill's islands), each with its holes.
True if the distance between segments ab and cd is strictly less than t (t >= 0).
True if closed segments ab and cd share at least one point.
s grown by grow, every approximated arc outside the true one (KiCad's ERROR_OUTSIDE), so a knockout built from it is never smaller than the clearance asks.