TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
clip.hpp File Reference

Polygon booleans and offsets on integer nanometres, a thin wrapper over Clipper2 (Angus Johnson, 2022; the Vatti scan-beam clipper, 1992). More...

#include <vector>
#include "geom/point.hpp"
#include "geom/shape.hpp"

Go to the source code of this file.

Classes

struct  tmk::geom::Polygon

Namespaces

namespace  tmk
namespace  tmk::geom

Typedefs

using tmk::geom::Ring = std::vector<Point>
 closed, first point not repeated
using tmk::geom::Rings = std::vector<Ring>
 a region under the non-zero fill rule: outer rings and holes

Enumerations

enum class  tmk::geom::Corners { tmk::geom::Round , tmk::geom::Chamfer }

Functions

Rings tmk::geom::unite (const Rings &a)
Rings tmk::geom::subtract (const Rings &a, const Rings &b)
Rings tmk::geom::intersect (const Rings &a, const Rings &b)
Rings tmk::geom::even_odd (const Rings &loops)
 Region of closed loops under the even-odd rule (a board outline with cut-outs).
Rings tmk::geom::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 tmk::geom::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 tmk::geom::circle_ring (Point centre, Coord radius, Coord max_error)
 Regular polygon around a circle with every edge outside it, chord 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)
bool tmk::geom::contains (const Rings &rs, Point p)
 Inside the region or on its boundary.
std::vector< Polygon > tmk::geom::polygons (const Rings &rs)
 The region as separate polygons (a fill's islands), each with its holes.
Ring tmk::geom::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).

Detailed Description

Polygon booleans and offsets on integer nanometres, a thin wrapper over Clipper2 (Angus Johnson, 2022; the Vatti scan-beam clipper, 1992).

Used for zone fills (doc 05 ยง36). Results depend only on the inputs and their order, so callers keep inputs in board order.

Definition in file clip.hpp.