From d4df21c4bec6d5d3f53fe6c42f2e9febf45734fb Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 20 Sep 2024 21:22:30 +0500 Subject: [PATCH] ifcopenshell.util.shape.get_normals --- src/ifcopenshell-python/ifcopenshell/util/shape.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/util/shape.py b/src/ifcopenshell-python/ifcopenshell/util/shape.py index 53c23297db..1fa0586e22 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/shape.py +++ b/src/ifcopenshell-python/ifcopenshell/util/shape.py @@ -290,6 +290,16 @@ def get_material_colors(geometry: ShapeType) -> npt.NDArray[np.float64]: return np.frombuffer(geometry.colors_buffer, dtype="d").reshape(-1, 4) +def get_normals(geometry: ShapeType) -> npt.NDArray[np.float64]: + """Get vertex normals as a numpy array. + + See geometry settings documentation for settings that affect normals. + + :return: A numpy array listing normal for each shape vertex. + """ + return np.frombuffer(geometry.normals_buffer, dtype="d").reshape(-1, 3) + + def get_representation_item_ids(geometry: ShapeType) -> npt.NDArray[np.int32]: """Get representation item ids for the geometry faces.""" return np.frombuffer(geometry.item_ids_buffer, dtype="i")