Fix the polygon touching contour test in poly_ChkContour
commit4a44c883afc56747ea95522fcbdf9dc0b6a38952
authorPeter Clifton <pcjc2@cam.ac.uk>
Wed, 2 Jun 2010 20:08:42 +0000 (2 21:08 +0100)
committerPeter Clifton <pcjc2@cam.ac.uk>
Wed, 2 Jun 2010 20:28:13 +0000 (2 21:28 +0100)
tree406edeb130884aa2bd7bdbb9d1008be0103d39f7
parent91fd6d3ea006ebc9e9189d81e0211b7c2646dfb2
Fix the polygon touching contour test in poly_ChkContour

The following test-cases were used to help verify the changes:

This polygon forms a self-touching shape like this:

\|  However, the right-hand edge does NOT have a node at the junction.
/|  This previously caused it to fail the self-intersection test.
    It should be reported as good.

Polygon("")
  (
    [85000 50000] [85000 90000] [83000 90000]
    [83536 63535] [85000 59999] [83535 56464]
  )

This polygon forms a self-intersecting shape like this:

 |/  (The vertical section is a straight line with no node in the middle)
/|   It must be reported as bad.

Polygon("")
  (
    [85000 50000] [85000 90000] [83000 90000]
    [83536 63535] [85000 59999] [89535 56464]
  )

This polygon self-intersects, and must be reported as bad:

Polygon("")
  (
    [160000  50000] [160000  90000] [170000 100000]
    [180000 120000] [180000 150000] [160000 150000]
    [160000 120000] [170000 100000] [180000  90000]
    [180000  50000]
  )

This polygon self-touches, and should be reported as good:

Polygon("clearpoly")
  (
    [120000  50000] [120000  90000] [130000 100000]
    [120000 120000] [120000 150000] [140000 150000]
    [140000 120000] [130000 100000] [140000  90000]
    [140000  50000]
  )
src/polygon1.c