-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Hello everybody,
This C# port of Poly2Tri is not up to date ; indeed, Java version of Poly2Tri contains several bug fixes.
As reported here (#12) the most important update you should made is to replace MeshClean by a non recursive version in the DTSweepContext.cs file, as follow :
public void MeshClean(DelaunayTriangle triangle)
{
MeshCleanReqNoStack(triangle);
}
private void MeshCleanReqNoStack(DelaunayTriangle triangle)
{
var stack = new System.Collections.Generic.Stack <DelaunayTriangle>();
stack.Push(triangle);
while (stack.Count > 0)
{
var t = stack.Pop();
if (t != null && !t.IsInterior)
{
t.IsInterior = true;
Triangulatable.AddTriangle(t);
for (int i = 0; i < 3; i++)
{
if (!t.EdgeIsConstrained[i])
{
stack.Push(t.Neighbors[i]);
}
}
}
}
}
This update will solve the stack overflow problem when you try to triangulate polygons with a lot of holes that contains a hight number of points :-)
But it's very important to understand that Poly2Tri still don't manage 100% of polygons generated with Clipper, because poly2tri does not support vertices with same coordinates (coincident).
So if you use Clipper to make polygons data and then Poly2Tri to get triangulation, your software is not robust because there are still some cases that you get a "Edge Event" exeption. Unfortunatelly, there is no easy way to deal with these cases. Clipper "strictly simple" does NOT give us a solution.
The problem is that you can't tranform any possible 2D shape in polygon tree structure without coincident points. It's not possible, so poly2tri cannot be used if your software needs to deals with any possible 2D shape.
Also, poly2tri is a good library to triangulate polygons if you are 100% sure that your data imput have not coincident points.
Another important point : this "poly2tri" project is not the same and not inherits from this project : http://sites-final.uclouvain.be/mema/Poly2Tri/
You can find here another interesting new triangulation project in .NET : https://github.com/speps/LibTessDotNet and it's fork https://github.com/Pro100AlexHell/LibTessDotNet
Thanks