Hi! I’m working on wrapping the C++ library Clipper2 which is a polygon boolean/clipping/offsetting library. I believe that this crate would be useful for 2D polygon graphics, gamedev and similar once I get it working. I myself have a need for the Clipper2 functionality in my cnccoder crate, but I’m sure others would also find other uses for the Rust clipper2 crate.
I’m looking for help getting the FFI parts working, I’m trying to create a Paths struct that should be able to match the memory layout of the C++ std::vector type.
Currently the cargo test
code on the no-copy
branch compiles, but crashes in runtime with the error fatal runtime error: Rust cannot catch foreign exceptions
.
The goal is to provide a Rust API to pass the src/tests.rs
#[test]
fn test_union() {
let shape1 = vec![(1.0, 1.0), (1.0, 5.0), (5.0, 5.0), (5.0, 1.0)];
let shape2 = vec![(2.0, 2.0), (2.0, 4.0), (8.0, 4.0), (8.0, 2.0)];
let shape3 = vec![(20.0, 20.0), (20.0, 40.0), (80.0, 40.0), (80.0, 20.0)];
let shapes = vec![shape1, shape2, shape3];
let paths = Paths::from(shapes);
let result = union(&paths, FillRule::NonZero);
assert_eq!(result.iter().count(), 2);
assert_eq!(
result.to_vec(),
Paths::from(vec![vec![(1.0, 1.0) /* fix expected output once there are no more crashes */]]).to_vec()
);
}
As I currently got a bit stuck with the skills I currently have I decided to try to reach out and get help on getting the basic FFI setup working. Where would be a good place to find people with experience with the combination of C++ and Rust need for FFI?
Either just help with advice on moving forward, or with actual code contributions.