Skip to main content

raygeo.ops.part.cleared_area

ClearedArea tracking a simulated raster toolpath — cleared fragments in blue, remaining red

ClearedArea tracking a simulated raster toolpath — cleared fragments in blue, remaining red

ClearedArea

actionable_remaining()

actionable_remaining(region: part.StockRegion, inset_distance: float) -> float

Uncleared area inside the actionable zone of the pocket.

The actionable zone is the boundary inset by inset_distance, with islands buffered by the same amount. Material outside this zone -- wall-band slivers thinner than inset_distance -- is excluded, so this metric can gate convergence on whether any actionable material remains.

inset_distance is typically step_length: slivers thinner than the per-step advance get skipped by the stepper, so they should not gate convergence.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
inset_distancefloatInset distance (mm) defining the actionable zone (boundary inset, islands buffered).
ReturnsfloatActionable remaining area in mm2.

begin_batch()

begin_batch() -> None

Begin buffering single-segment expansions.

Subsequent calls to expand_batched are queued without a union. Call commit_batch to union all queued sweeps with the stored fragments in a single pass.

Calling this while a batch is already active is a no-op.

ParameterTypeDescription
ReturnsNone

Three segments via  / , unioned in a single .

Three segments via begin_batch / expand_batched, unioned in a single commit_batch.

bites()

bites(
region: part.StockRegion,
step_over: float,
tool_radius: float,
simplify_tol: float,
) -> list[list[tuple[float, float]]]

Compute the "bites" — new material reachable by expanding the current frontier outward by step_over, clipping to the tool-centre envelope, and subtracting already-cleared portions.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
step_overfloatLateral step-over in mm.
tool_radiusfloatTool radius (mm) for computing the envelope.
simplify_tolfloatTolerance in mm for frontier simplification.
Returnslist[list[tuple[float, float]]]List of polygons representing the bite regions.
ComplexityO(n log n)

 computes the expansible material reachable by expanding the frontier by .

bites computes the expansible material reachable by expanding the frontier by step_over.

commit_batch()

commit_batch() -> None

Union all buffered sweeps with stored fragments in a single pass, then rebuild the spatial grid.

After this call the batch is closed (the caller may start a new one).

ParameterTypeDescription
ReturnsNone

commit_batch_local()

commit_batch_local() -> None

Union only the buffered sweeps with nearby overlapping fragments, using the spatial grid to avoid touching distant fragments.

After this call the batch is closed (the caller may start a new one).

ParameterTypeDescription
ReturnsNone

Global vs local commit — only overlapping frags updated.

Global vs local commit — only overlapping frags updated.

compact_if_needed()

compact_if_needed(region: part.StockRegion, tol: float) -> None

Compact fragments if total vertex count exceeds the default threshold.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
tolfloatVertex simplification tolerance in mm.
ReturnsNone

compact_if_needed_threshold()

compact_if_needed_threshold(
region: part.StockRegion,
tol: float,
threshold: int,
) -> None

Compact with an explicit vertex-count threshold.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
tolfloatVertex simplification tolerance in mm.
thresholdintVertex count threshold above which compaction is triggered.
ReturnsNone

cut()

cut(polygons: Sequence[Sequence[tuple[float, float]]]) -> None

Add pre-computed polygons to the cleared set.

ParameterTypeDescription
polygonsSequence[Sequence[tuple[float, float]]]List of polygons (each a list of (x, y) vertices) to add.
ReturnsNone
ComplexityO(n) where n = total vertices across all polygons

ClearedArea with bulk polygon insertion via  — cleared region in blue, remaining area in red

ClearedArea with bulk polygon insertion via cut — cleared region in blue, remaining area in red

cut_area()

cut_area(
c1: tuple[float, float],
c2: tuple[float, float],
radius: float,
) -> float

Incremental cut area when the tool moves from c1 to c2.

Computes the fresh material area inside the disk at c2 that is not already cleared (crescent area).

ParameterTypeDescription
c1tuple[float, float]Previous centre (x, y).
c2tuple[float, float]Next centre (x, y).
radiusfloatDisk radius (mm).
ReturnsfloatFresh cut area (mm2).

cut_fast()

cut_fast(
polygons: Sequence[Sequence[tuple[float, float]]],
) -> list[list[tuple[float, float]]]

Add polygons, returning only the newly-added portion. Faster than cut when inputs don't overlap existing fragments (skips the full union).

O(n) when inputs are disjoint from existing fragments
ParameterTypeDescription
polygonsSequence[Sequence[tuple[float, float]]]List of polygons to add.
Returnslist[list[tuple[float, float]]]List of polygons representing the newly-added portion.
ComplexityO(n log n) worst case when union required,

 adds polygons to the cleared area, returning only the newly-covered region (green).

cut_fast adds polygons to the cleared area, returning only the newly-covered region (green).

envelope()

envelope(
region: part.StockRegion,
tool_radius: float,
) -> list[list[tuple[float, float]]]

The tool-centre envelope (inset of boundary by tool_radius, minus islands).

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
tool_radiusfloatTool radius (mm).
Returnslist[list[tuple[float, float]]]List of polygons representing the tool-centre envelope.

expand()

expand(path: Sequence[tuple[float, float]], radius: float) -> None

Sweep a disk along a polyline, adding the swept area to the cleared set.

ParameterTypeDescription
pathSequence[tuple[float, float]]List of (x, y) points forming the polyline.
radiusfloatDisk radius (mm).
ReturnsNone
ComplexityO(n) where n = number of path points

: sweeping a disk along a multi-segment path enlarges the cleared area.

