Add examples project.

This commit is contained in:
wo80
2022-02-15 17:45:36 +01:00
parent 940ae18061
commit ea6d39e1da
16 changed files with 730 additions and 27 deletions
@@ -0,0 +1,46 @@
namespace TriangleNet.Examples
{
using TriangleNet.Geometry;
using TriangleNet.Meshing;
using TriangleNet.Rendering.Text;
/// <summary>
/// Triangulate a polygon with hole and set minimum angle constraint.
/// </summary>
public static class Example2
{
public static void Run(bool print = false)
{
// Generate the input geometry.
var poly = CreatePolygon();
// Set minimum angle quality option.
var quality = new QualityOptions() { MinimumAngle = 30.0 };
// Generate mesh using the polygons Triangulate extension method.
var mesh = poly.Triangulate(quality);
if (print) SvgImage.Save(mesh, "example-2.png", 500);
}
public static IPolygon CreatePolygon(double h = 0.2)
{
// Generate the input geometry.
var poly = new Polygon();
// Center point.
var center = new Point(0, 0);
// Inner contour (hole).
poly.Add(Generate.Circle(1.0, center, h, 1), center);
// Internal contour.
poly.Add(Generate.Circle(2.0, center, h, 2));
// Outer contour.
poly.Add(Generate.Circle(3.0, center, h, 3));
return poly;
}
}
}