jbuckmccready / CavalierContours

2D polyline library for offsetting, combining, etc.
MIT License
427 stars 79 forks source link

Apparently incorrect output using ParallelOffsetIslands #49

Open esuig opened 2 years ago

esuig commented 2 years ago

Hello,

first of all, great work. Your library is impressive.

I'm starting using it to understand the potentialities.

I'm looking at the ParallelOffsetIslands. I created a small test in which I have three profiles (one outer profile and two islands). The coordinates of the profiles are as follows:

island 1: (20,20) (20,40) (40,40) (40,20) IsClosed() = true;

island 2: (60,30) (60,80) (80,80) (80,30) IsClosed() = true;

outer contour: (0,0) (100,0) (100,100) (0,100) IsClosed() = true;

Then I followed exaclty the steps reported here: https://github.com/jbuckmccready/CavalierContours/blob/master/examples/polylineoffsetislands.cpp

to perform the offset of the input profiles. However, I get a strange result that is (the blue profiles are the input ones, while the green are the output ones): output_cavc_1 In the output I get 2 profiles (the smaller one and the bigger that includes both the offset of the bigger island and the offset of the outer contour), but I would expect 3 profiles if the coincident segments are not discarded. Or, I would expect something like: expected_output Maybe I am missing something? or it is a bug?

jbuckmccready commented 2 years ago

It's a known limitation right now in the simultaneous/island offsetting where overlapping/coincident offset segments are not removed. I had planned to look into it more when I implement the simultaneous offset algorithm in the Rust project where I'm continuing development here.