Skip to content

Commit 057da4d

Browse files
committed
fix quadsurf display bug
1 parent ba911fb commit 057da4d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

ansys/dpf/core/vtk_helper.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,27 @@ def dpf_mesh_to_vtk(nodes, etypes, connectivity, as_linear=True):
159159
# partition cells in vtk format
160160
cells = np.insert(connectivity, insert_ind, elem_size)
161161

162+
def compute_offset():
163+
"""Return the starting point of a cell in the cells array"""
164+
return insert_ind + np.arange(insert_ind.size)
165+
162166
# convert kAns to VTK cell type
167+
offset = None
163168
if as_linear:
164169
vtk_cell_type = VTK_LINEAR_MAPPING[etypes]
170+
171+
# visualization bug within VTK with quadratic surf cells
172+
ansquad8_mask = etypes == 6
173+
if np.any(ansquad8_mask): # kAnsQuad8
174+
175+
# simply copy the edge node indices to the midside points
176+
offset = compute_offset()
177+
cell_pos = offset[ansquad8_mask]
178+
cells[cell_pos + 5] = cells[cell_pos + 1]
179+
cells[cell_pos + 6] = cells[cell_pos + 2]
180+
cells[cell_pos + 7] = cells[cell_pos + 3]
181+
cells[cell_pos + 8] = cells[cell_pos + 4]
182+
165183
else:
166184
vtk_cell_type = VTK_MAPPING[etypes]
167185

@@ -170,7 +188,8 @@ def dpf_mesh_to_vtk(nodes, etypes, connectivity, as_linear=True):
170188
# compute offset array when < VTK v9
171189
return pv.UnstructuredGrid(cells, vtk_cell_type, nodes)
172190

173-
split_ind = elem_size + 1
174-
split_ind[0] = 0
175-
offset = np.cumsum(split_ind)
191+
# might be computed when checking for VTK quadratic bug
192+
if offset is None:
193+
offset = compute_offset()
194+
176195
return pv.UnstructuredGrid(offset, cells, vtk_cell_type, nodes)

0 commit comments

Comments
 (0)