Перейти до основного вмісту

raygeo.geo.algo.cleared_area

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

ClearedArea tracking a simulated raster toolpath — cleared fragments shown in blue, remaining area in red Incremental cleared-area tracker for adaptive clearing.

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

ClearedArea

add_cleared_polygons()

add_cleared_polygons(polygons: Sequence[Sequence[tuple[float, float]]]) -> None
ParameterTypeDescription
polygonsSequence[Sequence[tuple[float, float]]]
ReturnsNone
ComplexityO(n) where n = total vertices across all polygons

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

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

bite_in_direction()

bite_in_direction(
step_over: float,
valid_area: Sequence[Sequence[tuple[float, float]]],
simplify_tol: float,
target: tuple[float, float],
max_angle: float,
) -> list[list[tuple[float, float]]]

Like bites but filters to only the bites whose centroid lies within max_angle radians of the direction from the current cleared region's centre toward target. useful for steering the clearing direction along a MAT branch.

ParameterTypeDescription
step_overfloatlateral step-over in mm
valid_areaSequence[Sequence[tuple[float, float]]]list of polygons defining the valid tool-centre region
simplify_tolfloattolerance in mm for frontier simplification
targettuple[float, float](x, y) target point to steer toward
max_anglefloatmaximum deviation from the target direction (radians)
Returnslist[list[tuple[float, float]]]
ComplexityO(n log n)

Directional bites coloured by pass order (first = dark, later = pale)

Directional bites coloured by pass order (first = dark, later = pale)

bites()

bites(
step_over: float,
valid_area: Sequence[Sequence[tuple[float, 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 valid_area, and subtracting already-cleared portions.

ParameterTypeDescription
step_overfloatlateral step-over in mm
valid_areaSequence[Sequence[tuple[float, float]]]list of polygons defining the valid tool-centre region
simplify_tolfloattolerance in mm for frontier simplification
Returnslist[list[tuple[float, float]]]
ComplexityO(n log n)

bites computes the expansible material — the crescent-shaped regions of uncut material reachable by expanding the frontier by step_over.

bites computes the expansible material — the crescent-shaped regions of uncut material reachable by expanding the frontier by step_over.

expand()

expand(tool_path: Sequence[tuple[float, float]], tool_radius: float) -> None
ParameterTypeDescription
tool_pathSequence[tuple[float, float]]
tool_radiusfloat
ReturnsNone
ComplexityO(n) where n = number of path points

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 incorporate or add_cleared_polygons are called.

This is useful for determining which parts of a bite polygon lie outside the cleared area (i.e. the cutting arc), for example when used with raygeo.ops.assembly.hsm.find_cutting_arc.

ParameterTypeDescription
Returnslist[list[tuple[float, float]]]
ComplexityO(m) where m = number of fragments

frontier()

frontier(simplify_tol: float) -> list[list[tuple[float, float]]]

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

ParameterTypeDescription
simplify_tolfloattolerance in mm for polyline simplification
Returnslist[list[tuple[float, float]]]
ComplexityO(n log n)

frontier returns the outer boundary of the cleared area after merging overlapping fragments — shown in crimson.

frontier returns the outer boundary of the cleared area after merging overlapping fragments — shown in crimson.

incorporate()

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

Add polygons, returning only the newly-added portion. Faster than add_cleared_polygons 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]]]
Returnslist[list[tuple[float, float]]]
ComplexityO(n log n) worst case when union required,

incorporate adds polygons to the cleared state while returning only the newly-covered region (shown in green).

incorporate adds polygons to the cleared state while returning only the newly-covered region (shown in green).

query_window()

query_window(
bbox: tuple[float, float, float, float],
) -> list[list[tuple[float, float]]]
ParameterTypeDescription
bboxtuple[float, float, float, float]
Returnslist[list[tuple[float, float]]]
ComplexityO(m + k) where m = number of fragments, k = output vertices

remaining()

remaining(
bounds: Sequence[Sequence[tuple[float, float]]],
) -> list[list[tuple[float, float]]]
ParameterTypeDescription
boundsSequence[Sequence[tuple[float, float]]]
Returnslist[list[tuple[float, float]]]
ComplexityO(n * m) where n = bounds vertices, m = fragments

remaining_in_inset()

remaining_in_inset(
boundary: Sequence[tuple[float, float]],
obstacles: Optional[Sequence[Sequence[tuple[float, float]]]] = None,
radius: float = 3.0,
) -> list[list[tuple[float, float]]]

Compute the inset region of boundary by radius (excluding obstacles), then return the portions of that region not covered by stored fragments, together with the original obstacle polygons.

ParameterTypeDescription
boundarySequence[tuple[float, float]]Outer boundary polygon.
obstaclesOptional[Sequence[Sequence[tuple[float, float]]]] = NoneObstacle (hole) polygons to exclude.
radiusfloat = 3.0Inset distance applied to boundary and obstacles.
Returnslist[list[tuple[float, float]]]List of polygons — the obstacles plus the uncovered portion of the inset region.
ComplexityO(n log n) for the inset and difference operations.

total_area()

total_area() -> float
ParameterTypeDescription
Returnsfloat
ComplexityO(1)