Skip to content

Commit 146f858

Browse files
feat: process and plot contour over a mesh during pv to mesh3d conversion (#450)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent ee601a7 commit 146f858

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feat: process and plot contour over a mesh during pv to mesh3d conversion

src/ansys/tools/visualization_interface/backends/plotly/plotly_interface.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,17 @@ def _convert_polydata_to_mesh3d(self, pv_mesh: PolyData) -> go.Mesh3d:
108108
faces = triangulated_mesh.faces.reshape((-1, 4)) # Now we know all faces are triangular (3 vertices + count)
109109
i, j, k = faces[:, 1], faces[:, 2], faces[:, 3]
110110

111-
return go.Mesh3d(x=x, y=y, z=z, i=i, j=j, k=k)
111+
# Check if there is an active point dataset
112+
array = None
113+
if triangulated_mesh.point_data.active_scalars_name:
114+
array_name = triangulated_mesh.point_data.active_scalars_name
115+
array = triangulated_mesh.point_data[array_name]
116+
117+
# If each entry of the array is a vector, compute the norm
118+
if array.ndim > 1:
119+
array = ((array * array).sum(axis=1))**0.5
120+
121+
return go.Mesh3d(x=x, y=y, z=z, i=i, j=j, k=k, intensity=array)
112122

113123

114124
@property

0 commit comments

Comments
 (0)