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

NF: Sphere, Geometry & Material #946

Merged
merged 5 commits into from
Dec 20, 2024
Merged

Conversation

m-agour
Copy link
Contributor

@m-agour m-agour commented Dec 7, 2024

Added Sphere actor.

@pep8speaks
Copy link

pep8speaks commented Dec 7, 2024

Hello @m-agour! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 95:80: E501 line too long (81 > 79 characters)

Line 5:80: E501 line too long (84 > 79 characters)

Line 29:80: E501 line too long (81 > 79 characters)
Line 154:80: E501 line too long (84 > 79 characters)

Comment last updated at 2024-12-16 15:56:33 UTC

@m-agour
Copy link
Contributor Author

m-agour commented Dec 7, 2024

I will fix the pep8 and upload the tests

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @m-agour,

thank you for this. Do you know when this will be ready?

Let's try to move forward !

@@ -0,0 +1 @@
from .actor import sphere
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, use absolute import

Comment on lines 1 to 4
import fury.primitive as fp
import numpy as np
from fury.v2.actor.materials import _create_mesh_material
from fury.v2.actor.geometry import buffer_to_geometry, create_mesh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import order incorrect,

opacity=1,
material='phong',
enable_picking=True
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not forget docstring

Comment on lines 26 to 27
if faces is None and vertices is None:
vertices, faces = fp.prim_sphere(phi=phi, theta=theta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if only vertices is None ? will it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if only vertices is None ? will it work?

@skoudoro No, It will not work and I can't imagine any use case for giving the vertices and faces of a sphere to create a sphere. Do you think we should remove it or keep it?

scales=scales,
)
big_verts, big_faces, big_colors, _ = res
print(big_colors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print to remove

@@ -0,0 +1,32 @@
from pygfx import Geometry, Mesh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure geometry should be under actor folder

@@ -0,0 +1,54 @@
import fury.primitive as fp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure actor should be under actor folder. let's keep it simple and create submodule later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-agour and @skoudoro The broader picture on this is, it should have actor directory and actors should be divided in files such as sphere and line should be part of base.py and odf and slicer should be part of medical.py segregating the actors based on buckets or types.

Copy link
Contributor

@maharshi-gor maharshi-gor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at requesting changes and move faster on this @m-agour .

Thanks!

@@ -0,0 +1,54 @@
import fury.primitive as fp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-agour and @skoudoro The broader picture on this is, it should have actor directory and actors should be divided in files such as sphere and line should be part of base.py and odf and slicer should be part of medical.py segregating the actors based on buckets or types.

pick_write=enable_picking,
color_mode='vertex' if color is None else 'auto',
color=color if color is not None else (1, 1, 1, opacity if color is None else 1),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw an exception if the material does not equal to one of the configured types.

@skoudoro
Copy link
Contributor

The broader picture on this is, it should have actor directory and actors should be divided in files such as sphere and line should be part of base.py and

I think it is over-engineering @maharshi-gor. Let's keep it simple and split when we feel the need.

odf and slicer should be part of medical.py segregating the actors based on buckets or types.

odf can be used in other field like Geophysics, Astrophysics and Cosmology. We want fury to be generic. if odf is in medical.py, other field might avoid this file for no reason @maharshi-gor

@skoudoro
Copy link
Contributor

Also, try to squash your commit @m-agour please!

@m-agour
Copy link
Contributor Author

m-agour commented Dec 13, 2024

Thank you @skoudoro @maharshi-gor for your reviews I am already working on them and would finish them by tomorrow the 14th.

@m-agour
Copy link
Contributor Author

m-agour commented Dec 13, 2024

Also, try to squash your commit @m-agour please!

Will do @skoudoro

@m-agour m-agour marked this pull request as ready for review December 15, 2024 06:32
NF: mesh material

NF: geometry & mesh

NF: added sphere actor

RF: init actors

BF: fix `sphere` opacity

RF: pep8 issues fix & absolute import

RF: convert `actor` module into fury/actor.py

DOC: updated Sphere&material docstring
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @m-agour,

Thank you for the update. Here some initial review before trying it.

Also, Can you run pre-commit to make to follow the standard?

pip install pre-commit
pre-commit install
pre-commit run my_py_files

fury/actor.py Outdated
Spheres positions.
colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,)
RGB or RGBA (for opacity) R, G, B, and A should be in the range [0, 1].
radii : float or ndarray, shape (N,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, optional to add

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you just missed this one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this?

fury/actor.py Outdated Show resolved Hide resolved
fury/actor.py Outdated Show resolved Hide resolved
fury/actor.py Outdated Show resolved Hide resolved
fury/actor.py Outdated Show resolved Hide resolved
fury/material.py Outdated Show resolved Hide resolved
fury/material.py Outdated Show resolved Hide resolved
fury/material.py Outdated Show resolved Hide resolved
fury/material.py Outdated Show resolved Hide resolved
fury/material.py Show resolved Hide resolved
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, overall, it looks good!

Thank you for this @m-agour. I need to try it locally, butI think it is ready to be merged.

@maharshi-gor, Do you want to give it a look? if no news, I will go ahead and merge it tomorrow.

@maharshi-gor
Copy link
Contributor

I haven't tried as I need to device the tutorial on this. But looking at the PR LGTM.

I will give feedback as I have those tutorials ready.

@m-agour
Copy link
Contributor Author

m-agour commented Dec 16, 2024

Thank you, @skoudoro and @maharshi-gor for your reviews!

Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @m-agour,

After testing this PR, it can not be merged unfortunately.

  • Please, add some tests for material, geometry, utils and update the previous one for sphere actor.
  • See my comment below to address

fury/actor.py Outdated
Spheres positions.
colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,)
RGB or RGBA (for opacity) R, G, B, and A should be in the range [0, 1].
radii : float or ndarray, shape (N,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this?

fury/actor.py Outdated
Comment on lines 52 to 58
>>> from fury import window, actor
>>> scene = window.Scene()
>>> centers = np.random.rand(5, 3)
>>> colors = np.random.rand(5, 3)
>>> sphere_actor = actor.sphere(centers, colors, radii=0.5)
>>> scene.add(sphere_actor)
>>> # window.show(scene)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this example does not work. Can you update it ? ( window.show does not exist, missing numpy import)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on it @skoudoro

@skoudoro skoudoro added the v2 label Dec 18, 2024
Copy link
Contributor

@skoudoro skoudoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the last update @m-agour. Looks good to me, merging

@skoudoro skoudoro merged commit bfbedf7 into fury-gl:v2 Dec 20, 2024
3 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants