Ir al contenido principal

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.

FaceState

Geometry, stock region, and cleared area for one face of a multi-face part.

Read-only snapshot. Assemblers mutate face state internally; use the getters to inspect the state after assembly.

cleared

cleared: cleared_area.ClearedArea

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

geometry

geometry: Optional[geo.Geometry]

Vector geometry for this face, if any.

stock_region

stock_region: StockRegion

Boundary and islands of this face — the geometric input to clearing operations.

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.

face_ids

face_ids: list[str]

All face ids in this part.

The empty string "" is the default (largest) face; other faces are "1", "2", ... (sorted by pocket area descending). A single-pocket part has exactly [""].

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.

image

image: Optional[list[int]]

Optional pixel image buffer for raster/shrinkwrap operations.

Set by the stage before calling an assembler. The assembler reads this internally instead of accepting a separate image argument. Expects a 2-D uint8 numpy array; the value is stored on the part as a WholeImageSource and is also accessible via the image_source property.

image_source

image_source: Optional[Any]

The lazy ImageSource backing this part, or None if no raster image has been attached.

Reading this property returns the same instance that was passed to the setter (or constructed implicitly by the image setter). The returned object is either a WholeImageSource or a VipsChunkSource.

Vector-only parts have image_source = None.

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.

add_face()

add_face(id: str, geometry: Optional[geo.Geometry]) -> None

Add a new face. Panics if a face with the given id already exists.

ParameterTypeDescription
idstrFace identifier string. The empty string "" is reserved for the default face.
geometryOptional[geo.Geometry]Optional geometry for this face.
ReturnsNone

face()

face(id: str) -> Optional[FaceState]

Access a face's state by id.

Returns None if the given id does not exist. Use the empty string "" to get the default face (always exists).

ParameterTypeDescription
idstrFace identifier string.
ReturnsOptional[FaceState]A FaceState snapshot, or None.

from_geometry_multi_face()

from_geometry_multi_face(
geometry: geo.Geometry,
size_mm: tuple[float, float] = (0.0, 0.0),
) -> Part

Build a Part from geometry, auto-detecting separate pockets.

Each disconnected outer contour becomes its own face: the largest pocket is the default face "", the others get ids "1", "2", ... (sorted by area descending). Island (inner) contours are assigned to the outer that contains their centroid. Single-pocket geometry produces a single face "" (backward compatible with the Part(...) constructor).

ParameterTypeDescription
geometrygeo.GeometryVector geometry with one outer contour per pocket.
size_mmtuple[float, float] = (0.0, 0.0)Physical size (width, height) in mm (default (0, 0)).
ReturnsPartA new Part with one face per detected pocket.

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
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), ...].