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

What is the best way to resolve coincident topology? #308

Open
GuillaumeFavelier opened this issue Nov 26, 2020 · 2 comments
Open

What is the best way to resolve coincident topology? #308

GuillaumeFavelier opened this issue Nov 26, 2020 · 2 comments

Comments

@GuillaumeFavelier
Copy link

I tried to design a simplified version of mne-tools/mne-python#7599 (comment) but basically, I am looking for a robust way to resolve coincident topology. In mne-python, we use a temporary hack but it does not scale considering that multiple surfaces with their own scalar values and colormap can overlap. The current version forces some offset values for the overlay but still some artifacts appear depending on the camera position.

The code to illustrate the issue
import numpy as np
import pyvista
from pyvista import examples
from matplotlib.colors import ListedColormap

surface = examples.download_cow()
points = surface.points
surface_scalars = points[:, 0] > points[:, 0].mean()
surface_cmap = ListedColormap(np.array([(1, 0, 0, 1), (0, 1, 0, 1)]))

overlay = surface.copy()
overlay_scalars = np.sin(points[:, 0] * np.pi) > 0
overlay_cmap = ListedColormap(np.array([(0, 0, 1, 1), (1, 1, 1, 0)]))

plotter = pyvista.Plotter()

kwargs = dict(
    rng=[0, 1],
    opacity=1.,
    color=None,
    rgba=False,
    backface_culling=False,
    smooth_shading=True,
)

plotter.add_mesh(
    mesh=surface,
    scalars=surface_scalars,
    cmap=surface_cmap,
    **kwargs
)

plotter.add_mesh(
    mesh=overlay,
    scalars=overlay_scalars,
    cmap=overlay_cmap,
    **kwargs
)

plotter.show()

Gives the following:

image

@larsoner
Copy link

I tried various combinations of of SetResolveCoincidentTopology, SetResolveCoincidentTopologyToShiftZBuffer, ForceTranslucentOn, pyvista.rcParams['depth_peeling']['enabled'] = True but with no luck.

Maybe a vtkAssembly and set everything to translucent (opacity 0.999) or something? https://discourse.vtk.org/t/translucent-assemblies-in-8-2-0/419/10

@agramfort
Copy link

I just tried on mac os and it works fine for me.

pyvista:       0.27.3 {pyvistaqt=0.2.0, OpenGL 4.1 ATI-3.2.32 via AMD Radeon Pro 5500M OpenGL Engine}
vtk:           9.0.1
PyQt5:         5.15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants