1

ClipperLib documentation about offset operation says among preconditions:

  1. The orientations of closed paths must be consistent such that outer polygons share the same orientation, and any holes have the opposite orientation (ie non-zero filling). Open paths must be oriented with closed outer polygons.

(emphasis mine)

What is the definition of orientation for an open path?

6502
  • 112,025
  • 15
  • 165
  • 265
  • 1
    Good question! I'm the person who wrote both Clipper and its documentation, and I don't remember what I was thinking when I wrote that. However, I agree with your implication that what I wrote doesn't make sense since open paths don't have orientation. – Angus Johnson Nov 05 '20 at 21:22

1 Answers1

0

The definition of orientation makes sense only for closed paths, that is a typo in the documentation.

Also if the input is not sorted and oriented (i.e. the area you want to offset is defined as a collection of closed loops assuming even-odd filling rule and it's unknown what loops are holes and what are boundaries) a solution is to perform the operation in two steps

  1. Compute the x-or of all the loops as a boolean operation
  2. Compute the offset of the result

This is possible because results from clipperlib operations are always sorted and oriented.

6502
  • 112,025
  • 15
  • 165
  • 265