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

Radius selector #504

Merged
merged 4 commits into from
Nov 20, 2020
Merged

Radius selector #504

merged 4 commits into from
Nov 20, 2020

Conversation

marcus7070
Copy link
Member

Will close #501.


I've added an Edge.radius method to get the radius of a circular edge.

The method uses _geomAdaptor().Circle(). When I used that code on a elipse, I got the kernel (7.4.0) to segfault. So I've restricted the method to just objects with geomType() == "CIRCLE" to be safe.


I've added a RadiusSelector in the style of DirectionNthSelector.

I didn't add RadiusSelector to the string selector interface.

While I added it to the HTML docs, about half the selectors are not in the top level module and they don't show up due to #493.

@jmwright
Copy link
Member

Thanks for working on this @marcus7070

@adam-urbanczyk The errors with Travis, Appveyor and the doc builds seem to be related to font/text capability. Items like this:

ImportError: cannot import name 'Font_BRepTextBuilder'

Did something change with the deployed versions of OCP? Maybe related to the 7.5 beta?

@adam-urbanczyk
Copy link
Member

Indeed @jmwright , should be fine now.

@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #504 (821886f) into master (28d6089) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #504      +/-   ##
==========================================
+ Coverage   93.74%   93.81%   +0.07%     
==========================================
  Files          30       30              
  Lines        5994     6067      +73     
  Branches      636      637       +1     
==========================================
+ Hits         5619     5692      +73     
  Misses        237      237              
  Partials      138      138              
Impacted Files Coverage Δ
cadquery/occ_impl/shapes.py 91.30% <100.00%> (+0.07%) ⬆️
cadquery/selectors.py 99.17% <100.00%> (+0.07%) ⬆️
tests/test_cad_objects.py 99.10% <100.00%> (+0.11%) ⬆️
tests/test_selectors.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28d6089...821886f. Read the comment docs.

@jmwright
Copy link
Member

All green now.

@marcus7070 I'm assuming this is ready for review now?

@marcus7070
Copy link
Member Author

Yes, ready for review @jmwright.

cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/selectors.py Outdated Show resolved Hide resolved
@marcus7070 marcus7070 force-pushed the marcus7070/edgeRadius branch 2 times, most recently from 692888d to 41b0e83 Compare November 18, 2020 07:04
@marcus7070
Copy link
Member Author

So I think when you request the radius of a Wire with multiple Edges, OCCT just takes the radius of the first Edge and calls it a day. You can see code regarding this in test_cad_objects.py. This was pretty unexpected for me, so I've mentioned it in the radius docstring.

It wouldn't be too hard to do some more logic in the radius method. We could grab the radius of every edge in a wire, and if they are all within a tolerance return the average value as the radius, otherwise raise ValueError. But I've stuck with the OCCT logic for now. Let me know if you have opinions either way.

Copy link
Member

@adam-urbanczyk adam-urbanczyk left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

@adam-urbanczyk
Copy link
Member

@jmwright are OK with merging this PR?

@jmwright
Copy link
Member

Thanks @marcus7070 ! This is a great addition to the selectors.

@jmwright jmwright merged commit 78d100d into CadQuery:master Nov 20, 2020
@marcus7070 marcus7070 mentioned this pull request Nov 21, 2020
@marcus7070 marcus7070 deleted the marcus7070/edgeRadius branch November 21, 2020 06:56
@jmwright jmwright mentioned this pull request Nov 27, 2020
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.

Radius selector
3 participants