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

Changing focal point of plotter when pressing 'f' doesnt work when plotting UnstructuredGrid and editting it. #6067

Open
koenterheegde0507 opened this issue May 10, 2024 · 0 comments
Labels
bug Uh-oh! Something isn't working as expected.

Comments

@koenterheegde0507
Copy link

Describe the bug, what's wrong, and what you expected.

I am plotting an unstructured grid and trying to edit things in there while I have a Plotter open. The focal point of the camera doesn't always go the cursor, but in some cases it does. In the video I added, I first pressed 'f' with the cursor on the top block and then on the bottom block. The focal point goes to the correct point for the lower block but not for the upper one.

Steps to reproduce the bug.

import numpy as np
import vtk
import pyvista as pv
from pyvista import CellType
def testFunction(selected_grid):
   
        if not selected_grid.n_cells:
            return
        ghost_cells = np.zeros(grid.n_cells, np.uint8)
        ghost_cells[selected_grid['orig_extract_id']] = 1
        grid.cell_data[vtk.vtkDataSetAttributes.GhostArrayName()] = ghost_cells
        grid.RemoveGhostCells()


cells = np.array([8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15])


# cell type array. Contains the cell type of each cell
cell_type = np.array([CellType.HEXAHEDRON, CellType.HEXAHEDRON])


# in this example, each cell uses separate points
cell1 = np.array(
    [
        [0, 0, 0],
        [1, 0, 0],
        [1, 1, 0],
        [0, 1, 0],
        [0, 0, 1],
        [1, 0, 1],
        [1, 1, 1],
        [0, 1, 1],
    ]
)


cell2 = np.array(
    [
        [0, 0, 2],
        [1, 0, 2],
        [1, 1, 2],
        [0, 1, 2],
        [0, 0, 3],
        [1, 0, 3],
        [1, 1, 3],
        [0, 1, 3],
    ]
)


# points of the cell array
points = np.vstack((cell1, cell2)).astype(float)


# create the unstructured grid directly from the numpy arrays
grid = pv.UnstructuredGrid(cells, cell_type, points)
plotter = pv.Plotter()
plotter.add_mesh(grid,color='blue')
plotter.enable_cell_picking(callback=testFunction,show=False)
plotter.show()

System Information

--------------------------------------------------------------------------------
  Date: Fri May 10 14:41:04 2024 W. Europe Daylight Time

                OS : Windows
            CPU(s) : 24
           Machine : AMD64
      Architecture : 64bit
       Environment : Python
        GPU Vendor : NVIDIA Corporation
      GPU Renderer : NVIDIA GeForce RTX 3070 Ti/PCIe/SSE2
       GPU Version : 4.5.0 NVIDIA 516.94

  Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit
  (AMD64)]

           pyvista : 0.38.6
               vtk : 9.3.0
             numpy : 1.21.6
           imageio : 2.31.2
            scooby : 0.7.3
             pooch : v1.8.0
        matplotlib : 3.5.3
           IPython : 7.34.0
        ipywidgets : 8.1.2
             scipy : 1.7.3
              tqdm : 4.66.2
            meshio : 5.3.4
      nest_asyncio : 1.6.0
--------------------------------------------------------------------------------

Screenshots

Flux.PC.Remote.-.TeamViewer.2024-05-10.14-42-20.mp4
@koenterheegde0507 koenterheegde0507 added the bug Uh-oh! Something isn't working as expected. label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

1 participant