Skip to content

Commit 0123782

Browse files
committed
add bounding box computations for meshes
1 parent 7983c1c commit 0123782

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@
4242
- Joseph Kenny <<kenny@arch.ethz.ch>> [@jckenny59](https://github.com/jckenny59)
4343
- Panayiotis Papacharalambous <<papacharalambous@arch.ethz.ch>> [@papachap](https://github.com/papachap)
4444
- Oliver Bucklin <<obucklin@arch.ethz.ch>> [@obucklin](https://github.com/obucklin)
45+
- Dominik Reisach <<reisach@arch.ethz.ch>> [@dominikreisach](https://github.com/dominikreisach)

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99

1010
### Added
11+
* Implemented `to_points` method in `compas.datastructures.Mesh`, which before raised a `NotImplementedError`.
12+
* Implemented `compute_aabb` method in `compas.datastructures.Datastructure`, which before raised a `NotImplementedError`. Made use of the `compas.geometry.bbox.bounding_box` function.
13+
* Implemented `compute_obb` method in `compas.datastructures.Datastructure`, which before raised a `NotImplementedError`. Made use of the `compas.geometry.bbox_numpy.oriented_bounding_box_numpy` function.
1114

1215
### Changed
1316

src/compas/datastructures/datastructure.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def compute_aabb(self):
8686
:class:`compas.geometry.Box`
8787
8888
"""
89-
raise NotImplementedError
89+
from compas.geometry import Box
90+
from compas.geometry.bbox import bounding_box
91+
92+
return Box.from_bounding_box(bounding_box(self.to_points()))
9093

9194
def compute_obb(self):
9295
"""Compute the oriented bounding box of the datastructure.
@@ -96,7 +99,10 @@ def compute_obb(self):
9699
:class:`compas.geometry.Box`
97100
98101
"""
99-
raise NotImplementedError
102+
from compas.geometry import Box
103+
from compas.geometry.bbox_numpy import oriented_bounding_box_numpy
104+
105+
return Box.from_bounding_box(oriented_bounding_box_numpy(self.to_points()))
100106

101107
def transform(self, transformation):
102108
"""Transforms the data structure.

src/compas/datastructures/mesh/mesh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ def to_points(self):
725725
The points representing the vertices of the mesh.
726726
727727
"""
728-
raise NotImplementedError
728+
return [self.vertex_coordinates(vertex) for vertex in self.vertices()]
729729

730730
def to_polygons(self):
731731
"""Convert the mesh to a collection of polygons.

0 commit comments

Comments
 (0)