FP sensitivity vs clipPolyPolygonOnPolyPolygon

Dr. David Alan Gilbert dave at treblig.org
Sun Dec 8 18:29:24 UTC 2024


Hi,
  I've got two calls to clipPolyPolygonOnPolyPolygon from the PDF import
code; one works as expected and pops out the intersecting polygon,
the other one spits out an empty polygon - the difference in the
input is a fractional change in one point's X coordinate.

  a) Can anyone explain why this happens?
  b) Would I be any better off with solvePolygonOperationAnd ?

I've got a suspicion that it's turned one into a 'hole' but, hmm,
each input is a single polygon with a single simple line; it can't
have a hole; it doesn't seem right to treat the combination as having
a winding rule when the intent is to clip one against the other.

(In this case this is clipping a chunk of 'fill' against a shape
to be filled and because of this behaviour we're losing some fill)

The inputs
'The good case' (aka 'a')
cur: [1:<5:(39717.2,28762)--(39096.7,28761.7)--(37381.4,27689.8)--(37394.8,27668.3)--(40399.7,27669.9)>]
new: xfrm: [1:<4:(38732.2,25528)--(40893.9,26878.9)--(39543.1,29040.6)--(37381.4,27689.8)>]

'The bad case' (aka 'b')
cur: [1:<5:(39717.2,28762)--(39096.7,28761.7)--(37381.4,27689.8)--(37394.8,27668.3)--(40399.6,27669.9)>]
new: xfrm: [1:<4:(38732.2,25528)--(40893.9,26878.9)--(39543.1,29040.6)--(37381.4,27689.8)>]

*** Note the .7 vs .6 in the X coordinate of the last point in 'cur'

The call
aNewClip = basegfx::utils::clipPolyPolygonOnPolyPolygon( aCurClip, aNewClip, true, false );

The good output
[1:<5:(39717.2,28762)--(39096.7,28761.7)--(37381.4,27689.8)--(37394.8,27668.3)--(40399.6,27669.9)>]

The bad output
[0:]

As far as I can tell clipPolyPolygonOnPolyPolygon diverges in
   aRetval = solveCrossovers(aRetval, pPointLimit)

which for a is:
 [2:<10:(38732.2,25528)--(40893.9,26878.9)--(40399.6,27669.9)--(40399.7,27669.9)--(39717.2,28762)--(39717.2,28762)--(39543.1,29040.6)--(37381.4,27689.8)--(37381.4,27689.8)--(37394.8,27668.3)>,<5:(39717.2,28762)--(39096.7,28761.7)--(37381.4,27689.8)--(37394.8,27668.3)--(40399.6,27669.9)>]

and for b is:
[2:<4:(38732.2,25528)--(40893.9,26878.9)--(39543.1,29040.6)--(37381.4,27689.8)>,<5:(39717.2,28762)--(39096.7,28761.7)--(37381.4,27689.8)--(37394.8,27668.3)--(40399.6,27669.9)>]
 
Thanks,

Dave
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/


More information about the LibreOffice mailing list