Skip to content

Generic interface for both integer and floating-point triangulation#14

Open
mikwielgus wants to merge 6 commits into
iShape-Rust:mainfrom
mikwielgus:generic_api_attempt_3
Open

Generic interface for both integer and floating-point triangulation#14
mikwielgus wants to merge 6 commits into
iShape-Rust:mainfrom
mikwielgus:generic_api_attempt_3

Conversation

@mikwielgus

@mikwielgus mikwielgus commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR makes the current floating-point API a more generic interface that works both on floats and integers, while still using the same currently used integer-only code internally. This is done by creating a new PointAdapter trait that generalizes FloatPointAdapter to also work on integers, through a new IntPointAdapter struct whose methods are just identity maps.

.triangulate_as(), .unchecked_triangulate_as(), custom_triangulate_as() are still float-only and are moved to their own traits to maintain the current interface, but I'm not sure if they are still needed on this branch.

The proposal for this change was discussed on #11. I understand that this change is controversial and may be unlikely to be merged. I have created this because I need this for myself, as I tend to write geometric code that is generic over both integers and floats, and I'm PR-ing this just in case you might be interested in taking a look and reconsidering.

If there is a different way you would prefer this implemented, let me know, I can rewrite.

@mikwielgus
mikwielgus force-pushed the generic_api_attempt_3 branch 2 times, most recently from a7d2253 to c804a60 Compare July 24, 2026 21:48
@mikwielgus
mikwielgus force-pushed the generic_api_attempt_3 branch from c804a60 to 6d33d04 Compare July 24, 2026 21:55
@NailxSharipov

Copy link
Copy Markdown
Member

I checked this PR, but unfortunately, I still think the API should be separate.
I also noticed that you have a lot of similar code for shapes, paths, etc.
It's better to hide this with an abstraction that returns paths, like ShapeResource does.

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.

2 participants