Drawing Helpers
lc_plugin::drawing provides reader post-processing helpers for operations that need access to the drawing after parsing. LinkCAD passes Drawing to Reader::post_process().
Python exposes equivalent drawing helper methods on linkcad.v1.db.Drawing.
Key Public Items
| Item | Purpose |
|---|---|
Drawing | Host-owned drawing handle for reader post-processing. |
BooleanOperation | Layer-level boolean operation. |
MergeLayerPolarityResult | Result of deferred-polarity materialization. |
Enums
pub enum BooleanOperation { Or, AMinusB,}
pub enum MergeLayerPolarityResult { Success, Cancelled, Failure,}BooleanOperation::Or unions the operand layer into the result layer. BooleanOperation::AMinusB subtracts the operand layer from the result layer.
Host Construction
pub unsafe fn from_raw(ptr: *mut LcDrawing) -> Self;This method is public for ABI glue. Format plugins should use the Drawing passed to Reader::post_process().
Post-Processing Methods
| Method | Description |
|---|---|
boolean_layers_by_name(op, result_layer, operand_layer, resolution) -> bool | Run a layer boolean operation. result_layer is operand A and receives the output. |
merge_layer_polarity_group(group_name, resolution, progress, progress_from, progress_to) -> MergeLayerPolarityResult | Materialize one deferred-polarity group. |
merge_all_polarity_groups(resolution, progress, progress_from, progress_to) -> MergeLayerPolarityResult | Materialize all deferred-polarity groups in one batch. |
destroy_layer_by_name(layer: &str) -> bool | Destroy a layer if it exists. |
rename_layer(from: &str, to: &str) -> bool | Rename a layer. |
String inputs that contain an interior NUL byte return false or MergeLayerPolarityResult::Failure instead of panicking.
Reader Post-Process Example
impl Reader for ExampleReader { fn parse_file( &mut self, _path: &str, builder: &mut DrawingBuilder, _file_size: i64, _current_file: i32, _file_count: i32, ) -> bool { builder.open_cell_by_name("TOP", true, false); builder.select_layer_by_name("metal"); builder.create_rectangle(Point::new(0, 0), Point::new(10_000, 10_000)); builder.close_cell(); true }
fn post_process( &mut self, phase: Phase, drawing: &mut Drawing, progress: Option<&mut DrawingBuilder>, log: &mut EventLog, resolution: &Resolution, ) -> bool { if phase != Phase::ParsedAll { return true; }
match drawing.merge_all_polarity_groups(resolution, progress, 0, 100) { MergeLayerPolarityResult::Success => true, MergeLayerPolarityResult::Cancelled => false, MergeLayerPolarityResult::Failure => { log.error("Could not merge layer polarity groups"); false } } }}Progress Range
progress_from and progress_to map the operation’s internal progress to a percentage interval in the host progress bar. Pass the progress builder from Reader::post_process() when available so cancellation is detected and progress updates are visible.