ofxClipper icon indicating copy to clipboard operation
ofxClipper copied to clipboard

Clipping open paths

Open CarstenHoyer opened this issue 6 years ago • 5 comments

Hi @bakercp - I had an issue where I needed to clip an open path. I was unable to do this with the current code - maybe there is some way to do it?

What I ended up doing was setting the "use_lines" preprocessor macro and implement the clipping with Clipper::PolyTree and finally also not closing the generated paths and the incoming subject paths.

Currently I am just making some very simple changes to the code, but it could probably be made into a proper pull request.

Would that be something you'd be interested in?

Before: (notice the closed paths arr not in the after image) screenshot 2019-01-22 at 22 04 03

After: screenshot 2019-01-22 at 22 03 28

CarstenHoyer avatar Jan 22 '19 21:01 CarstenHoyer

Hi @CarstenHoyer I'm certainly interested, though I'm not totally sure what I'm looking at in the images.

bakercp avatar Jan 22 '19 22:01 bakercp

@bakercp OK I see the example probably worked better in my head :), here is a another one:

We have two bezier curves. screenshot 2019-01-23 at 08 54 41

We want to do a difference, where the blue curve is a mask on the green curve. Currently both curves will be closed by ofxClipper, and the result will look like this (the red is the clipping difference): screenshot 2019-01-23 at 08 56 13

Using PolyTree and the "use_lines" macro, we can keep the subject open (http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Methods/Execute.htm). The result will look like this - the user will have to manually close and open the blue curve: screenshot 2019-01-23 at 08 55 48

CarstenHoyer avatar Jan 23 '19 08:01 CarstenHoyer

@bakercp - Let me know what you think.

CarstenHoyer avatar Jan 25 '19 13:01 CarstenHoyer

@bakercp - did you have a moment to look at this?

CarstenHoyer avatar Feb 01 '19 07:02 CarstenHoyer

Hey there, sorry for the delay. I just merged some API changes for of 0.10.+ Could you take a look and see how these changes fit or don't fit with this issue? If your problem is still ongoing, then we should be able to find a solution with the api rework.

bakercp avatar Mar 08 '19 17:03 bakercp