Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Updated workflows to v2.
* Changed deepcopy of `RhinoBrep` to use the native `Rhino.Geometry` mechanism.
* The normal of the cutting plane is no longer flipped in `compas_rhino.geometry.RhinoBrep`.
* Fixed `Polygon` constructor to not modify the input list of points.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/primitives/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def points(self):
@points.setter
def points(self, points):
if points[-1] == points[0]:
del points[-1]
points = points[:-1]
self._points = [Point(*xyz) for xyz in points]
self._lines = None

Expand Down
8 changes: 8 additions & 0 deletions tests/compas/geometry/test_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def test_polygon():
assert polygon.lines == [(a, b) for a, b in pairwise(points + points[:1])]


def test_ctor_does_not_modify_input_params():
pts = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]]

polygon = Polygon(pts)
assert len(pts) == 5
assert len(polygon.points) == 4, "The last point (matching the first) should have been removed"


def test_equality():
points1 = [[0, 0, x] for x in range(5)]
polygon1 = Polygon(points1)
Expand Down