Looks like a great start. Feel free to push a draft PR when ready so you can get early feedbacks.
I had a quick look and this looks pretty fine to me. We'll try to have a deeper look at it later.
@GeneFC, do you have time to test this PR? I tried it on some strange U shapes with random holes in them and that sort of thing, but maybe you can come up with some more edge cases that it might break.