Closed GoogleCodeExporter closed 8 years ago
Note, this is a bug on java version of Poly2Tri. This version does not throw
errors.
Original comment by nico.de...@gmail.com
on 20 Apr 2015 at 9:21
duplicate sorry. There was an error in the first publishing.
Original comment by nico.de...@gmail.com
on 20 Apr 2015 at 11:01
The thing is that this isn't a strictly simple polygon since both outer ring
and the hole shares a vertex. So this is a weakly simple polygon.
As long as this shared vertex is a single object the triangulator should have
no problems triangulating. If your polygon contain multiple shared vertexes
such that all the internal triangles can't form a single edge connected graph
the cleanup of external triangles will fail.
So poly2tri assumes that vertexes shared by hole and outer ring isn't shared,
but can handle it if you make sure they are the same object. Poly2tri's simple
way of cleaning away outside triangles also assumes that all inner triangles
are connected by atleast one edge so that they form a single graph.
Original comment by thahlen@gmail.com
on 20 Apr 2015 at 12:30
Do you mean that equality check in done with == instead of Object.equals ?
Original comment by nico.de...@gmail.com
on 20 Apr 2015 at 12:39
yes
Original comment by thahlen@gmail.com
on 20 Apr 2015 at 12:41
Can I replace == by .equals or there is a reason ?
Original comment by nico.de...@gmail.com
on 20 Apr 2015 at 12:46
Since the points will contain data to build a connected graph during the
triangulation. Any input case where two different objects can have the exact
same coordinate the result of the triangulation is somewhat undefined. poly2tri
was written to assume that polygon is strictly simple and that there aren't two
objects with exactly same coordinate supplied in the input.
Original comment by thahlen@gmail.com
on 20 Apr 2015 at 12:48
If you aren't sure all input polygons is strictly simple the solution would be
to hash the points of the outer ring. Then check if the hole points .equals any
of the outer points and replace duplicate points them with the already existing
object.
Original comment by thahlen@gmail.com
on 20 Apr 2015 at 12:54
Ok. Then this could be a preprocessing step. Its true that == test is way more
faster than Object.equals.
I will change the code to check for duplicates into the method
Triangulatable.prepareTriangulation . Does its seems to be clean for you ?
Thanks,
Original comment by nico.de...@gmail.com
on 20 Apr 2015 at 1:01
I think I would do these test in the "external code" before adding the holes to
the poly2tri lib instead of altering the code in poly2tri.
It is a redundant test in every case when you know your polygons are strictly
simple, thats why I think this test should be done before adding the input to
the Polygon class.
But in this case you are changing your fork of the poly2tri lib, just for your
own usage with orbisgis. So where you add this test is up to you.
My best suggestion in this case would probably be to use this hash in Polygon
class and do the test every time you add a hole/steiner point.
Original comment by thahlen@gmail.com
on 20 Apr 2015 at 1:47
Original issue reported on code.google.com by
nico.de...@gmail.com
on 20 Apr 2015 at 9:17