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

Sphere actor does not appear when vertices and faces are used #400

Closed
nasimanousheh opened this issue Mar 29, 2021 · 4 comments · Fixed by #527
Closed

Sphere actor does not appear when vertices and faces are used #400

nasimanousheh opened this issue Mar 29, 2021 · 4 comments · Fixed by #527

Comments

@nasimanousheh
Copy link
Contributor

Description

When I use 'theta' and 'phi' parameters in sphere actor, I can see the spheres in the window. But I don't see any spheres when I use 'vertices' and 'faces' parameters.

Here is the code sample to verify the issue:

from fury import actor, primitive, window
import fury
print(fury.__version__)
print(fury.__file__)
import numpy as np

scene = window.Scene()
sphere_res = 'symmetric362'
vertices, faces = primitive.prim_sphere(name=sphere_res,
                                        gen_faces=False)
pos = 10 * np.random.rand(100, 3)
colors = 100 * np.ones((100, 3), dtype='uint8')
radii_spheres = 2+np.random.rand(100)
sphere_actor = actor.sphere(centers=pos,
                                colors=colors,
                                radii=radii_spheres,
                                vertices=vertices,
                                faces=faces)
scene.add(sphere_actor)
window.show(scene)

Thank you all!

@skoudoro
Copy link
Contributor

Hi @nasimanousheh,

Thank you for pointing that out.

I see several potential mistakes:

  • colors is between [0-1]. I don't think you need to multiply by 1000
  • vertices, faces, have only 1 sphere (and you want 100 spheres), they are not duplicating after. So you have to do it yourself.
  • why do you prim_sphere? I do not see the goal here

I need to tests your example but it will be good if you could check these 2 points first.

@nasimanousheh
Copy link
Contributor Author

Thank you for the corrections.
I fixed the code, but still the problem is not solved.
why do you prim_sphere? Currently, I'm using sphere actor in my application. There are 906 vertices in each sphere and it takes time to visualize more than1000 spheres. I want to use prim_sphere with less vertices (362 vertices or even 100 vertices).

from fury import actor, primitive, window
import fury
import numpy as np

scene = window.Scene()
vertices, faces = primitive.prim_sphere(name='symmetric362',
                                        gen_faces=False)
pos = np.array([[0,0,0]])
sphere_actor = actor.sphere(centers=pos,
                            colors=1,
                            radii=0.5,
                            vertices=vertices,
                            faces=faces)
scene.add(sphere_actor)
window.show(scene)

@skoudoro
Copy link
Contributor

ok, we will look into this issue.

a temporary solution for you is:

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

scene = window.Scene()
vertices, faces = primitive.prim_sphere(name='symmetric362',
                                        gen_faces=False)
pos = np.array([[0,0,0]])
res = primitive.repeat_primitive(vertices, faces, centers=pos)
big_verts, big_faces, big_colors, _ = res
sphere_actor = utils.get_actor_from_primitive(big_verts, big_faces, big_colors)
scene.add(sphere_actor)
window.show(scene)

@SunTzunami
Copy link
Member

SunTzunami commented Apr 5, 2021

I tried debugging it, there are perhaps three functions that can contain clues - primitive.prim_sphere, actor.sphere (which in turn uses utils.repeat_sources). I think primitive.prim_sphere works fine as I tried it and it returned the correct vertices and faces for the 'symmetric362' sphere. This leaves actor.sphere and utils.repeat_sources.
When I don't typecast the vertices on this line, it seems to work as can be seen in this preview-
image
What I mean when I say that I don't typecast is that instead of vertices.astype(np.int8) I simply use vertices.
PTAL @nasimanousheh , @skoudoro.

Thank you for the corrections.
I fixed the code, but still the problem is not solved.
why do you prim_sphere? Currently, I'm using sphere actor in my application. There are 906 vertices in each sphere and it takes time to visualize more than1000 spheres. I want to use prim_sphere with less vertices (362 vertices or even 100 vertices).

from fury import actor, primitive, window
import fury
import numpy as np

scene = window.Scene()
vertices, faces = primitive.prim_sphere(name='symmetric362',
                                        gen_faces=False)
pos = np.array([[0,0,0]])
sphere_actor = actor.sphere(centers=pos,
                            colors=1,
                            radii=0.5,
                            vertices=vertices,
                            faces=faces)
scene.add(sphere_actor)
window.show(scene)

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