Skip to content

Commit e9162f6

Browse files
committed
[BUG] Fix empty element handling in boundary plotting logic
Ensure elements with no vertices are properly excluded, raising an error if none remain. This prevents potential runtime issues during 3D plot generation.
1 parent 8307d7d commit e9162f6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

gempy_viewer/API/_plot_3d_API.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,25 @@ def plot_3d(
125125
**kwargs_plot_topography
126126
)
127127

128-
if data_to_show.show_boundaries[0] is True and len(solutions_raw_arrays.vertices) != 0:
128+
if data_to_show.show_boundaries[0] is True:
129+
# Check elements to plot .vertices are not empty
130+
elements_to_plot = model.structural_frame.structural_elements
131+
for element in elements_to_plot:
132+
if element.vertices is None:
133+
elements_to_plot.remove(element)
134+
if len(elements_to_plot) == 0:
135+
raise ValueError("No elements to plot. Please check the model.")
136+
129137
if transformed_data:
130138
surfaces_transform = model.input_transform
131139
grid_transform = model.grid.transform
132140
else:
133141
surfaces_transform = None
134142
grid_transform = None
135-
143+
136144
plot_surfaces(
137145
gempy_vista=gempy_vista,
138-
structural_elements_with_solution=model.structural_frame.structural_elements,
146+
structural_elements_with_solution=elements_to_plot,
139147
input_transform=surfaces_transform,
140148
grid_transform=grid_transform,
141149
**kwargs_plot_surfaces

0 commit comments

Comments
 (0)