Skip to content

Commit ba7b6ad

Browse files
committed
Merge branch 'surface_types' of https://github.com/compas-dev/compas into surface_types
2 parents 83c747a + e5ef490 commit ba7b6ad

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
* Changed deepcopy of `RhinoBrep` to use the native `Rhino.Geometry` mechanism.
2525
* The normal of the cutting plane is no longer flipped in `compas_rhino.geometry.RhinoBrep`.
2626
* Planar holes caused by `RhinoBrep.trim` are now automatically capped.
27+
* Fixed `Polygon` constructor to not modify the input list of points.
2728
* Fixed serialization of sphere and cylinder Breps in `RhinoBrep`.
2829
* Fixed serialization of some trimmed shapes in `RhinoBrep`.
2930

src/compas/geometry/primitives/polygon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def points(self):
132132
@points.setter
133133
def points(self, points):
134134
if points[-1] == points[0]:
135-
del points[-1]
135+
points = points[:-1]
136136
self._points = [Point(*xyz) for xyz in points]
137137
self._lines = None
138138

tests/compas/geometry/test_polygon.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ def test_polygon():
2525
assert polygon.lines == [(a, b) for a, b in pairwise(points + points[:1])]
2626

2727

28+
def test_ctor_does_not_modify_input_params():
29+
pts = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]]
30+
31+
polygon = Polygon(pts)
32+
assert len(pts) == 5
33+
assert len(polygon.points) == 4, "The last point (matching the first) should have been removed"
34+
35+
2836
def test_equality():
2937
points1 = [[0, 0, x] for x in range(5)]
3038
polygon1 = Polygon(points1)

0 commit comments

Comments
 (0)