Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed Sphere._vertices used before populated #1407

Merged
merged 4 commits into from
Nov 1, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/shapes/capsule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/shapes/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def compute_faces(self): # type: () -> list[list[int]]
list[list[int]]

"""
vertices = self._vertices
vertices = self.vertices

faces = []
first = 0
Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/shapes/cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/shapes/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
16 changes: 16 additions & 0 deletions tests/compas/geometry/test_capsule.py
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions tests/compas/geometry/test_cone.py
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/compas/geometry/test_cylinder.py
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions tests/compas/geometry/test_shpere.py
Original file line number Diff line number Diff line change
@@ -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
Loading