Comments (3)
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.
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:
This will produce:
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:
This creates negative areas at these concave joins which the final Union
operation removes:
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.
Thanks for the feedback.
And yes this is definitely a bug that needs fixing.
from clipper2.
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)
- Regression when removing type casting in IsCollinear() HOT 4
- Minkowski in export header HOT 4
- Clipper2 slower than clipper1 HOT 2
- New release? HOT 1
- can this library cut a hole in a polygon?
- How to handle path value of double type HOT 1
- [new API request] API using PolyTree for RectClip HOT 1
- Dose Clipper support to get Inscribed rectangle ?
- How Clipper2 is used in iOS project(Cocoaspod)
- Union returns self-intersecting polygon HOT 1
- Why is Rect empty when bottom <= top?
- Union of forms that touch but don't intersect
- Union of forms that share an edge
- Empty polytree when taking the union of 3 closed polygons. HOT 6
- Is there a plan for the clipper to support circular arc structures
- `RectClip` not always preserving orientation HOT 3
- Range error in TClipperOffset.BuildNormals (Delphi) HOT 1
- update vcpkg & docs HOT 1
- Negative offset should be empty but is not HOT 4
- Handling Large Shrinking Deltas for Polygons
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clipper2.