Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(node_components, str):
node_components = [node_components]
mask = np.zeros(grid.n_points, np.bool)
for component in node_components:
component = component.upper()
if component not in grid.point_arrays:
raise KeyError('Result file does not contain node ' +
'component "%s"' % component)
mask += grid.point_arrays[component].view(np.bool)
# need to extract the mesh
cells, offset = vtk_cell_info(grid)
if sel_type_all:
cell_mask = cells_with_all_nodes(offset, cells, grid.celltypes,
mask.view(np.uint8))
else:
cell_mask = cells_with_any_nodes(offset, cells, grid.celltypes,
mask.view(np.uint8))
if not cell_mask.any():
raise RuntimeError('Empty component')
reduced_grid = grid.extract_cells(cell_mask)
if not reduced_grid.n_cells:
raise RuntimeError('Empty mesh due to component selection\n' +
'Try "sel_type_all=False"')
ind = reduced_grid.point_arrays['vtkOriginalPointIds']
if not ind.any():
raise RuntimeError('Invalid selection.\n' +