expand: sweeping a disk along a multi-segment path enlarges the cleared area.

expand_batched()

expand_batched(
prev: tuple[float, float],
next: tuple[float, float],
radius: float,
) -> None

Queue a single-segment expansion into the current batch.

The segment swept polygon is stored in the internal buffer. Does not perform a union until commit_batch is called.

.. warning::

Panics if `begin_batch` was not called first.
ParameterTypeDescription
prevtuple[float, float]Start point (x, y) of the segment.
nexttuple[float, float]End point (x, y) of the segment.
radiusfloatDisk radius (mm).
ReturnsNone

expand_step()

expand_step(
prev: tuple[float, float],
next: tuple[float, float],
radius: float,
) -> None

Expand the cleared area by sweeping a disk of radius along a single segment from prev to next.

ParameterTypeDescription
prevtuple[float, float]Start point (x, y) of the segment.
nexttuple[float, float]End point (x, y) of the segment.
radiusfloatDisk radius (mm).
ReturnsNone

 sweeps a disk from prev to next, enlarging the cleared area vs initial state.

expand_step sweeps a disk from prev to next, enlarging the cleared area vs initial state.

fragments()

fragments() -> list[list[tuple[float, float]]]

Return the union of all polygons currently tracked as cleared.

Each fragment is a closed polygon (list of (x, y) vertices) representing an area that has already been cut. The fragment set grows as cut_fast or cut are called.

This is useful for inspecting which areas have been cleared.

ParameterTypeDescription
Returnslist[list[tuple[float, float]]]List of polygons representing the cleared fragments.
ComplexityO(m) where m = number of fragments

frontier()

frontier(
region: part.StockRegion,
simplify_tol: float,
) -> list[list[tuple[float, float]]]

Return a unioned, simplified snapshot of the current outer boundary, clipped to the stock.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
simplify_tolfloatTolerance in mm for polyline simplification.
Returnslist[list[tuple[float, float]]]List of polygons representing the outer boundary.
ComplexityO(n log n)

 returns the outer boundary of the cleared area after merging overlapping fragments.

frontier returns the outer boundary of the cleared area after merging overlapping fragments.

get_angular_engagement()

get_angular_engagement(center: tuple[float, float], radius: float) -> float

Compute angular engagement by exact circle-polygon intersection.

Creates a disk polygon at center with radius, intersects it with all nearby cleared fragments, and returns the uncleared angular extent in [0, 2*pi].

ParameterTypeDescription
centertuple[float, float]Query point (x, y).
radiusfloatDisk radius (mm).
ReturnsfloatUncleared angular extent (radians).

get_point_engagement()

get_point_engagement(
center: tuple[float, float],
radius: float,
) -> tuple[float, float, float]

Evaluate engagement at a point using the signed distance to this cleared area's boundary.

ParameterTypeDescription
centertuple[float, float]Query point (x, y).
radiusfloatDisk radius (mm).
Returnstuple[float, float, float](angle_rad, area, chord_depth).

is_empty()

is_empty() -> bool

True when no fragments have been recorded.

ParameterTypeDescription
ReturnsboolTrue if no fragments have been recorded.

path_engagement()

path_engagement(
path: Sequence[tuple[float, float]],
radius: float,
) -> list[tuple[float, float, float]]

Evaluate engagement along a polyline.

ParameterTypeDescription
pathSequence[tuple[float, float]]List of (x, y) points.
radiusfloatDisk radius (mm).
Returnslist[tuple[float, float, float]]List of (angle, area, chord_depth) tuples.

query_window()

query_window(
bbox: tuple[float, float, float, float],
) -> list[list[tuple[float, float]]]

Return fragments whose bounding box overlaps the query window.

k = output vertices
ParameterTypeDescription
bboxtuple[float, float, float, float]Bounding box (x_min, y_min, x_max, y_max).
Returnslist[list[tuple[float, float]]]Fragments intersecting the bounding box.
ComplexityO(m + k) where m = number of fragments,

 returns only the cleared fragments whose bbox overlaps the query (green).

query_window returns only the cleared fragments whose bbox overlaps the query (green).

remaining()

remaining(region: part.StockRegion) -> list[list[tuple[float, float]]]

Subtract cleared fragments from the stock, returning the uncut portion.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
Returnslist[list[tuple[float, float]]]List of polygons representing the uncut portion.
ComplexityO(n * m) where n = stock vertices, m = fragments

 subtracts cleared fragments from the boundary, returning the uncut region (red).

remaining subtracts cleared fragments from the boundary, returning the uncut region (red).

remaining_area()

remaining_area(region: part.StockRegion) -> float

Remaining uncut area (boundary minus islands minus cleared fragments). Only positive-area (CCW) polygons are counted, so island holes do not inflate the result.

ParameterTypeDescription
regionpart.StockRegionStockRegion defining the boundary and islands.
ReturnsfloatRemaining uncut area in mm2.

signed_boundary_distance()

signed_boundary_distance(x: float, y: float) -> float

Signed perpendicular distance to the nearest cleared boundary.

Returns positive when the point is outside the cleared area (in uncut material), negative when inside.

ParameterTypeDescription
xfloatX coordinate of the query point.
yfloatY coordinate of the query point.
ReturnsfloatSigned distance in mm. 0.0 means exactly on the boundary.

Signed boundary distance around a cleared square: green = inside cleared, red = outside.

Signed boundary distance around a cleared square: green = inside cleared, red = outside.

total_area()

total_area() -> float

Total cleared area.

ParameterTypeDescription
ReturnsfloatTotal cleared area in mm2.
ComplexityO(1)