Skip to content

RasterMode enum, section markers, state blocks, assembler markers#9

Merged
knipknap merged 4 commits into
mainfrom
raster-mode-section-markers
Jul 15, 2026
Merged

RasterMode enum, section markers, state blocks, assembler markers#9
knipknap merged 4 commits into
mainfrom
raster-mode-section-markers

Conversation

@knipknap

@knipknap knipknap commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Nesting relationship

OpsSectionStart(VectorOutline, raster_mode=None)
  StateBlockStart(name="labels")
    SetPower(0.3), SetFeedRate(1000)
    ...label text geometry...
  StateBlockEnd

  StateBlockStart(name="cell-r0-c0")
    SetPower(0.1), SetFeedRate(100)
    ...square geometry...
  StateBlockEnd

  StateBlockStart(name="cell-r0-c1")
    SetPower(0.5), SetFeedRate(200)
    ...same square geometry, different params...
  StateBlockEnd
  ...
OpsSectionEnd

OpsSectionStart(RasterFill, raster_mode=ConstantPower)
  StateBlockStart(name="cell-r0-c0")
    SetPower(0.5), SetFeedRate(100)
    ...raster scan geometry...
  StateBlockEnd
  ...
OpsSectionEnd

OpsSection is the outer boundary produced by a single producer (raster assembler, material test grid, vector cut). StateBlock nests inside OpsSection and delimits sub-regions where device parameters change.


Consuming the new APIs

Iterating sections by type and mode

sections = ops.sections()

raster_sections = ops.sections_by_type(SectionType.RASTER_FILL)
variable_power = ops.sections_by_mode(RasterMode.VARIABLE_POWER)

for sec in sections:
    print(sec.section_type, sec.raster_mode)

Extracting section content

section = ops.sections()[0]
content = ops.section_content(section)
content = section.content(ops)  # convenience

Reading section params

st, uid, mode = ops.section_params(idx)
# mode is None for VectorOutline, RasterMode variant for RasterFill

State blocks within a section

section = ops.sections()[0]

blocks = section.state_blocks(ops)
for b in blocks:
    print(b.name)
    print(b.marker_indices)
    print(b.content_indices)
    block_ops = b.content(ops)

labels = section.state_blocks_by_name(ops, "labels")     # exact match
cells = section.state_blocks_by_name(ops, "cell-*")      # prefix match

Flat iteration

all_blocks = ops.state_blocks()  # across all sections

Assembler output with markers

The raster and material-test-grid assemblers now emit section and state block markers:

result = raster(part, mode="power_modulated")
sections = result.ops.sections()
# Each section has raster_mode set appropriately

result = generate_material_test_grid(params, size_mm)
sections = result.ops.sections()
labels = sections[0].state_blocks_by_name(ops, "labels")
cells = sections[0].state_blocks_by_name(ops, "cell-*")

knipknap added 4 commits July 13, 2026 17:30
- Add RasterMode enum (VariablePower, ConstantPower, DepthMap)
- Add raster_mode field to OpsSectionStart/End markers
- Add constructor validation for SectionType/RasterMode combinations
- Add section query API (section_ops, sections_by_type, sections_by_mode)
- section_params returns 3-tuple with raster_mode
- Add StateBlockStart/End markers with name support
- Add StateBlock struct and section-scoped query API
- Rust raster assembler wraps passes in section markers
- Rust material_test_grid assembler wraps output in section+state blocks
- Dict serialization/deserialization for all new types
Breaking change: ops_section_start and ops_section_end now require
raster_mode for RasterFill sections and return Result. The old
infallible shims and _with_mode variants are removed.

- ops_section_start/end unified into single validated Result-returning API
- All callers updated to pass raster_mode= for RasterFill sections
- Dict deserialization uses the unified path
- Python bindings accept keyword-only raster_mode (default None)
# Conflicts:
#	src/ops/assembly/material_test_grid/mod.rs
@knipknap
knipknap merged commit 9356ee3 into main Jul 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant