跳转到主要内容

raygeo.ops.part

Workpiece state: cleared-area tracker, stock region, and part descriptor.

Maintains a union of swept-disk polygons and provides a spatial-indexed windowed query for efficient engagement computation.

Part

Unified workpiece description for motion assembly.

Carries geometry, physical metadata, and a ClearedArea tracking what has already been cut. Assemblers mutate the cleared area as they work.

cleared

cleared: cleared_area.ClearedArea

Accumulated cleared-area state — what has been cut so far.

Read-only snapshot. Assemblers mutate this internally; use it after an assembler returns to inspect remaining material, fragments, etc.

geometry

geometry: Optional[geo.Geometry]

Vector geometry (the outline(s) of the part), if any.

Returns None if no geometry was provided at construction time.

pixels_per_mm

pixels_per_mm: Optional[tuple[float, float]]

Pixel density (x, y) in px/mm, if set.

size_mm

size_mm: tuple[float, float]

Physical size (width, height) in millimetres.

stock_region

stock_region: StockRegion

Boundary and islands of the workpiece — cached extraction from geometry. Read-only.

from_polygons()

from_polygons(
boundary: Sequence[tuple[float, float]],
islands: Optional[Sequence[Sequence[tuple[float, float]]]] = None,
size_mm: tuple[float, float] = (0.0, 0.0),
initial: Optional[Sequence[Sequence[tuple[float, float]]]] = None,
) -> Part

Build a Part from a boundary polygon and optional islands.

ParameterTypeDescription
boundarySequence[tuple[float, float]]Outer boundary as [(x, y), ...].
islandsOptional[Sequence[Sequence[tuple[float, float]]]] = NoneList of island polygons, each [(x, y), ...] (default []).
size_mmtuple[float, float] = (0.0, 0.0)Physical size (width, height) in mm (default (0, 0)).
initialOptional[Sequence[Sequence[tuple[float, float]]]] = NoneOptional pre-seeded cleared polygons (e.g. a seed circle for adaptive clearing). When provided, the part's cleared area starts with these fragments instead of being empty.
ReturnsPartA new Part with the geometry constructed from the given polygons.

has_geometry()

has_geometry() -> bool

True if this Part has geometry.

ParameterTypeDescription
Returnsbool

StockRegion

Boundary and islands of a workpiece — the geometric input to clearing operations.

boundary

boundary: list[tuple[float, float]]

Outer boundary polygon as [(x, y), ...].

islands

islands: list[list[tuple[float, float]]]

List of island polygons, each [(x, y), ...].