cavalier_contours icon indicating copy to clipboard operation
cavalier_contours copied to clipboard

API (and C FFI) for Multi Polyline Offset

Open jbuckmccready opened this issue 2 years ago • 2 comments

Add C FFI wrapper function for the multi polyline offset algorithm (currently in Rust the Shape::parallel_offset method).

The way that the multi polyline offset is implemented requires spatial indexes for all the polylines and the bounding boxes of the polylines which will require a little more involved C FFI wrapper or a more simplistic wrapper which has to rebuild the indexes.

Current questions I'm mulling over:

  • Does it make sense to have a shape type? Maybe these composite algorithms should just stand on their own as free functions? Raises question for how the data can be elegantly passed in.
  • Rust API maybe needs to create traits to represent a shape type (or access to shape data) to avoid having to copy and allocate into an owned Shape type when polylines and indexes are already owned by other user structures?
  • The API in Rust maybe affects how the C FFI is formed?

jbuckmccready avatar Jul 27 '23 01:07 jbuckmccready

Any guess for when this might be done?

I'm currently working on integrating this library into a Mac application (FWIW, I'm using the C FFI from Objective-C). I'd prefer to avoid duplication of effort if it's close to being ready; but if it's not then I'll just hack something together.

bdurbrow avatar Mar 05 '24 10:03 bdurbrow

Any guess for when this might be done?

I'm currently working on integrating this library into a Mac application (FWIW, I'm using the C FFI from Objective-C). I'd prefer to avoid duplication of effort if it's close to being ready; but if it's not then I'll just hack something together.

I haven't started or done anything for the C FFI, feel free to add them and make a PR. I wont be able to get to this anytime soon.

jbuckmccready avatar Mar 06 '24 07:03 jbuckmccready

Ugh... finally got a chance finish this (came down with carpel tunnel in both hands, couldn't type - I'm a bit better now, but I still need to get the surgery done to fix it). Anyways....

OK, I think I did this right... at least, it's working on my machine. I'm NOT a Rust programmer so there's probably better ways to accomplish this, but... it is working for me. Nonetheless you should probably have a look at the PR before accepting it.

bdurbrow avatar Dec 27 '24 06:12 bdurbrow

Hey, thanks for the PR! I reviewed it, link to PR for reference here.

jbuckmccready avatar Jan 03 '25 18:01 jbuckmccready

Implemented in this PR: https://github.com/jbuckmccready/cavalier_contours/pull/63

jbuckmccready avatar Jul 06 '25 22:07 jbuckmccready