Skip to content

When fusing two Faces, in some cases (esp. hull result) the internal edges cannot be removed. #1891

@huskier

Description

@huskier

The following code can successfully fuse two Faces and remove the internal edges;

Image
from cadquery.hull import find_hull
from cadquery.func import *
from cadquery.vis import show

base_face = face(rect(w=64, h=75))
print(type(base_face))
show(base_face)

moved_face = face(rect(40, 40).moved(Location(44, 0, 0)))

combined = base_face + moved_face
print(type(combined))

combined = combined.clean()
show(combined)

however, the code below cannot remove the internal edges.

Image
from cadquery.hull import find_hull
from cadquery.func import *
from cadquery.vis import show

base_face = face(rect(w=64, h=75))

print(type(base_face))
show(base_face)

moved_square = rect(40, 40).moved(Location(44, 0, 0))
moved_circle = circle(20).moved(Location(82, 0, 0))

hull_shapes = moved_square + moved_circle
hull_edges = hull_shapes.Edges()
hull_wire = find_hull(hull_edges)
hull_face = face(hull_wire)

print(type(hull_face))
show(hull_face)

#combined_face = base_face + hull_face
combined_face = base_face.fuse(hull_face)
combined_face = combined_face.clean()

print(type(combined_face))
show(combined_face)

The difference between the two pieces of code is that in the working case, a base_face is fused with a simple rectangular face, while in the non-working case, the base_face is fused with a face obtained through a hull operation.

After thorough debugging, we are confident that the issue stems from the hull operation. The following code presents an alternative implementation that eliminates the use of hull entirely.

Image
from cadquery.hull import find_hull
from cadquery.func import *
from cadquery.vis import show

base_face = face(rect(w=64, h=75))

moved_square = rect(58, 40).moved(Location(53, 0, 0))
moved_circle = circle(20).moved(Location(82, 0, 0))
face_wo_hull = face(moved_square) + face(moved_circle)

combined_face = base_face + face_wo_hull

show(combined_face)

combined_face = combined_face.clean()

print(type(combined_face))
show(combined_face)

Environment

We are on Windows 11 with CadQuery 2.4.0 under Anaconda environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions