Bug 400521 - Performing a logical operation on vector objects adds many nodes
Summary: Performing a logical operation on vector objects adds many nodes
Status: CONFIRMED
Alias: None
Product: krita
Classification: Applications
Component: Tools/Vector (show other bugs)
Version: 4.3.0
Platform: Microsoft Windows Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-31 16:43 UTC by Gremriel
Modified: 2022-04-04 13:55 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot of before and after operation (41.14 KB, image/png)
2018-10-31 16:43 UTC, Gremriel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gremriel 2018-10-31 16:43:47 UTC
Created attachment 116009 [details]
Screenshot of before and after operation

SUMMARY

When performing a logical operation on two or more vector shapes, the resulting object has many extra nodes.

STEPS TO REPRODUCE
1. add two vector shapes
2. perform a logical operation (right-click--> Logical Operations --> Unite (or intersect and subtract)
3. select shape with Edit Shapes Tool

OBSERVED RESULT
The resulting shape has way more nodes than the originals

EXPECTED RESULT

The Number of nodes should stay the same (or less, depending on the shapes)

SOFTWARE VERSIONS
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Scott Petrovic 2018-11-01 23:39:20 UTC
I am confirming this, but setting it to a wishlist item. I remember we discussed this for a while when working on vectors. The work it would take to simplify the shapes from Unite operations was going to be quite a bit of time, so we deferred doing the work until later.
Comment 2 rogertavares 2020-09-14 15:56:30 UTC
Version 4.3.0 (2020) and error still is present. 
Would be great if its fixed.
Thanks.
Comment 3 Xu Che 2022-04-04 13:55:07 UTC
I read about this project on GSoC's ideas page and I was intrigued enough to do some research.
The project is currently implemented using Qt's built-in `QPainterPath::united()` method, where Qt converts a Bezier curve into a straight line segment before manipulating it, leading to the current issue.
I think the easiest way to fix this is to port the code for the polygon boolean operations from Libreoffice source code(`basegfx`) to Krita. The operations we want are provided in Libreoffice's `b2dpolypolygoncutter.cxx`. LibreOffice uses the MPL 2.0 license, which is compatible with Krita's GPLv3.
The Vatti and Greiner-Hormann algorithms are both possible options if we were to implement clipping from scratch, but the online descriptions I could find of these algorithms only cover operations on straight-line paths, and I'm uncertain whether they can be used for Bessel curves. (Specifically, I think the Greiner-Hormann algorithm may be applicable to Bessel curves without much modification, and I am not sure about many details of the Vatti algorithm)