From c556cedc204ff7a7167e97e2174662f592117e0d Mon Sep 17 00:00:00 2001 From: Pablo Vasconez Date: Fri, 10 Nov 2023 16:38:19 +0100 Subject: [PATCH] fix(#19): Fix method `filter_volumes_above_polygons` to consider both all the SoilVolumes and Volumes in plaxis and not only the Volumes. --- notebooks/Plaxis3D_input_controller.ipynb | 6 +++--- src/plxcontroller/plaxis_3d_input_controller.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/notebooks/Plaxis3D_input_controller.ipynb b/notebooks/Plaxis3D_input_controller.ipynb index 4dced56..5a995f5 100644 --- a/notebooks/Plaxis3D_input_controller.ipynb +++ b/notebooks/Plaxis3D_input_controller.ipynb @@ -117,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -126,7 +126,7 @@ "\n", "filtered_volumes = co.filter_volumes_above_polygons(\n", " polygons=[\n", - " Polygon3D([(-10, -10, -5), (10, -10, -5), (10, 10, -20), (-10, 10, -20)]),\n", + " Polygon3D([(-10, -10, -20), (10, -10, -20), (10, 10, -20), (-10, 10, -20)]),\n", " ],\n", " plaxis_volumes=None,\n", ")\n", @@ -135,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ diff --git a/src/plxcontroller/plaxis_3d_input_controller.py b/src/plxcontroller/plaxis_3d_input_controller.py index dce91db..ce1e682 100644 --- a/src/plxcontroller/plaxis_3d_input_controller.py +++ b/src/plxcontroller/plaxis_3d_input_controller.py @@ -68,7 +68,7 @@ def filter_volumes_above_polygons( TypeError if parameters are not of the expected type. ValueError - if any item of plaxis_volumes is not present in the volumes of the plaxis model. + if any item of plaxis_volumes is not present in the Volumes nor SoilVolumes of the plaxis model. """ # Validate input @@ -92,14 +92,18 @@ def filter_volumes_above_polygons( raise TypeError( f"Unexpected type for item {i} of plaxis_volumes. Expected PlxProxyObject, but got {type(plaxis_volume)}." ) - if plaxis_volume not in self.g_i.Volumes: + if plaxis_volume not in list( + set(list(self.g_i.SoilVolumes) + list(self.g_i.Volumes)) + ): raise ValueError( - f"Plaxis object {plaxis_volume} is not present in the volumes of the plaxis model." + f"Item {i} of plaxis_volumes is not present in the volumes of the plaxis model." ) # Initialize plaxis_volume list as all the volumes in the Plaxis model. if plaxis_volumes is None: - plaxis_volumes = self.g_i.Volumes + plaxis_volumes = list( + set(list(self.g_i.SoilVolumes) + list(self.g_i.Volumes)) + ) # Map plaxis volumes to bounding boxes for plaxis_volume in plaxis_volumes: