Hello Clipper, bye JTS

Polygon clipping and polygon offsetting are operations that due to the multitud of cases possible are quite a difficult beast to tame. That is why I have used an external library when I have needed such a feature in a program.

A few days ago, researching for a student's assignment, I learned that "clipper" library had been migrated to Java by Tobias Mahlmann.  I had a minor trouble with one file not using UTF-8 encoding but other than that it compiled and run beautifully (not in my large display though as I am using an scale factor larger than one that messes the Java GUI layout).


Another interesting detail is that the code will need Java 1.8 to compile as it uses a Lambda function in one of the Comparators used. However, I wanted to use it with some older code that was using 1.6 and the compiler was not happy with my version request, so I needed to do a small change to get rid of the Lamba function code in favor of an inner class. 

Once the code was working, I could use it with some code developed with Processing 2.21 and it would work ok.  Now I have to do some tests but my first impression is that Clipper is way faster than Java Topology Suite.

Update: After some tests it seems Clipper is not as robust as JTS, so I am not going to make any change to my software after all.

Comments

Popular posts from this blog

VFD control with Arduino using RS485 link

Importing OpenSCAD designs into Onshape

How to get sinusoidal s-curve for a stepper motor