Make Pheon structural review results self-contained
Capture revision metadata, cell presence and attributes, and structured
diagnostics in owned comparison results. Derive outcomes and render text,
JSON, and hierarchy reports without retaining source documents. Keep derived
descriptions and graph analysis in their renderers.
Use pheon-structural-v1 and PHEON_LAYER_NAMES_V1 consistently, expose helpers
through their defining modules, and remove obsolete re-exports. Update user
guides and report fixtures without changing schema version 1.
Cover dropped inputs, diagnostic ordering, absent and empty cells, offset
independence, and CLI failures. All 92 Rust tests pass in debug and release;
report and hierarchy goldens retain their behavior.
2026-11-16 20:45:06 -08:00
|
|
|
//! Unique replacement matches that explain removed and added objects.
|
|
|
|
|
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct Replacement {
|
|
|
|
|
pub removed: usize,
|
|
|
|
|
pub added: usize,
|
|
|
|
|
/// Explanation matching is never object identity or geometric equivalence.
|
|
|
|
|
pub match_rule: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Group = (u16, Option<Layer>, Option<String>, Option<Bounds>);
|
|
|
|
|
|
|
|
|
|
fn group(object: &ObjectChange, bounds: bool) -> Group {
|
|
|
|
|
(
|
|
|
|
|
object.kind,
|
|
|
|
|
object.layer,
|
|
|
|
|
object.target.clone(),
|
|
|
|
|
if bounds && object.target.is_none() {
|
|
|
|
|
object.bounds
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Pair only unique candidates in the remaining multisets. Ambiguous groups
|
|
|
|
|
/// remain additions/removals; no identity or geometric equivalence is inferred.
|
|
|
|
|
pub(super) fn replacements(old: &[ObjectChange], new: &[ObjectChange]) -> Vec<Replacement> {
|
2026-11-18 10:58:19 -08:00
|
|
|
if old.is_empty() || new.is_empty() {
|
|
|
|
|
return Vec::new();
|
|
|
|
|
}
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
let (mut used_old, mut used_new) = (BTreeSet::new(), BTreeSet::new());
|
|
|
|
|
let mut result = Vec::new();
|
|
|
|
|
for bounds in [true, false] {
|
|
|
|
|
let (mut a, mut b) = (
|
|
|
|
|
BTreeMap::<Group, Vec<usize>>::new(),
|
|
|
|
|
BTreeMap::<Group, Vec<usize>>::new(),
|
|
|
|
|
);
|
|
|
|
|
for (i, object) in old
|
|
|
|
|
.iter()
|
|
|
|
|
.enumerate()
|
|
|
|
|
.filter(|(i, _)| !used_old.contains(i))
|
|
|
|
|
{
|
|
|
|
|
a.entry(group(object, bounds)).or_default().push(i);
|
|
|
|
|
}
|
|
|
|
|
for (i, object) in new
|
|
|
|
|
.iter()
|
|
|
|
|
.enumerate()
|
|
|
|
|
.filter(|(i, _)| !used_new.contains(i))
|
|
|
|
|
{
|
|
|
|
|
b.entry(group(object, bounds)).or_default().push(i);
|
|
|
|
|
}
|
|
|
|
|
for (key, indices) in a {
|
|
|
|
|
if let (1, Some(others)) = (indices.len(), b.get(&key))
|
|
|
|
|
&& others.len() == 1
|
|
|
|
|
{
|
|
|
|
|
let (i, j) = (indices[0], others[0]);
|
|
|
|
|
result.push(Replacement {
|
|
|
|
|
removed: i,
|
|
|
|
|
added: j,
|
|
|
|
|
match_rule: if old[i].target.is_some() {
|
|
|
|
|
"unique_kind_target"
|
|
|
|
|
} else if bounds {
|
|
|
|
|
"unique_kind_layer_bounds"
|
|
|
|
|
} else {
|
|
|
|
|
"unique_kind_layer"
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
used_old.insert(i);
|
|
|
|
|
used_new.insert(j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result.sort_by_key(|r| (r.removed, r.added));
|
|
|
|
|
result
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-17 21:49:26 -08:00
|
|
|
pub(super) fn field_changes<'a>(
|
|
|
|
|
old: &'a ObjectChange,
|
|
|
|
|
new: &'a ObjectChange,
|
|
|
|
|
) -> impl Iterator<Item = (u16, Option<&'a [u8]>, Option<&'a [u8]>)> {
|
|
|
|
|
let mut fields = BTreeMap::<u16, (Option<&[u8]>, Option<&[u8]>)>::new();
|
|
|
|
|
for field in &old.fields {
|
|
|
|
|
fields.entry(field.tag).or_default().0 = Some(&field.data);
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
}
|
2026-11-17 21:49:26 -08:00
|
|
|
for field in &new.fields {
|
|
|
|
|
fields.entry(field.tag).or_default().1 = Some(&field.data);
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
}
|
2026-11-17 21:49:26 -08:00
|
|
|
fields
|
|
|
|
|
.into_iter()
|
|
|
|
|
.filter_map(|(tag, (before, after))| (before != after).then_some((tag, before, after)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn polygon_heading(object: &ObjectChange, rectangular: bool) -> String {
|
|
|
|
|
object_heading(object, object_name(object.kind, rectangular))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn object_heading(object: &ObjectChange, kind: &str) -> String {
|
|
|
|
|
match object.layer {
|
|
|
|
|
Some((layer, datatype)) => format!("{layer}/{datatype}: {kind}"),
|
|
|
|
|
None => kind.to_string(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-18 10:58:19 -08:00
|
|
|
fn object_xy(object: &ObjectChange) -> &[u8] {
|
2026-11-17 21:49:26 -08:00
|
|
|
object
|
|
|
|
|
.fields
|
|
|
|
|
.iter()
|
|
|
|
|
.find(|field| field.tag == RTAG_XY)
|
|
|
|
|
.map_or(&[], |field| field.data.as_slice())
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-18 20:12:42 -08:00
|
|
|
pub(super) fn write_unmatched(out: &mut String, object: &ObjectChange) {
|
2026-11-18 10:58:19 -08:00
|
|
|
if object.kind == RTAG_PATH
|
|
|
|
|
&& let Some([xmin, ymin, xmax, ymax]) = object.bounds
|
|
|
|
|
{
|
|
|
|
|
let vertices = XY::points(object_xy(object)).len();
|
|
|
|
|
if vertices > POINTS_PER_LINE {
|
|
|
|
|
let heading = object_heading(object, "path");
|
|
|
|
|
let width = object
|
|
|
|
|
.width
|
|
|
|
|
.map_or_else(|| "absent".to_string(), |width| format!("{width} dbu"));
|
|
|
|
|
writeln!(
|
|
|
|
|
out,
|
2026-11-18 20:12:42 -08:00
|
|
|
"{heading} · width {width} · {vertices} vertices · bounds ({xmin}, {ymin}) to ({xmax}, {ymax}) dbu"
|
2026-11-18 10:58:19 -08:00
|
|
|
)
|
|
|
|
|
.unwrap();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-11-18 20:12:42 -08:00
|
|
|
writeln!(out, "{object}").unwrap();
|
2026-11-18 10:58:19 -08:00
|
|
|
}
|
|
|
|
|
|
2026-11-17 21:49:26 -08:00
|
|
|
fn vertex_count(xy: &[u8]) -> usize {
|
|
|
|
|
XY::points(xy).len().saturating_sub(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn rectangle_size(xy: &[u8]) -> Option<[i64; 2]> {
|
|
|
|
|
let [xmin, ymin, xmax, ymax] = XY::closed_rectangle(xy)?;
|
|
|
|
|
Some([
|
|
|
|
|
i64::from(xmax) - i64::from(xmin),
|
|
|
|
|
i64::from(ymax) - i64::from(ymin),
|
|
|
|
|
])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn translation(before: &[u8], after: &[u8]) -> Option<[i64; 2]> {
|
|
|
|
|
let mut old = XY::points(before);
|
|
|
|
|
let mut new = XY::points(after);
|
|
|
|
|
if old.len() != new.len() {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
let (Some(a), Some(b)) = (old.next(), new.next()) else {
|
|
|
|
|
return None;
|
|
|
|
|
};
|
|
|
|
|
let displacement = |[x0, y0]: [i32; 2], [x1, y1]: [i32; 2]| {
|
|
|
|
|
[i64::from(x1) - i64::from(x0), i64::from(y1) - i64::from(y0)]
|
|
|
|
|
};
|
|
|
|
|
let shift = displacement(a, b);
|
|
|
|
|
(shift != [0, 0] && old.zip(new).all(|(a, b)| displacement(a, b) == shift)).then_some(shift)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
struct ShapeCounts {
|
|
|
|
|
rectangles: usize,
|
|
|
|
|
polygons: usize,
|
|
|
|
|
boxes: usize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ShapeCounts {
|
2026-11-18 23:01:57 -08:00
|
|
|
fn total(&self) -> usize {
|
|
|
|
|
self.rectangles + self.polygons + self.boxes
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-17 21:49:26 -08:00
|
|
|
fn add(&mut self, object: &ObjectChange, replacement: Option<&ObjectChange>) {
|
|
|
|
|
let is_rectangle =
|
2026-11-18 10:58:19 -08:00
|
|
|
|object: &ObjectChange| XY::closed_rectangle(object_xy(object)).is_some();
|
2026-11-17 21:49:26 -08:00
|
|
|
match object.kind {
|
|
|
|
|
RTAG_BOX => self.boxes += 1,
|
|
|
|
|
_ if is_rectangle(object) && replacement.is_none_or(is_rectangle) => {
|
|
|
|
|
self.rectangles += 1
|
|
|
|
|
}
|
|
|
|
|
_ => self.polygons += 1,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
struct LayerPolygonChanges {
|
|
|
|
|
changed: ShapeCounts,
|
|
|
|
|
moved: ShapeCounts,
|
|
|
|
|
removed: ShapeCounts,
|
|
|
|
|
added: ShapeCounts,
|
2026-11-18 23:01:57 -08:00
|
|
|
displacement: Option<[i64; 2]>,
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub(super) struct PolygonChanges(BTreeMap<Option<Layer>, LayerPolygonChanges>);
|
|
|
|
|
|
|
|
|
|
impl PolygonChanges {
|
|
|
|
|
pub fn replacement(&mut self, old: &ObjectChange, new: &ObjectChange) {
|
|
|
|
|
let counts = self.0.entry(old.layer).or_default();
|
2026-11-18 23:01:57 -08:00
|
|
|
let displacement = if old.properties == new.properties {
|
|
|
|
|
translation(object_xy(old), object_xy(new))
|
|
|
|
|
.filter(|_| field_changes(old, new).all(|(tag, _, _)| tag == RTAG_XY))
|
2026-11-17 21:49:26 -08:00
|
|
|
} else {
|
2026-11-18 23:01:57 -08:00
|
|
|
None
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
};
|
2026-11-18 23:01:57 -08:00
|
|
|
if let Some(shift) = displacement {
|
|
|
|
|
counts.displacement = Some(shift);
|
|
|
|
|
counts.moved.add(old, Some(new));
|
|
|
|
|
} else {
|
|
|
|
|
counts.changed.add(old, Some(new));
|
|
|
|
|
}
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn unmatched(&mut self, object: &ObjectChange, removed: bool) {
|
|
|
|
|
let counts = self.0.entry(object.layer).or_default();
|
|
|
|
|
let shapes = if removed {
|
|
|
|
|
&mut counts.removed
|
|
|
|
|
} else {
|
|
|
|
|
&mut counts.added
|
|
|
|
|
};
|
|
|
|
|
shapes.add(object, None);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-18 20:12:42 -08:00
|
|
|
pub fn write(&self, out: &mut String, layers: &mut LayerRows<'_>) {
|
2026-11-17 21:49:26 -08:00
|
|
|
for (layer, counts) in &self.0 {
|
2026-11-18 20:12:42 -08:00
|
|
|
out.push_str(" ");
|
|
|
|
|
layers.record(*layer, out.len());
|
2026-11-17 21:49:26 -08:00
|
|
|
if let Some((layer, datatype)) = layer {
|
2026-11-18 20:12:42 -08:00
|
|
|
write!(out, "{layer}/{datatype}: ").unwrap();
|
2026-11-17 21:49:26 -08:00
|
|
|
} else {
|
2026-11-18 20:12:42 -08:00
|
|
|
out.push_str("unknown layer: ");
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
2026-11-18 23:01:57 -08:00
|
|
|
let groups = [
|
2026-11-17 21:49:26 -08:00
|
|
|
("changed", &counts.changed),
|
|
|
|
|
("moved", &counts.moved),
|
|
|
|
|
("removed", &counts.removed),
|
|
|
|
|
("added", &counts.added),
|
2026-11-18 23:01:57 -08:00
|
|
|
];
|
|
|
|
|
if let Some([dx, dy]) = counts.displacement
|
|
|
|
|
&& groups
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|(_, shapes)| shapes.total())
|
|
|
|
|
.sum::<usize>()
|
|
|
|
|
== 1
|
|
|
|
|
{
|
|
|
|
|
let shape = if counts.moved.rectangles == 1 {
|
|
|
|
|
"rectangle"
|
|
|
|
|
} else if counts.moved.boxes == 1 {
|
|
|
|
|
"box"
|
|
|
|
|
} else {
|
|
|
|
|
"polygon"
|
|
|
|
|
};
|
|
|
|
|
writeln!(out, "{shape} moved by ({dx}, {dy}) dbu").unwrap();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
let mut separator = "";
|
|
|
|
|
for (action, shapes) in groups {
|
2026-11-17 21:49:26 -08:00
|
|
|
let terms = [
|
|
|
|
|
(shapes.rectangles, "rectangle", "rectangles"),
|
|
|
|
|
(shapes.polygons, "polygon", "polygons"),
|
|
|
|
|
(shapes.boxes, "box", "boxes"),
|
|
|
|
|
]
|
|
|
|
|
.into_iter()
|
|
|
|
|
.filter(|(count, _, _)| *count != 0)
|
|
|
|
|
.map(|(count, singular, plural)| {
|
|
|
|
|
let shape = if count == 1 { singular } else { plural };
|
|
|
|
|
format!("{count} {shape}")
|
|
|
|
|
})
|
|
|
|
|
.collect::<Vec<_>>();
|
|
|
|
|
if !terms.is_empty() {
|
|
|
|
|
write!(out, "{separator}{} {action}", terms.join(", ")).unwrap();
|
|
|
|
|
separator = " · ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out.push('\n');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub(super) struct ReferenceCounts {
|
|
|
|
|
singles: usize,
|
|
|
|
|
arrays: usize,
|
|
|
|
|
placements: u128,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ReferenceCounts {
|
|
|
|
|
pub fn add(&mut self, object: &ObjectChange) {
|
|
|
|
|
if object.kind == RTAG_AREF {
|
|
|
|
|
self.arrays += 1;
|
|
|
|
|
} else {
|
|
|
|
|
self.singles += 1;
|
|
|
|
|
}
|
2026-11-18 20:12:42 -08:00
|
|
|
self.placements += reference_placements(object);
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
|
|
|
|
|
2026-11-18 20:12:42 -08:00
|
|
|
pub fn write(&self, out: &mut String, sign: &str, target: &str, first: &ObjectChange) {
|
|
|
|
|
if self.len() == 1 {
|
|
|
|
|
writeln!(out, " {sign} {first}").unwrap();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-11-17 21:49:26 -08:00
|
|
|
write!(out, " {sign} ").unwrap();
|
2026-11-18 20:12:42 -08:00
|
|
|
self.write_counts(out, "");
|
|
|
|
|
write!(out, " to {}", cell_label(target)).unwrap();
|
|
|
|
|
self.write_placements(out);
|
|
|
|
|
out.push('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn len(&self) -> usize {
|
|
|
|
|
self.singles + self.arrays
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn write_change(&self, out: &mut String, target: &str, added: &Self) {
|
|
|
|
|
write!(out, " {} · ", cell_label(target)).unwrap();
|
|
|
|
|
self.write_counts(out, "-");
|
|
|
|
|
self.write_placements(out);
|
|
|
|
|
out.push_str(", ");
|
|
|
|
|
added.write_counts(out, "+");
|
|
|
|
|
added.write_placements(out);
|
|
|
|
|
out.push('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn write_counts(&self, out: &mut String, sign: &str) {
|
2026-11-17 21:49:26 -08:00
|
|
|
if self.singles > 0 {
|
|
|
|
|
let suffix = if self.singles == 1 { "" } else { "s" };
|
2026-11-18 20:12:42 -08:00
|
|
|
write!(out, "{sign}{} ref{suffix}", self.singles).unwrap();
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
|
|
|
|
if self.arrays > 0 {
|
|
|
|
|
if self.singles > 0 {
|
|
|
|
|
out.push_str(", ");
|
|
|
|
|
}
|
|
|
|
|
let suffix = if self.arrays == 1 { "" } else { "s" };
|
2026-11-18 20:12:42 -08:00
|
|
|
write!(out, "{sign}{} array ref{suffix}", self.arrays).unwrap();
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
2026-11-18 20:12:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn write_placements(&self, out: &mut String) {
|
2026-11-17 21:49:26 -08:00
|
|
|
if self.arrays > 0 {
|
|
|
|
|
let suffix = if self.placements == 1 { "" } else { "s" };
|
|
|
|
|
write!(out, " ({} placement{suffix})", self.placements).unwrap();
|
|
|
|
|
}
|
2026-11-18 20:12:42 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn reference_placements(object: &ObjectChange) -> u128 {
|
|
|
|
|
match object.counts {
|
|
|
|
|
Some([columns, rows]) => u128::from(columns) * u128::from(rows),
|
|
|
|
|
None => 0,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub(super) struct ShownReferences {
|
|
|
|
|
shown: usize,
|
|
|
|
|
total: usize,
|
|
|
|
|
removed: u128,
|
|
|
|
|
added: u128,
|
|
|
|
|
row_start: usize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ShownReferences {
|
|
|
|
|
pub fn replacement(&mut self, old: &ObjectChange, new: &ObjectChange, row_start: usize) {
|
|
|
|
|
self.shown += 2;
|
|
|
|
|
self.removed += reference_placements(old);
|
|
|
|
|
self.added += reference_placements(new);
|
|
|
|
|
self.row_start = row_start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn unmatched(
|
|
|
|
|
&mut self,
|
|
|
|
|
removed: &ReferenceCounts,
|
|
|
|
|
added: &ReferenceCounts,
|
|
|
|
|
row_start: usize,
|
|
|
|
|
) {
|
|
|
|
|
self.shown += removed.len() + added.len();
|
|
|
|
|
self.removed += removed.placements;
|
|
|
|
|
self.added += added.placements;
|
|
|
|
|
self.row_start = row_start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn count_change(&mut self) {
|
|
|
|
|
self.total += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn complete(&self) -> bool {
|
|
|
|
|
self.shown == self.total
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn annotate(&self, text: &str, annotations: &mut Vec<(usize, String)>, old: u64, new: u64) {
|
|
|
|
|
if (u128::from(old), u128::from(new)) == (self.removed, self.added) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let at = self.row_start + text[self.row_start..].find('\n').unwrap();
|
|
|
|
|
let totals = if old == new {
|
|
|
|
|
let suffix = if new == 1 { "" } else { "s" };
|
|
|
|
|
format!(" · {new} total placement{suffix}")
|
|
|
|
|
} else {
|
|
|
|
|
format!(" · placements {old} -> {new}")
|
|
|
|
|
};
|
|
|
|
|
annotations.push((at, totals));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) struct LayerRows<'a> {
|
|
|
|
|
names: &'a BTreeMap<Layer, String>,
|
|
|
|
|
rows: BTreeMap<Layer, Option<usize>>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a> LayerRows<'a> {
|
|
|
|
|
pub fn new(names: &'a BTreeMap<Layer, String>) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
names,
|
|
|
|
|
rows: BTreeMap::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn record(&mut self, layer: Option<Layer>, row_start: usize) {
|
|
|
|
|
if let Some(layer) = layer
|
|
|
|
|
&& self.names.contains_key(&layer)
|
|
|
|
|
{
|
|
|
|
|
self.rows
|
|
|
|
|
.entry(layer)
|
|
|
|
|
.and_modify(|first| *first = None)
|
|
|
|
|
.or_insert(Some(row_start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn finish(self, text: &str, annotations: &mut Vec<(usize, String)>, legend: &mut String) {
|
|
|
|
|
for (layer, first) in self.rows {
|
|
|
|
|
let name = &self.names[&layer];
|
|
|
|
|
if let Some(at) = first {
|
|
|
|
|
// Each recorded heading starts with the numeric layer/type and a colon.
|
|
|
|
|
let at = at + text[at..].find(':').unwrap();
|
|
|
|
|
annotations.push((at, format!(" ({})", cell_label(name))));
|
|
|
|
|
} else {
|
|
|
|
|
writeln!(legend, "{}/{}: name {name:?}", layer.0, layer.1).unwrap();
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-11-17 21:49:26 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn polygon_replacement(old: &ObjectChange, new: &ObjectChange) -> String {
|
2026-11-18 10:58:19 -08:00
|
|
|
let before = object_xy(old);
|
|
|
|
|
let after = object_xy(new);
|
2026-11-17 21:49:26 -08:00
|
|
|
let old_size = rectangle_size(before);
|
|
|
|
|
let new_size = rectangle_size(after);
|
|
|
|
|
let mut out = polygon_heading(old, old_size.is_some() && new_size.is_some());
|
|
|
|
|
if before == after {
|
|
|
|
|
out.push_str(" modified");
|
|
|
|
|
} else {
|
|
|
|
|
match (old_size, new_size) {
|
|
|
|
|
(Some(a), Some(b)) if a == b => out.push_str(" moved"),
|
|
|
|
|
(Some([w0, h0]), Some([w1, h1])) => {
|
|
|
|
|
write!(out, " dimensions changed ({w0} x {h0} -> {w1} x {h1} dbu)").unwrap();
|
|
|
|
|
}
|
|
|
|
|
_ if translation(before, after).is_some() => out.push_str(" moved"),
|
|
|
|
|
_ => {
|
|
|
|
|
out.push_str(" vertices changed");
|
|
|
|
|
let (a, b) = (vertex_count(before), vertex_count(after));
|
|
|
|
|
if a != b {
|
|
|
|
|
write!(out, " ({a} -> {b} vertices)").unwrap();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(super) fn replacement_summary(old: &ObjectChange, new: &ObjectChange) -> String {
|
|
|
|
|
let polygon = is_polygon(old.kind);
|
|
|
|
|
let mut out = if polygon {
|
|
|
|
|
polygon_replacement(old, new)
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
} else {
|
2026-11-17 21:49:26 -08:00
|
|
|
let mut heading = object_heading(old, object_name(old.kind, false));
|
|
|
|
|
if let Some(target) = &old.target {
|
|
|
|
|
write!(heading, " {target:?}").unwrap();
|
|
|
|
|
}
|
|
|
|
|
heading
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let mut separator = if polygon { "\n " } else { " " };
|
|
|
|
|
for (tag, before, after) in field_changes(old, new) {
|
|
|
|
|
if polygon && tag == RTAG_XY {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
let change = match (tag, before, after) {
|
|
|
|
|
(RTAG_XY, Some(a), Some(b)) => {
|
|
|
|
|
if let Some([dx, dy]) = translation(a, b) {
|
|
|
|
|
format!("moved by ({dx}, {dy}) dbu")
|
|
|
|
|
} else if matches!(old.kind, RTAG_PATH | RTAG_NODE) {
|
|
|
|
|
let (a, b) = (XY::points(a).len(), XY::points(b).len());
|
|
|
|
|
if a == b {
|
|
|
|
|
"vertices changed".to_string()
|
|
|
|
|
} else {
|
|
|
|
|
format!("vertices changed ({a} -> {b} vertices)")
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let points = |data: &[u8]| XY::points(data).collect::<Vec<_>>();
|
|
|
|
|
format!("coordinates {:?} -> {:?} dbu", points(a), points(b))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
(RTAG_COLROW, _, _) if old.kind == RTAG_AREF => {
|
|
|
|
|
let counts = |dimensions: Option<[u16; 2]>| {
|
|
|
|
|
dimensions.map_or_else(|| "absent".to_string(), |[a, b]| format!("{a} x {b}"))
|
|
|
|
|
};
|
|
|
|
|
format!(
|
|
|
|
|
"columns/rows {} -> {}",
|
|
|
|
|
counts(old.counts),
|
|
|
|
|
counts(new.counts)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
(RTAG_WIDTH, _, _) => {
|
|
|
|
|
let width =
|
|
|
|
|
|n: Option<i32>| n.map_or_else(|| "absent".to_string(), |n| n.to_string());
|
|
|
|
|
format!("width {} -> {} dbu", width(old.width), width(new.width))
|
|
|
|
|
}
|
|
|
|
|
_ => {
|
|
|
|
|
let name = if tag == RTAG_STRING {
|
|
|
|
|
"text".to_string()
|
|
|
|
|
} else {
|
|
|
|
|
tag_name(tag)
|
|
|
|
|
};
|
|
|
|
|
format!("{name} {}", format_field_change(tag, before, after))
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
write!(out, "{separator}{change}").unwrap();
|
|
|
|
|
separator = "\n ";
|
|
|
|
|
}
|
|
|
|
|
if old.properties != new.properties {
|
|
|
|
|
let properties = |items: &[(u16, Vec<u8>)]| {
|
|
|
|
|
items
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|(attribute, value)| format!("{attribute}={}", quoted(value)))
|
|
|
|
|
.collect::<Vec<_>>()
|
|
|
|
|
.join(", ")
|
|
|
|
|
};
|
|
|
|
|
write!(
|
|
|
|
|
out,
|
|
|
|
|
"{separator}properties [{}] -> [{}]",
|
|
|
|
|
properties(&old.properties),
|
|
|
|
|
properties(&new.properties)
|
|
|
|
|
)
|
|
|
|
|
.unwrap();
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
}
|
2026-11-17 21:49:26 -08:00
|
|
|
out
|
Introduce Pheon GDSII parsing and layout review tools
Implement native GDSII reading and writing with Arrow interchange, hierarchy
scans and selective cell loading. Validate numeric packing and array pitches,
and preserve normalized REAL8 encodings exactly within the supported range.
Add standalone dump, structural diff, hierarchy, layer-name annotation and Git
diff commands. Provide scoped text and JSON reports, deterministic comparison,
and record-preserving metadata edits.
Package the shared library and optional Python Arrow readers as pheon using
CFFI ABI mode and Python-independent platform wheels. Include locked source
builds, native API checks, cross-platform artifact workflows, documentation
and regression coverage. Require Rust 1.88 or newer and Python 3.11 or newer.
Validation: 87 native tests, 14 binding tests on Python 3.11/3.13/3.14,
and 71 installed companion integration tests pass. Full, scanned and selected
Arrow layouts match the previous schemas.
2026-11-16 16:21:21 -08:00
|
|
|
}
|