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

Fix method filter_volumes_above_polygons to consider SoilVolumes and Volumes #20

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
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