diff --git a/CHANGELOG.md b/CHANGELOG.md index de5719753ba..119587906dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Fixed bug in `VolMesh.delete_cell`. +* Fixed `NoneType` error when calling `compas.geometry.Sphere.edges`. + ### Removed diff --git a/src/compas/geometry/shapes/capsule.py b/src/compas/geometry/shapes/capsule.py index e6668e85234..8ba87f97cd4 100644 --- a/src/compas/geometry/shapes/capsule.py +++ b/src/compas/geometry/shapes/capsule.py @@ -297,7 +297,7 @@ def compute_faces(self): # type: () -> list[list[int]] if v % 2 == 1: v += 1 - vertices = self._vertices + vertices = self.vertices faces = [] diff --git a/src/compas/geometry/shapes/cone.py b/src/compas/geometry/shapes/cone.py index 6036df7eb3a..0281bab723b 100644 --- a/src/compas/geometry/shapes/cone.py +++ b/src/compas/geometry/shapes/cone.py @@ -267,7 +267,7 @@ def compute_faces(self): # type: () -> list[list[int]] list[list[int]] """ - vertices = self._vertices + vertices = self.vertices faces = [] first = 0 diff --git a/src/compas/geometry/shapes/cylinder.py b/src/compas/geometry/shapes/cylinder.py index d13e036591c..29857a3743e 100644 --- a/src/compas/geometry/shapes/cylinder.py +++ b/src/compas/geometry/shapes/cylinder.py @@ -267,7 +267,7 @@ def compute_faces(self): # type: () -> list[list[int]] """ u = self.resolution_u - vertices = self._vertices + vertices = self.vertices faces = [] # side faces diff --git a/src/compas/geometry/shapes/sphere.py b/src/compas/geometry/shapes/sphere.py index 3dba8859a1d..0124dc01470 100644 --- a/src/compas/geometry/shapes/sphere.py +++ b/src/compas/geometry/shapes/sphere.py @@ -218,7 +218,7 @@ def compute_faces(self): # type: () -> list[list[int]] u = self.resolution_u v = self.resolution_v - vertices = self._vertices + vertices = self.vertices faces = [] diff --git a/tests/compas/geometry/test_capsule.py b/tests/compas/geometry/test_capsule.py new file mode 100644 index 00000000000..51ebac0ea66 --- /dev/null +++ b/tests/compas/geometry/test_capsule.py @@ -0,0 +1,16 @@ +import pytest + +from compas.geometry import Capsule + + +@pytest.fixture +def capsule(): + return Capsule(123.0, 13.0) + + +def test_capsule_discretization(capsule): + # just checking these don't break. Could not quickly find a formula that worked to test the actual values + # as function of the resolution + assert capsule.edges + assert capsule.faces + assert capsule.vertices diff --git a/tests/compas/geometry/test_cone.py b/tests/compas/geometry/test_cone.py new file mode 100644 index 00000000000..1a0d331b99b --- /dev/null +++ b/tests/compas/geometry/test_cone.py @@ -0,0 +1,16 @@ +import pytest + +from compas.geometry import Cone + + +@pytest.fixture +def cone(): + return Cone(432.0, 123.0) + + +def test_cone_discretization(cone): + # just checking these don't break. Could not quickly find a formula that worked to test the actual values + # as function of the resolution + assert cone.edges + assert cone.faces + assert cone.vertices diff --git a/tests/compas/geometry/test_cylinder.py b/tests/compas/geometry/test_cylinder.py new file mode 100644 index 00000000000..56ce885efeb --- /dev/null +++ b/tests/compas/geometry/test_cylinder.py @@ -0,0 +1,15 @@ +import pytest +from compas.geometry import Cylinder + + +@pytest.fixture +def cylinder(): + return Cylinder(radius=0.3, height=1.6) + + +def test_cylinder_discretization(cylinder): + # just checking these don't break. Could not quickly find a formula that worked to test the actual values + # as function of the resolution + assert cylinder.edges + assert cylinder.faces + assert cylinder.vertices diff --git a/tests/compas/geometry/test_shpere.py b/tests/compas/geometry/test_shpere.py new file mode 100644 index 00000000000..1be9ba4941d --- /dev/null +++ b/tests/compas/geometry/test_shpere.py @@ -0,0 +1,19 @@ +import pytest + +from compas.geometry import Frame +from compas.geometry import Sphere + + +@pytest.fixture +def sphere(): + return Sphere(450.0, Frame.worldXY()) + + +def test_sphere_discretization(sphere): + expected_face_count = sphere.resolution_v * sphere.resolution_u + expected_vertex_count = (sphere.resolution_v - 1) * sphere.resolution_u + 2 + expected_edge_count = expected_face_count * 2 - sphere.resolution_u + + assert len(sphere.edges) == expected_edge_count + assert len(sphere.faces) == expected_face_count + assert len(sphere.vertices) == expected_vertex_count