Skip to content

Small fixes#1472

Merged
tomvanmele merged 8 commits intomainfrom
fix-polyhedron-discretisation
Jun 4, 2025
Merged

Small fixes#1472
tomvanmele merged 8 commits intomainfrom
fix-polyhedron-discretisation

Conversation

@tomvanmele
Copy link
Copy Markdown
Member

  • fixed context detection (default should be None and not Viewer)
  • fixed discretisation of polyhedron into edges (when data comes from numpy)
  • fixed graph construction from pointcloud which used degree parameter in nonsensical way
  • added isocurve_u and isocurve_v for spherical and cylindrical surfaces

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 51.21951% with 20 lines in your changes missing coverage. Please review.

Project coverage is 61.93%. Comparing base (bac708f) to head (c13e0e4).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/compas/geometry/surfaces/spherical.py 14.28% 12 Missing ⚠️
src/compas/geometry/surfaces/cylindrical.py 30.00% 7 Missing ⚠️
src/compas/rpc/dispatcher.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1472      +/-   ##
==========================================
- Coverage   61.98%   61.93%   -0.05%     
==========================================
  Files         208      208              
  Lines       22394    22427      +33     
==========================================
+ Hits        13880    13890      +10     
- Misses       8514     8537      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@gonzalocasas gonzalocasas left a comment

Choose a reason for hiding this comment

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

generally lgtm except the scary commented out context code. The other things are more like an open question

Comment on lines +166 to +197
def isocurve_u(self, u):
"""Compute the isoparametric curve at parameter u.

Parameters
----------
u : float

Returns
-------
:class:`compas.geometry.Line`

"""
base = self.point_at(u=u, v=0.5)
return Line.from_point_direction_length(base, self.frame.zaxis, 1.0)

def isocurve_v(self, v):
"""Compute the isoparametric curve at parameter v.

Parameters
----------
v : float

Returns
-------
:class:`compas.geometry.Circle`

"""
point = self.center + self.frame.zaxis * v
xaxis = self.frame.xaxis
yaxis = self.frame.yaxis
frame = Frame(point, xaxis, yaxis)
return Circle(radius=self.radius, frame=frame)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand the logical reason for returning Circle and Line, but wouldn't make more sense to return Curve instances always? That way both _u and _v would be symmetrical and also this API would be consistent with the one of Surface

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we don't have a functional general curve

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

afaik that is also not possible. you need a way to evaluate the curve and this depends on the type of curve it is...

Comment thread tests/compas/geometry/test_polyhedron.py
Comment on lines +115 to +117
# other_contexts = [v for v in ITEM_SCENEOBJECT.keys()]
# if other_contexts:
# return other_contexts[0]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks dangerous to commit, isn't that going to break stuff, like the viewer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

viewer and notebook set the context explicitly so they are unaffected. the fact that we return the viewer instead of none is just by coincidence and actually masks bugs and creates unpredictable behavior

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just to confirm, I did few tests with viewer too they are not affected

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good, then let's delete instead of comment out

Comment on lines +194 to +230
def isocurve_u(self, u):
"""Compute the isoparametric curve at parameter u.

Parameters
----------
u : float

Returns
-------
:class:`compas.geometry.Circle`

"""
origin = self.center
xaxis = self.point_at(u=u, v=0) - origin
yaxis = self.point_at(u=u, v=0.25) - origin
frame = Frame(origin, xaxis, yaxis)
return Circle(radius=xaxis.length, frame=frame)

def isocurve_v(self, v):
"""Compute the isoparametric curve at parameter v.

Parameters
----------
v : float

Returns
-------
:class:`compas.geometry.Circle`

"""
x = self.point_at(u=0, v=v)
y = self.point_at(u=0.25, v=v)
origin = self.center + self.frame.zaxis * (x - self.center).dot(self.frame.zaxis)
xaxis = x - origin
yaxis = y - origin
frame = Frame(origin, xaxis, yaxis)
return Circle(radius=xaxis.length, frame=frame)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment here about aligning these methods to a unified API that returns Curve always

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is not possible because the base curve class just defines an api but no functionality

Comment thread src/compas/datastructures/graph/graph.py Outdated
Copy link
Copy Markdown
Member Author

@tomvanmele tomvanmele left a comment

Choose a reason for hiding this comment

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

apparently i started a review so i have to leave a comment to submit my comments :)

@tomvanmele tomvanmele merged commit 927a4e4 into main Jun 4, 2025
19 of 21 checks passed
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

Successfully merging this pull request may close these issues.

3 participants