From 2cc1633ee9b66c6138b2d090e5ce695c072d1769 Mon Sep 17 00:00:00 2001 From: katehryhorenko Date: Wed, 13 Sep 2023 14:19:33 -0300 Subject: [PATCH] Polygon: delete last vertex if it equals the first one --- Elements/src/Geometry/Polygon.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Elements/src/Geometry/Polygon.cs b/Elements/src/Geometry/Polygon.cs index fa0e11f2d..4b9ccf43a 100644 --- a/Elements/src/Geometry/Polygon.cs +++ b/Elements/src/Geometry/Polygon.cs @@ -77,6 +77,12 @@ protected override void ValidateVertices() this.Vertices = Vector3.RemoveSequentialDuplicates(this.Vertices, true); DeleteVerticesForOverlappingEdges(); + + if (Vertices.Count > 3 && Vertices[Vertices.Count - 1].IsAlmostEqualTo(Vertices[0])) + { + Vertices.RemoveAt(Vertices.Count - 1); + } + if (this.Vertices.Count < 3) { throw new ArgumentException("The polygon could not be created. At least 3 vertices are required.");