Skip to content

Preserve bounded MPOLYGON and paper-space layouts - #461

Draft
dxli wants to merge 140 commits into
LibreCAD:masterfrom
dxli:codex/mpolygon-consumer-compat
Draft

dxli wants to merge 140 commits into
LibreCAD:masterfrom
dxli:codex/mpolygon-consumer-compat

Conversation

@dxli

@dxli dxli commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Preserve supported DXF geometry and layout data in LibreCAD_3 while reporting profiles that cannot be safely replayed. This draft depends on LibreCAD_3 #460 and libdxfrw #106; its combined diff includes the parent work and an unmerged codec revision.

Changes

  • Retain selected planar MPOLYGON geometry through translation and rotation, with a reported HATCH fallback for unsupported edits. Preserve selected true colors and layer states, and keep hidden and locked layer behavior consistent across drawing, selection and block edits.
  • Preserve a checked default layout graph for selected ASCII and binary R2000–R2013 paths. Refuse unsupported paper-space saves before replacing the destination; report source data that cannot be reattached.
  • Preserve selected 3D coordinates through POINT, circle, arc, ellipse, Bézier, spline and IMAGE bounds and transforms. IMAGE boundary queries and corner/boundary snaps use the same 3D geometry, shared planar projection handles selected tilted line and image edges, wrapped arc membership and endpoint snaps are corrected, zero-length vector paths return their endpoint and 3D segment and entity-snap queries clamp to endpoints, and transforms retain identity, layer, block and display metadata; mirror follows the existing 3D-line convention and rejects invalid axes.
  • Keep forced edits bound to the current same-named layer and preserve undo/redo for selected entity operations. Root dictionary closure now propagates missing descendants through shared cycles, and its image-record decisions match raw emission for selected model-space and block profiles. Skipped source IMAGEDEF and reactor records are reported when their regenerated replacements have not been proven equivalent. In selected ordinary dictionaries, entries targeting omitted raw IMAGE reactors and same-import typed IMAGEDEF records are removed and reported while unrelated entries are retained; cross-document handle collisions do not authorize a typed definition removal, and custom dictionary layouts stay outside this repair. Selected source IMAGE display fields and polygonal clipping boundaries survive a move, style metadata replacement and R2000/R2010 reopen/resave; clipping beyond the bounded retention budget and unavailable pre-R2010 clip mode are reported. IMAGEDEF dimensions and pixel settings are preserved for selected source definitions, including distinct definitions that share a file path. Bounded text-only application groups and selected XDATA, including checked same-source layer references and selected IMAGEDEF handle references, survive selected saves and reopens with required APPID rows generated. Unsupported metadata, unqualified layer edits, nondefault source APPID metadata and path-change losses are reported. Source handles are reserved and removed entries are reported. For a checked same-revision ASCII source with a sole image dictionary, the original image keys and soft-owner references are remapped to the selected definitions in ASCII and binary output; partial graphs return to reported-loss fallback. Deleting the last image also removes and reports its known source reactor and stale entries; independently useful unused definitions are not yet preserved.

Validation

  • The latest local checks pass 15 focused IMAGE, dictionary and paper-space tests and 18 layout tests, including checked IMAGE dictionary replay in both encodings, binary reopen, last-image deletion and same-writer refusal/retry and selected source image-dictionary key restoration and XDATA self/cross-definition handle mapping, including selected binary reopen and removal/foreign-import retries; independent ezdxf audits both output encodings without repairs. An earlier head passed 88 focused IMAGE and DXF persistence tests, including selected polygon clipping, metadata replacement, dictionary owner/child guards and retention-budget controls. An earlier compatible head passed 151 viewer, math, arc, line, IMAGE, intersection and scripting tests and generated AC1024 ASCII/binary IMAGE initial save/reopen controls. The cycle checks include a 1,024-dictionary shared graph; IMAGE checks include selected planar and tilted boundary queries, path, boundary and corner snapping, lock refusal, corrected retry and undo/redo.
  • On macOS ARM64, an isolated current consumer build with its bundled codec opened, moved, saved and reopened one locally authored tilted LINE; independent readback verified the translated endpoints and preserved elevations. The captured canvas was black, and selection used Select All, so this does not qualify rendered pixels or mouse picking.
  • Earlier compatible heads passed focused layout, DWG import and DXF round-trip tests. Independent ezdxf checks covered selected binary layout replay, cross-encoding layout conversions, colors and MPOLYGON output. Native macOS controls exercised selected polygon edits and paper-space reopen; these do not establish broad GUI or platform coverage.
  • The current hosted platform checks must finish on this head. Historical checks and source-bound receipts are linked from the remaining plan.

