Path Intersection Issue

Post questions on how to use or achieve an effect in Inkscape.
Giacomo
Posts: 3
Joined: Mon Jan 11, 2016 2:24 am

Path Intersection Issue

Postby Giacomo » Wed Jan 13, 2016 6:22 am

Hi,

I am trying to use the path intersection tool with these two paths (the SVGs are attached):
Image

The paths have self-intersections, and it looks like in this specific case they are being ignored.
Image

The resulting intersection path is clearly not what it should be (the darker areas in the first image).

Is this a bug, or is it to be expected for self-intersecting paths?

Thanks for any pointers,

Giacomo
Attachments
testMerge.svg
Initial 2 paths
(11.07 KiB) Downloaded 163 times
Intersection.svg
Intersection
(2.2 KiB) Downloaded 165 times

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Path Intersection Issue

Postby brynn » Wed Jan 13, 2016 7:20 am

That's a correct result. The path operations don't work on self-intersecting paths.

By the way, you realize these objects are 8 feet by 9 feet, roughly? (And you're zoomed out by 95%)

Giacomo
Posts: 3
Joined: Mon Jan 11, 2016 2:24 am

Re: Path Intersection Issue

Postby Giacomo » Wed Jan 13, 2016 8:11 am

Yes, the hugeness is due to the files being generated automatically.
Could that somehow be the problem?

Because I tried reproducing the problem with other self-intersecting paths:
Image
Which gives the following intersection:
Image

This different (probably simpler) self intersecting path works perfectly fine.
Does Inkscape not view this path as self-intersecting?

Also, sorry for bothering you but do you have any reference for the fact that path operations don't work with self-intersecting paths?
Attachments
test2.svg
2 Paths
(2.51 KiB) Downloaded 161 times
intersection2.svg
Intersection
(2.88 KiB) Downloaded 173 times

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Path Intersection Issue

Postby ~suv » Wed Jan 13, 2016 11:11 am

Giacomo wrote:(...) the files being generated automatically.
Could that somehow be the problem?

Yes, it is (and not the fact that the paths self-intersect).

  • Pragmatic workaround:
    1. Open the generated file in Inkscape, select both paths, nudge the selection with the cursor keys (e.g. a tick up and back down) before applying 'Path > Intersection'.
    2. Alternatively, select both paths, open 'Fill and Stroke' and toggle the fill rule from 'evenodd' to 'nonzero' and back to 'evenodd' before applying 'Path > Intersection'.
  • Technical explanation:
    1. The generated files define the fill rule for the paths as presentation attribute 'fill-rule' (snippet from testMerge.svg, content of path data 'd' omitted):

      Code: Select all

        <path
           fill-rule="evenodd"
           id="path520106"
           d="…"
           style="opacity:0.50" />
      This is valid SVG, and rendered correctly (as expected) when opened in Inkscape.
    2. Inkscape on the other hand always writes style properties as inline CSS in the 'style' attribute (snippet from test2.svg, content of path data 'd' omitted):

      Code: Select all

          <path
             style="fill:#ff2b2b;fill-opacity:0.62769228;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
             d="…"
             id="path21745"
             inkscape:connector-curvature="0" />
    Apparently, stable Inkscape releases (latest 0.91 and earlier ones) don't fully support the file-rule as presentation attributes with boolean path operations (tested and confirmed with Inkscape 0.47, 0.48.5 and 0.91). As soon as the fill-rule is defined as style property in the 'style' attribute, the result is as expected (the workarounds trigger a rewrite of the objects' style by Inkscape, thus converting the presentation attribute into a style property).

    Current development snapshot builds based on Inkscape trunk (aka Inkscape 0.91+devel) do produce the expected results without resorting to any workaround --> AFAICT the next major release (0.92) will handle such generated files ok for boolean path operations (tested with several local trunk builds on OS X 10.7.5 - it seems that the presentation attributes get converted to a style property already on load).

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Path Intersection Issue

Postby ~suv » Wed Jan 13, 2016 11:28 am

Off topic:
~suv wrote:Current development snapshot builds based on Inkscape trunk (aka Inkscape 0.91+devel) do produce the expected results without resorting to any workaround --> AFAICT the next major release (0.92) will handle such generated files ok for boolean path operations (tested with several local trunk builds on OS X 10.7.5 - it seems that the presentation attributes get converted to a style property already on load).
… more technical details (probably off-topic for a user forum):
Based on tests with archived development snapshot builds, this modification of the SVG source on load seems more of a unexpected (and unintended) side-effect of a commit which forces the addition of a viewBox attribute in files which don't have one defined already (r13938). AFAIK whether or not this exact change will be part of the next major release is not fully determined yet. The underlying issue (presentation attribute for fill-rule has no effect on boolean path operation) as such still persists, unfortunately.

Giacomo
Posts: 3
Joined: Mon Jan 11, 2016 2:24 am

Re: Path Intersection Issue

Postby Giacomo » Thu Jan 14, 2016 1:05 am

Thank you!
That solved the issue nicely

Since I was generating the files myself, I will just modify how I specify the fill-rule.

Thanks again for the quick response


Return to “Help with using Inkscape”