Skip to content

Commit

Permalink
fix(#19): Fix method filter_volumes_above_polygons to consider both…
Browse files Browse the repository at this point in the history
… all the SoilVolumes and Volumes in plaxis and not only the Volumes.
  • Loading branch information
Pablo Vasconez committed Nov 10, 2023
1 parent 0024445 commit c556ced
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions notebooks/Plaxis3D_input_controller.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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",
Expand All @@ -135,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down
12 changes: 8 additions & 4 deletions src/plxcontroller/plaxis_3d_input_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit c556ced

Please sign in to comment.