Skip to content
Open
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 @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Renamed `Tolerance.units` to `Tolerance.unit` to better reflect the documented properties. Left `units` with deprecation warning.
* Fixed `NotImplementedErorr` when calling `BrepLoop.vertices`.
* Fixed `python -m compas` to detect extensions based on `importlib` rather than `pkg_resources`.
* Fixed `Polyhedron.vertices` setter to convert `Point` instances to `[x, y, z]` lists.
* `compas_rhino.uninstall` will try to remove compas packages from all possible install locations.
* Changed `angle_vectors_projected` to raise `ValueError` when an input vector is parallel to projection normal.
* Changed `angle_vectors` to raise `ValueError` when one of the input vectors is a zero-length vector instead of returning 0.
Expand Down
4 changes: 3 additions & 1 deletion src/compas/geometry/polyhedron.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def vertices(self):

@vertices.setter
def vertices(self, vertices):
self._vertices = vertices
self._vertices = []
for vertex in vertices:
self._vertices.append([*vertex])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use tuples instead of lists here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes to tuples. also, @ericgozzi we'd need to write this somehow more verbose since IPY isn't happy with the unpacking syntax (build fails)

@yck011522 I'd also love to hear more details!


@property
def faces(self):
Expand Down
16 changes: 16 additions & 0 deletions tests/compas/geometry/test_polyhedron.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from compas.geometry import Polyhedron
from compas.geometry import Point
from compas.itertools import pairwise


Expand All @@ -17,3 +18,18 @@ def test_polyhedron():
assert polyhedron.lines == [(a, b) for a, b in pairwise(vertices[-1:] + vertices)]
assert polyhedron.points[0] == vertices[0]
assert polyhedron.points[-1] != polyhedron.points[0]


def test_polyhedron_vertices():
vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
faces = [[0, 1, 2, 3]]
name = "Test Polyhedron"
polyhedron = Polyhedron(vertices, faces, name)

polyhedron_vertices = polyhedron.vertices
assert all(isinstance(vertex, list) and len(vertex) == 3 for vertex in polyhedron_vertices)

vertices = [Point(0, 0, 0), Point(1, 0, 0), Point(1, 1, 0), Point(0, 1, 0)]
polyhedron = Polyhedron(vertices, faces, name)
polyhedron_vertices = polyhedron.vertices
assert all(isinstance(vertex, list) and len(vertex) == 3 for vertex in polyhedron_vertices)
Loading