-
Notifications
You must be signed in to change notification settings - Fork 109
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
new functions for compas geometry #569
base: main
Are you sure you want to change the base?
new functions for compas geometry #569
Conversation
line divide by count polyline shorten polyline rebuild polyline divide by count polyline tween transformations extend line transformations extend polyline intersection_mesh_line intersection_mesh_plane split polyline_plane split mesh_plane
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked mostly for code style. I guess @brgcode would check for correctness in terms of geometry processing.
I added a bunch of comments, plus I think it would really be of use to add a few unit tests to this (and it should not be overly complex to do so).
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
Co-authored-by: Gonzalo Casas <[email protected]>
corrected errors invoke lint passed invoke test passed
intersection_2 = intersection_line_triangle(line, triangle_2) | ||
if intersection_2: | ||
return Point(intersection_2[0], intersection_2[1], intersection_2[2]) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Nik, nice PR! There's a lot going in this, so I've made a lot of comments, sorry if it is overwhelming. Really, there are three general themes to the comments.
- The first category is about making the docstrings consistent and exact:
There should be consistency in using the same tense, capitalization, and punctuation (eg "Return blahblahblah. " vs "returns blahblahblah").
Types of function parameters and return objects should be double checked. Reference-able types should be included in the format required by Sphinx, eg
:class:`compas.geometry.Point`
Docstrings should by default include examples that can be run as tests. I didn't explicitly ask for examples in my comments, but those should be added when possible.
-
The next category of comments is about tightening up the code. Using one line instead of two, or naming conventions. These are mostly about readability, and maybe are just my personal preference, but a couple of them are about optimization.
-
The last category of comments is about code correctness. I think in one or two places some edge cases were missed, and these need to be addressed.
Do let me know if anything is unclear.
|
||
Parameters | ||
---------- | ||
mesh : compas.datastructures.Mesh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the documentation reference-able, this should read
mesh : :class:`compas.datastructures.Mesh`
and similarly for all references in this PR.
------- | ||
Point : compas.geometry.Point | ||
""" | ||
for fkey in list(mesh.faces()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it mesh.faces()
returns a generator, so there's no need to instantiate a list (could be very taxing on memory), so it would be more efficient to have:
for fkey in mesh.faces():
if not vertex_keys: | ||
continue | ||
vertices = [mesh.vertex_attributes(vkey, 'xyz') for vkey in vertex_keys] | ||
if len(vertex_keys) not in (3, 4): | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be simplified to
if not (vertex_keys and len(vertex_keys) in (3,4)):
continue
vertices = [mesh.vertex_atrributes(vkey, 'xyz') for vkey in vertex_keys]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well or a condition that fails early (the and
will require both conditions to be checked at all times)
if not vertex_keys or len(vertex_keys) not in (3, 4):
continue
intersections: list of points as keys from mesh | ||
""" | ||
intersections = [] | ||
for u, v in list(mesh.edges()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, for efficiency for u, v in mesh.edges():
|
||
Returns | ||
------- | ||
Point : compas.geometry.Point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:class:`compas.geometry.Point`
Parameters | ||
---------- | ||
mesh : compas.datastructures.Mesh | ||
plane : compas.geometry.Plane |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a description of 'open'.
|
||
|
||
def intersection_mesh_line(mesh, line): | ||
"""Compute intersection between mesh faces and line. After one single intersection, stops searching for more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are very clear in the docstrings about the behavior of intersection_mesh_line
and intersection_mesh_plane
, but I don't like that the one fails early (returning the first point of intersection with a line) and the other gives all points of intersection. I think the difference should be reflected in the names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename both to intersections_mesh_xxx
? with returned intersections sorted based on distance in the case of line
?
triangle = [vertices[0], vertices[1], vertices[2]] | ||
intersection = intersection_line_triangle(line, triangle) | ||
if intersection: | ||
return Point(intersection[0], intersection[1], intersection[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this work?
return Point(*intersection)
return intersections | ||
|
||
|
||
def mesh_vertices_to_points(mesh, v_keys): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't have much functionality, and I don't see much point of adding it to the library.
|
||
Returns | ||
------- | ||
list of :class: 'compas.geometry.Point' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list of :class:`compas.geometry.Point`
Hi everyone, First, thank you for the great package. Would it be possible to know when this will be merged. I need the function All the best |
hi, it seems there are still quite a bit of unaddressed comments. if you resolve those, i am more than happy to merge immediately. if in the meantime you need mesh/line intersections urgently you could use |
also, in the case of |
@tomvanmele this is meaningful work, but this has been sitting here for a long time... |
Hi I am the author,
This commits were result of the work I was doing at mesh 4 years ago. Due to covid, funds of mesh got shortened and I could not continue the project.
Now im doing a phd at DBT, and I would be delighted to finalise those commits and comments if you really think are a good contribution, but I have completely lost the environment and the code and everything.
If you were so kind, we could set a meeting, may be you could guide me through on how to set the working environment and everything properly and I will be delighted to finish the contribution applying all the comments that were done 4 years ago.
Best,
Nik Eftekhar Olivo
El 16.04.2024, a las 14:47, Jelle Feringa ***@***.***> escribió:
@tomvanmele<https://github.com/tomvanmele> this is meaningful work, but this has been sitting here for a long time...
Since the author hasn't responded to the excellent code review, I think its fair to close it.
—
Reply to this email directly, view it on GitHub<#569 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKK6EFS5JR3RF66EZEAS2F3Y5UMX7AVCNFSM4OGSN3MKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBVHEYDCMJUG4ZA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@nikeftekhar yep, let's do that, feel free to poke me directly in person, or send me a calendar invite to do this |
Hi Gonzalo,
Perfect then ill try to approach you during this week or the following
Best,
Nik
El 16.04.2024, a las 17:53, Gonzalo Casas ***@***.***> escribió:
we could set a meeting, may be you could guide me through on how to set the working environment and everything properly
@nikeftekhar<https://github.com/nikeftekhar> yep, let's do that, feel free to poke me directly in person, or send me a calendar invite to do this
—
Reply to this email directly, view it on GitHub<#569 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKK6EFUXTA47DJOKGMJJMG3Y5VCQXAVCNFSM4OGSN3MKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBVHE2DEMJSGY3A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
new functions regarding the following topics:
line divide by count
polyline shorten
polyline rebuild
polyline divide by count
polyline tween
transformations extend line
transformations extend polyline
intersection_mesh_line
intersection_mesh_plane
split polyline_plane
split mesh_plane
What type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas.datastructures.Mesh
.