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

Implement glue option and fuzzy tolerance in union #375

Merged
merged 6 commits into from
Jun 6, 2020

Conversation

adam-urbanczyk
Copy link
Member

@adam-urbanczyk adam-urbanczyk commented Jun 4, 2020

Will resolve #374 . It will also enable advanced users to apply the fuzzy bool ops (see #184 ).

@codecov
Copy link

codecov bot commented Jun 4, 2020

Codecov Report

Merging #375 into master will decrease coverage by 0.01%.
The diff coverage is 93.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
- Coverage   95.52%   95.50%   -0.02%     
==========================================
  Files          19       19              
  Lines        4777     4805      +28     
==========================================
+ Hits         4563     4589      +26     
- Misses        214      216       +2     
Impacted Files Coverage Δ
cadquery/occ_impl/shapes.py 91.81% <81.81%> (-0.18%) ⬇️
cadquery/cq.py 94.09% <100.00%> (ø)
tests/test_cadquery.py 99.22% <100.00%> (+0.01%) ⬆️

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 96a0406...e55b7ed. Read the comment docs.

@bragostin
Copy link
Contributor

For example consider the following example taken from Ex101 where interpPlates are unioned together:

# EXAMPLE 3
# Points on hexagonal pattern coordinates, use of pushpoints.
r1 = 1.0
N = 3
ca = cos(30.0 * pi / 180.0)
sa = sin(30.0 * pi / 180.0)
# EVEN ROWS
pts = [
    (-3.0, -3.0),
    (-1.267949, -3.0),
    (0.464102, -3.0),
    (2.196152, -3.0),
    (-3.0, 0.0),
    (-1.267949, 0.0),
    (0.464102, 0.0),
    (2.196152, 0.0),
    (-2.133974, -1.5),
    (-0.401923, -1.5),
    (1.330127, -1.5),
    (3.062178, -1.5),
    (-2.133975, 1.5),
    (-0.401924, 1.5),
    (1.330127, 1.5),
    (3.062178, 1.5),
]

# Spike surface
thickness = 0.1
fn = 6
edge_points = [
    [
        r1 * cos(i * 2 * pi / fn + 30 * pi / 180),
        r1 * sin(i * 2 * pi / fn + 30 * pi / 180),
    ]
    for i in range(fn + 1)
]
surface_points = [
    [
        r1 / 4 * cos(i * 2 * pi / fn + 30 * pi / 180),
        r1 / 4 * sin(i * 2 * pi / fn + 30 * pi / 180),
        0.75,
    ]
    for i in range(fn + 1)
] + [[0, 0, 2]]
edge_wire = cq.Workplane("XY").polyline(edge_points)
plate_3 = (
    cq.Workplane("XY")
    .pushPoints(pts)
    .interpPlate(
        edge_wire,
        surface_points,
        thickness,
        combine=False,
        clean=False,
        degree=2,
        nbPtsOnCur=20,
        nbIter=2,
        anisotropy=False,
        tol2d=0.00001,
        tol3d=0.0001,
        tolAng=0.01,
        tolCurv=0.1,
        maxDeg=8,
        maxSegments=9,
    )
)

# TODO

plate_3 = [o.vals()[0] for o in plate_3.all()]
print("plate_3 = ", plate_3)
plate_3 = cq.Compound.makeCompound(plate_3)
print("plate_3 = ", plate_3)
#plate_3.exportStep('plate_3.stp')
plate_3 = cq.Workplane("XY").union(cq.CQ(plate_3), glue=True, tol=1e-2)
plate_3.val().exportStep('plate_3.stp')

# TODO
print("plate_3.val().Volume() = ", plate_3.val().Volume())
plate_3 = plate_3.translate((0, 4 * 11, 0))
show_object(plate_3)

It crashes with standard union and also gluing without tolerance. However it works almost instantly with gluing and the Fuzzy tolerance set at 0.01.

@adam-urbanczyk adam-urbanczyk changed the title Implement glue option in union Implement glue option and fuzzy tolerance in union Jun 5, 2020
@adam-urbanczyk
Copy link
Member Author

I added the tol option @bragostin . Nice model BTW:
obraz

Copy link
Member

@jmwright jmwright left a comment

Choose a reason for hiding this comment

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

Looks good @adam-urbanczyk thanks for doing this!

cadquery/cq.py Show resolved Hide resolved
cadquery/occ_impl/shapes.py Show resolved Hide resolved
@adam-urbanczyk
Copy link
Member Author

Docstring is fixed, if CI passes the PR is ready for merging.

@jmwright jmwright merged commit f9fe7b1 into master Jun 6, 2020
@jmwright
Copy link
Member

jmwright commented Jun 6, 2020

@adam-urbanczyk I went ahead and merged since everything looked fine.

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.

Expose BRepAlgoAPI_Fuse.SetGlue in the union operation
3 participants