wo80 / Triangle.NET

C# / .NET version of Jonathan Shewchuk's Triangle mesh generator.
442 stars 81 forks source link

Some Mesh Triangles eaten away, or not created at all #43

Closed mustbau closed 5 months ago

mustbau commented 5 months ago

Hi, in some cases the Mesh gets eaten, i.e some triangles are not created. The image below shows a case where some triangles were missing

image

Here is my code for te mesh creation: `

        p.Add(new Contour(boundary.Select(px => new Vertex(px.X, px.Y, 1)), 1));
        p.Points.AddRange(boreholepts.Select(qy => new Vertex(qy.X, qy.Y, 1)));

        var triQuality = new TriangleNet.Meshing.QualityOptions() { MinimumAngle = 20.0 };
        var options = new ConstraintOptions() { ConformingDelaunay = true };
        //var mesh = p.Triangulate(new ConstraintOptions() { Convex = true });
        var mesh = p.Triangulate(options, triQuality);//,triQuality
        var vertices = mesh.Vertices.ToList();
        var triangles = mesh.Triangles.ToList();

`

wo80 commented 5 months ago

You are referring to the four points to the right of the polygon?

Since they are not protected inside a contour, it's expected that those triangles get eaten. One way to circumvent this is to use the Convex option. Another option would be to put the whole region into a bounding box.

Please let me know what output you would like to see exactly. It might be possible to tweak the ConstraintMesher a little to get more desirable results.

wo80 commented 5 months ago

In case you are referring to the green/pink colored triangles inside the polygon, please make sure that this is not a post-processing error like in https://github.com/wo80/Triangle.NET/issues/40 and then post the input polygon data.

mustbau commented 5 months ago

Hi, Thank you for your response. I appreciate your effort and this cool project. I was referring to the internal ones that seem to be eaten. I am currently running some internal tests to check again if its not a Graphics Error.

mustbau commented 5 months ago

Hi,

After running some internal tests it came out to be a Boolean operation problem, which causes the elements to be eaten. Not anything with the Triangle algo itself, Anyways thanks for pointing in the right direction. I am closing the issue now

Cheers, :)