public IDataset Execute(IApplication application) { IDataset dataSet = application.CreateDataset("Polygon test"); TestVectors testVectors = dataSet.CreateVectorSetGroup <TestVectors>("Polygons"); PolygonTriangulator polygonTriangulator = new PolygonTriangulator(); Random random = new Random(0); List <List <PolygonTriangulator.Vertex> > intersectionContourList = new List <List <PolygonTriangulator.Vertex> >(); ITable <TestVectorsFeature2D> featureTable = testVectors.VectorSet2D.FeatureTable; TestVectorsFeature2D intersectionPolygonFeature = featureTable.AllocateOne(); intersectionPolygonFeature.ID = intersectionPolygonFeature.RowIndex; foreach (TestVectorsFeature2D polygonFeature in featureTable.AllocateMany((int)PolygonCount.Value)) { polygonFeature.ID = polygonFeature.RowIndex; List <PolygonTriangulator.Vertex> contour = new List <PolygonTriangulator.Vertex>(); List <PolygonTriangulator.Vertex> intersectionContour = new List <PolygonTriangulator.Vertex>(); double centreX = random.NextDouble() * 100.0 - 50.0; double centreY = random.NextDouble() * 80.0 - 40.0; double radiusX = random.NextDouble() * 28.0 + 4.0; double radiusY = random.NextDouble() * 28.0 + 4.0; double z = (double)(polygonFeature.RowIndex - 1) / (double)PolygonCount.Value * 5.0 + 1.0; int vertexCount = 160; for (int vertexNum = 0; vertexNum < vertexCount; ++vertexNum) { double angle = (double)vertexNum / (double)vertexCount * Math.PI * 2.0; double radiusScale = random.NextDouble() * 0.0 + 1.0; double x = centreX + radiusX * radiusScale * Math.Cos(angle); double y = centreY + radiusY * radiusScale * Math.Sin(angle); contour.Add(new PolygonTriangulator.Vertex(-1, x, y)); intersectionContour.Add(new PolygonTriangulator.Vertex(-1, x, y)); } List <List <PolygonTriangulator.Vertex> > contourList = new List <List <PolygonTriangulator.Vertex> >(); contourList.Add(contour); intersectionContourList.Add(intersectionContour); List <PolygonTriangulator.Triangle> triangleList; List <PolygonTriangulator.Vertex> vertexList; polygonTriangulator.Tesselate(contourList, PolygonTriangulator.WindingRule.Odd, out triangleList, out vertexList); BuildPolygonPrimitives(testVectors, polygonFeature, z, triangleList, vertexList); } List <List <PolygonTriangulator.Vertex> > simplifiedContourList; polygonTriangulator.Simplify(intersectionContourList, PolygonTriangulator.WindingRule.Odd, out simplifiedContourList); List <PolygonTriangulator.Triangle> intersectionTriangleList; List <PolygonTriangulator.Vertex> intersectionVertexList; polygonTriangulator.Tesselate(simplifiedContourList, PolygonTriangulator.WindingRule.Positive, out intersectionTriangleList, out intersectionVertexList); BuildPolygonPrimitives(testVectors, intersectionPolygonFeature, 0.0, intersectionTriangleList, intersectionVertexList); return(dataSet); }