GithubHelp home page GithubHelp logo

Comments (3)

AngusJohnson avatar AngusJohnson commented on August 21, 2024 4

Unfortunately, there isn't an easy fix, and the explanation is complicated 😱.

Paths 'shrink' usually when offsets are negative, but holes will also shrink when offsets are positive. Anyhow, when paths are shrinking it's possible to 'over-shrink' them, and when this happens path orientations reverse. In order to remove these over-shrunk paths, Clipper checks path orientation both before and after offsetting. But this needs to be done before the final Union operation that cleans up the offset paths. (And why this Union operation is needed will be explained below.) Unfortunately after this Union operation, there's no simple way to associate the resulting paths with paths prior to this operation. (Yes, Clipper could enable and use the Z field in paths to do this, but that would prevent Z being used for other purposes when offsetting.) So currently Clipper checks for path reversal before the final Union operation.

Why is checking for path orientation reversal before the final Union occasionally a problem? And why is a Union operation needed? Usually, determining where negative offset joins occur is fairly simple - just offset the adjacent edges and find where these intersect.
test3
But sometimes this approach won't work.

For example, when negative offsetting (-25) the path - 335,79, 211,180, 28,177, 22,183, 87,29 - using the above approach:
Clipper2b
This will produce:
test2b

To get around this, Clipper uses a different approach when offsetting produces concave joins. Instead of finding the intersect point of the offset adjacent edges, Clipper offsets vertices at concave joins by (temporarily) inserting 3 points there as illustrated in the following image:
test3
This creates negative areas at these concave joins which the final Union operation removes:
test3

Unfortunately, on occasions (as indicated at the start of this thread), the (temporary) negative areas produced at these concave joins will be greater than the non-negative areas - and this will flag path reversal and trick Clipper into removing these paths (believing that the path has shrunk too much).

So, in short, I'm still contemplating how best to address this problem.

from clipper2.

AngusJohnson avatar AngusJohnson commented on August 21, 2024 1

Thanks for the feedback.
And yes this is definitely a bug that needs fixing.

from clipper2.

AngusJohnson avatar AngusJohnson commented on August 21, 2024

This should now be fixed in the latest revision.
(I'm no longer performing area checking pre-and post offsetting to exclude excessive offsetting.)

from clipper2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.