FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(drawing): harden linework generation against bad cache and degene… by theoryshaw · Pull Request #9311 · IfcOpenShell/IfcOpenShell · GitHub

fix(drawing): harden linework generation against bad cache and degene… - #9311

Open
theoryshaw wants to merge 1 commit into
IfcOpenShell:v0.8.0from
theoryshaw:fix-drawing-linework-cache-and-degenerate-polygon
Open

fix(drawing): harden linework generation against bad cache and degene…#9311
theoryshaw wants to merge 1 commit into
IfcOpenShell:v0.8.0from
theoryshaw:fix-drawing-linework-cache-and-degenerate-polygon

Conversation

Copy link
Copy Markdown
Member

…rate cells

Two independent crashes in CreateDrawing, the second of which was masked by the first.

Treat an unreadable linework cache as a cache miss (#9309). A cache file being present on disk does not mean it is usable: it may be zero bytes or truncated from an interrupted write, or an unhydrated cloud storage placeholder whose sync provider isn't running, in which case the directory entry reports the full logical size but no content can be read back. generate_linework checked os.path.isfile() and treated that as proof of readability, so etree.parse() aborted the whole print operation. Add parse_cached_svg(), which returns None and reports a warning instead of raising, and use it at both call sites. The cache is derived data, so regenerating is always safe. The early return needed the guard too, since combine_svgs reads that path back line by line and cannot recover from it.

Skip degenerate cell polygons (#9310). shapely.Polygon() rejects a 1 or 2 coordinate ring, and did so before the existing polygon.area < 1 check could discard the sliver. Filter on coordinate count first. This is the same defect fixed in #2836 for merge_linework_and_add_metadata, which is already guarded by len(coords) > 2; the cell path loop never got the equivalent.

Verified valid polygons are unaffected: triangles and squares are still kept, and sub-1mm2 polygons are still dropped by the area check.

…rate cells

Two independent crashes in CreateDrawing, the second of which was masked by
the first.

Treat an unreadable linework cache as a cache miss (IfcOpenShell#9309). A cache file
being present on disk does not mean it is usable: it may be zero bytes or
truncated from an interrupted write, or an unhydrated cloud storage
placeholder whose sync provider isn't running, in which case the directory
entry reports the full logical size but no content can be read back.
generate_linework checked os.path.isfile() and treated that as proof of
readability, so etree.parse() aborted the whole print operation. Add
parse_cached_svg(), which returns None and reports a warning instead of
raising, and use it at both call sites. The cache is derived data, so
regenerating is always safe. The early return needed the guard too, since
combine_svgs reads that path back line by line and cannot recover from it.

Skip degenerate cell polygons (IfcOpenShell#9310). shapely.Polygon() rejects a 1 or 2
coordinate ring, and did so before the existing `polygon.area < 1` check
could discard the sliver. Filter on coordinate count first. This is the same
defect fixed in IfcOpenShell#2836 for merge_linework_and_add_metadata, which is already
guarded by `len(coords) > 2`; the cell path loop never got the equivalent.

Verified valid polygons are unaffected: triangles and squares are still
kept, and sub-1mm2 polygons are still dropped by the area check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL