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

Free function api #1469

Merged
merged 63 commits into from
May 5, 2024
Merged

Free function api #1469

merged 63 commits into from
May 5, 2024

Conversation

adam-urbanczyk
Copy link
Member

@adam-urbanczyk adam-urbanczyk commented Dec 20, 2023

A free function API for cq.Shape. Originally inspired by #1269.

The idea is to provide a low-level but reasonably user friendly API for cq.Shape

  • primitives
  • operations
  • bool op as operators
  • moved with multiple locations
    • Overload for *locs
    • overload for moved(x=0, y=0, z=0, rx=0, ry=0, rz=0)
  • Location constructor improvements ?
  • additional factories ?
  • tests
  • docs

@adam-urbanczyk adam-urbanczyk marked this pull request as draft December 20, 2023 09:26
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Attention: Patch coverage is 99.23664% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 95.04%. Comparing base (99792e5) to head (066795c).
Report is 2 commits behind head on master.

Files Patch % Lines
cadquery/occ_impl/shapes.py 99.18% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1469      +/-   ##
==========================================
+ Coverage   94.54%   95.04%   +0.49%     
==========================================
  Files          28       28              
  Lines        5848     7202    +1354     
  Branches     1166     1572     +406     
==========================================
+ Hits         5529     6845    +1316     
- Misses        193      224      +31     
- Partials      126      133       +7     

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

@adam-urbanczyk adam-urbanczyk added cq.Shape enhancement New feature or request labels Jan 20, 2024
@adam-urbanczyk
Copy link
Member Author

@lorenzncode will you have bandwidth/interest to look at this?

@lorenzncode
Copy link
Member

@adam-urbanczyk Yes, at first glance this looks very interesting. I'll find some time to take a look.

@lorenzncode
Copy link
Member

I started experimenting. It seems very easy to use! Can revolve be changed to accept Shell?

    # https://groups.google.com/g/cadquery/c/B-9w-U3gs1M/m/YhwbkMYPCAAJ
    from cadquery.occ_impl.shapes import spline, loft, revolve

    pts0 = [(1, 1, 0), (1, 1, 1), (1.2, 0.7483, 2)]
    pts1 = [(2, 2, 0), (2, 2, 1), (2.2, 1.7776, 2)]
    edge0 = spline(pts0)
    edge1 = spline(pts1)

    sh0 = loft([edge0, edge1])
    result = revolve(sh0, pts0[0], pts1[0], 180) # changed revolve _get Shell

test_free_api_jupyter.zip

@adam-urbanczyk
Copy link
Member Author

I added shape normalization. For your example loft returns Face instead of Shell.

@adam-urbanczyk adam-urbanczyk marked this pull request as ready for review April 21, 2024 18:07
@adam-urbanczyk
Copy link
Member Author

I think it is ready for a fist pass. Take a look at the new doc section to get a glimpse.

@lorenzncode
Copy link
Member

Very exciting new CQ development! I checked out the branch and started trying it out. Will play around with it more.

cadquery/occ_impl/shapes.py Show resolved Hide resolved
cadquery/occ_impl/shapes.py Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
doc/free-func.rst Outdated Show resolved Hide resolved
doc/free-func.rst Show resolved Hide resolved
doc/free-func.rst Outdated Show resolved Hide resolved
mypy/cadquery-plugin.py Outdated Show resolved Hide resolved
mypy/cadquery-plugin.py Outdated Show resolved Hide resolved
@jmwright
Copy link
Member

Thanks for all the work on this @adam-urbanczyk ! The examples run fine for me, and the code looks good.

Either in this PR or a separate PR, we will also need to update setup.py for the new multimethod version declaration. With version 1.9.1 I get an intermittent error. This means we will probably see some support issues after the next release where people did not upgrade their multimethod version or create a fresh environment.

@adam-urbanczyk
Copy link
Member Author

OK, I think I resolved all the points. Let me know if you are OK with merging.

Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

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

I've added few comments on docs/docstrings after proofreading.

doc/free-func.rst Outdated Show resolved Hide resolved
doc/free-func.rst Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
@lorenzncode
Copy link
Member

Thank you for the new API!

@jmwright
Copy link
Member

jmwright commented May 5, 2024

+1 to merge

@adam-urbanczyk adam-urbanczyk merged commit 995d139 into master May 5, 2024
6 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.

3 participants