Remaining limits

IMAGE resaves remain partial outside the selected source-dictionary profile; unsupported graphs can report detached dictionaries, skipped source image records or unmodeled records. For selected filtered dictionaries, planning and writing agree and retain text-only XRECORDs with checked ownership; wrong-owner and unmodeled children remain detached. A bounded same-revision IMAGE profile omits an unused synthetic paper-space block; independent audits of selected model-space and block outputs, last-image deletion outputs, and same-revision binary LINE/IMAGE outputs report no repairs. Independent readback also checks distinct and shared IMAGEDEFs; checked same-revision ASCII-to-binary IMAGE graphs retain selected ordinary dictionaries and text XRECORDs; unsupported text and other source graphs still report dropped raw records. Selected binary-to-ASCII and binary-to-binary resaves retain checked dictionaries and the Normal plot-style pair; other producers and graph shapes remain unqualified. Source paper blocks and unknown graphs remain conservative. Other profiles and custom dictionaries remain unqualified. Complete source IMAGE dictionary, definition and reactor closure and broader binary-source XDATA handle profiles are still required.

The bounded layout and MPOLYGON profiles exclude other block/layout graphs, resources and unqualified geometry. Other tilted and rational geometry, additional layer and edit paths, native rendering, final Linux/Windows checks and the dependent codec release remain open. No general DWG/DXF or consumer parity is claimed.

Windows CI follow-up: close test input streams before file removal or replacement and read ASCII text with platform newline translation. The three affected image tests pass locally; the new Windows run is pending.

Windows validation: the refreshed BuildWindows job passed, including the three previously failing IMAGE round-trip tests. BuildWindowsPersistence also passed.

Review follow-up 63fa814f: canvas picking and logical snapping use XY distance for tilted LINE and IMAGE geometry, and grip dragging restores the selection. Edited MPOLYGON RGB is retained on supported replay; changed fill or a newly named boundary color uses the reported HATCH fallback. The pinned codec interprets MPOLYGON group 430 as fill metadata. The fallback preserves the fill and reports loss of a separate boundary color.

On macOS ARM64 with the pinned bundled codec, the headless DWG-enabled build passed all 356 unit tests and 18 layout tests. Six focused regressions failed on the previous implementation and passed after the fix. The 31 plan-checker tests and PR-base plan validation passed. Native GUI and other platform follow-up checks remain open; intersection snapping at nonzero elevation still needs qualification.

dxli added 25 commits November 21, 2026 17:47
…compat

# Conflicts:
#	PYTHON_BINDING_IMPLEMENTATION_PLAN.md
…compat

# Conflicts:
#	PYTHON_BINDING_IMPLEMENTATION_PLAN.md
…compat

# Conflicts:
#	PYTHON_BINDING_IMPLEMENTATION_PLAN.md
…compat

# Conflicts:
#	PYTHON_BINDING_IMPLEMENTATION_PLAN.md
…compat

# Conflicts:
#	PYTHON_BINDING_IMPLEMENTATION_PLAN.md
#	unittest/persistence/dwgimporttest.cpp
dxli added 29 commits November 27, 2026 16:49
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