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

Allow selection and picking of surfaces with triangle strips #757

Open
Garyfallidis opened this issue Mar 8, 2023 · 3 comments
Open

Allow selection and picking of surfaces with triangle strips #757

Garyfallidis opened this issue Mar 8, 2023 · 3 comments
Labels
good first issue Good for newcomers

Comments

@Garyfallidis
Copy link
Contributor

Currently the SelectionManager works as expected for selecting triangle representations of surfaces.

However when we have surfaces represented with triangle strips we need to be more careful and find the correct triangle indices from the strips.

To see the issue you can start by modifying the viz_selection.py tutorial and add actors that use strips such as streamtube and then try to select those and start debugging the issue.

@Clarkszw
Copy link
Contributor

Clarkszw commented Mar 10, 2023

Hi @Garyfallidis, where is the viz_selection.py tutorial you mentioned..

update 10.3.2023
I think this is the tutorial you mentioned: Selecting multiple objects

@Clarkszw
Copy link
Contributor

Clarkszw commented Mar 10, 2023

Hi @Garyfallidis , I need some help..
Here is the snippet I wrote for streamtube. But I don't know how to change the color for the selection. could you give me some hitns?
Thanks in advance:)

import numpy as np
from fury import actor, window, pick, utils


scene = window.Scene()

lines = [np.random.rand(10, 3), 10 * np.random.rand(20, 3)]
colors = np.random.rand(2, 3)
streamtube_actor = actor.streamtube(lines, colors)

rgba = 255 * np.ones((100, 200, 4))
rgba[1:-1, 1:-1] = np.zeros((98, 198, 4))+100
texa = actor.texture_2d(rgba.astype(np.uint8))

scene.add(streamtube_actor)
scene.add(texa)
scene.reset_camera()
scene.zoom(3.)

showm = window.ShowManager(scene, size=(1024, 768),
                            order_transparent=True,
                            reset_camera=False)

selm = pick.SelectionManager(select='faces')
selm.selectable_off(texa)

vcolors = utils.colors_from_actor(streamtube_actor, 'colors')

def hover_callback(_obj, _event):
    event_pos = selm.event_position(showm.iren)
    # updates rectangular box around mouse
    texa.SetPosition(event_pos[0] - 200//2,
                     event_pos[1] - 100//2)

    # defines selection region and returns information from selected objects
    info = selm.select(event_pos, showm.scene, (200//2, 100//2))
    for node in info.keys():
        if info[node]['face'] is not None:
            if info[node]['actor'] is streamtube_actor:
                for face_index in info[node]['face']:
                    color_change = np.array([150, 0, 0], dtype='uint8')
                    vcolors[face_index] \
                        = color_change
                utils.update_actor(streamtube_actor)
    showm.render()

showm.add_iren_callback(hover_callback)

interactive = True

if interactive:
    showm.start()

@Preetam-Das26
Copy link

Preetam-Das26 commented Jan 25, 2024

Is this issue resolved?
@Garyfallidis @Clarkszw

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

No branches or pull requests

3 participants