Skip to content

Introduce IntoBezPaths trait#191

Open
abey79 wants to merge 2 commits into
pr4-metadata-refactorfrom
pr45-intobezpaths
Open

Introduce IntoBezPaths trait#191
abey79 wants to merge 2 commits into
pr4-metadata-refactorfrom
pr45-intobezpaths

Conversation

@abey79

@abey79 abey79 commented Feb 21, 2026

Copy link
Copy Markdown
Owner

Summary

Introduces the IntoBezPathsTolerance / IntoBezPaths traits and dedicated implementations for multi-geometry types, laying the groundwork for correct multi-polygon hatching in #188.

Problem

When a geo::MultiPolygon (e.g. from boolean operations) is converted to a single BezPath, all rings are flattened together and structural boundaries between polygons are lost. The hatching code then uses the heuristic "first subpath = exterior, rest = holes", which misinterprets the second polygon's exterior as a hole in the first.

Solution

This PR adds the new trait infrastructure. The next PR (#188) wires it into Draw::add_path.

  • New traits: IntoBezPathsTolerance and IntoBezPaths (plural), which return Vec<BezPath> — one per structural unit.
  • Blanket impl: Any type implementing IntoBezPathTolerance (singular) automatically gets IntoBezPathsTolerance returning a one-element Vec, so all existing single-geometry types (kurbo shapes, geo::Polygon, etc.) work unchanged.
  • Dedicated impls for multi-geometry types (MultiPolygon, MultiLineString, MultiPoint, GeometryCollection, Geometry) that return one BezPath per constituent, preserving structural boundaries. The old IntoBezPathTolerance impls for these types are removed (they now get it via the blanket from their dedicated IntoBezPathsTolerance impl).
  • Tests verifying that MultiPolygon yields multiple bezpaths and single types yield one.

Files changed

File Change
crates/vsvg/src/path/into_bezpath.rs New traits, blanket impls, dedicated multi-geo IntoBezPathsTolerance impls (replacing old IntoBezPathTolerance impls), tests
crates/vsvg/src/path/mod.rs Export new traits

This is part 5 of 6 in a stack made with GitButler:

@abey79 abey79 added the vsvg Relates to vsvg label Feb 21, 2026
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 69fbf67 to a0db2dd Compare February 22, 2026 13:13
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from a0db2dd to 10d677b Compare February 22, 2026 20:28
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 10d677b to 69f7d5c Compare February 22, 2026 20:29
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 69f7d5c to 2819fe4 Compare February 22, 2026 21:03
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 2819fe4 to 54fd21d Compare February 22, 2026 21:07
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 54fd21d to feb5528 Compare February 22, 2026 21:31
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from feb5528 to 895ddc1 Compare March 1, 2026 08:49
@abey79 abey79 force-pushed the pr45-intobezpaths branch from 60b6bfd to fbb909a Compare March 1, 2026 08:49
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 895ddc1 to 6cb4ede Compare March 1, 2026 09:15
@abey79 abey79 force-pushed the pr45-intobezpaths branch from fbb909a to e473904 Compare March 1, 2026 09:15
@abey79 abey79 force-pushed the pr4-metadata-refactor branch from 6cb4ede to bd25ac5 Compare March 1, 2026 09:36
@abey79 abey79 force-pushed the pr45-intobezpaths branch from e473904 to 2358c23 Compare March 1, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vsvg Relates to vsvg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant