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

raygeo.ops.assembly.raster

Functions

raster()

raster(
part: ops.part.Part,
image: numpy.ndarray,
alpha: numpy.ndarray | None = None,
mode: str = 'power_modulated',
line_interval_mm: float = 0.1,
sample_interval_mm: float = 0.05,
min_power: float = 0,
max_power: float = 1,
step_power: float = 0.1,
num_power_levels: int = 10,
angle: float = 0,
offset_x_mm: float = 0,
offset_y_mm: float = 0,
scan_mode: str = 'segmented',
cross_hatch: bool = False,
num_depth_levels: int = 5,
z_step_down: float = 0,
angle_increment: float = 0,
) -> ops.assembly.result.AssemblyResult

Rasterise a part image into scan paths.

Converts the grayscale or binary image into a sequence of scan-line toolpath commands suitable for laser engraving or similar raster operations.

Three modes are supported:

  • "power_modulated" (default) — uses grayscale + alpha channels to produce power-modulated scan lines.
  • "mask_scan" — treats image as a binary mask and produces scan-line segments with constant power. Also used for "dither" — the caller pre-ditheres the image and passes it as a binary mask.
  • "multi_pass" — decomposes the grayscale image into num_depth_levels layers, rasterising each at a progressive Z offset.

When cross_hatch is True the scan is run twice — once at angle and once at angle + 90° — and the results are concatenated.

Raises: ValueError — If the mode is unknown or required data is

missing.
ParameterTypeDescription
partops.part.PartPart providing pixel density and size metadata.
imagenumpy.ndarray2-D grayscale (uint8) or binary numpy array.
alphanumpy.ndarray | None = NoneOptional 2-D alpha mask (uint8). Required for power_modulated mode when the image is not pre-masked.
modestr = 'power_modulated'"power_modulated", "mask_scan", or "multi_pass".
line_interval_mmfloat = 0.1Spacing between scan lines in mm.
sample_interval_mmfloat = 0.05Power sampling interval along a scan line in mm (power_modulated only).
min_powerfloat = 0Minimum laser power (0–1).
max_powerfloat = 1Maximum laser power (0–1).
step_powerfloat = 0.1Power step per level.
num_power_levelsint = 10Number of discrete power levels.
anglefloat = 0Scan angle in degrees.
offset_x_mmfloat = 0Global X offset in mm.
offset_y_mmfloat = 0Global Y offset in mm.
scan_modestr = 'segmented'"segmented" or "full_sweep".
cross_hatchbool = FalseIf True, add a second pass at angle + 90° (default False).
num_depth_levelsint = 5Number of depth layers (multi_pass only, default 5).
z_step_downfloat = 0Z decrement per depth layer in mm (multi_pass only, default 0.0).
angle_incrementfloat = 0Angle added per depth layer in degrees (multi_pass only, default 0.0).
Returnsops.assembly.result.AssemblyResultAn AssemblyResult with the raster path.