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

Fillet Fails on Simple 2D Geometry, Succeeds in 3D #720

Open
ZacharyKF opened this issue Sep 30, 2024 · 2 comments
Open

Fillet Fails on Simple 2D Geometry, Succeeds in 3D #720

ZacharyKF opened this issue Sep 30, 2024 · 2 comments
Labels
enhancement New feature or request occt A bug with the OpenCascade CAD core

Comments

@ZacharyKF
Copy link

First here's the minimal example:

from build123d import *

# Simplest form of the face
box = Spline((-10, 1), (0, 0), (10, 1)).offset_2d(1, side=Side.LEFT, closed=False)
box = (
    Line(box @ 0, (box @ 0) - Vector(0, 5))
    + box
    + Line(box @ 1, (box @ 1) - Vector(0, 5))
)
box = make_face(box + Line(box @ 0, box @ 1)) + Location((0, 2.5)) * Rectangle(3, 5)

# Showing the vertex selection works
verts = box.vertices().sort_by_distance((0, 0))[0:2]

# Trying to fillet, these won't work
# edges = box.edges().sort_by_distance(verts[0])[0:2]
# box.max_fillet(edges)
# box = fillet(edges, 0.1)

from ocp_vscode import show, set_defaults, Camera, set_port

set_port(3939)
set_defaults(reset_camera=Camera.KEEP, ortho=True, black_edges=True)
show(box, verts)

Jern pointed out that it works in 3D:

threed = extrude(box,amount=1)
edges2 = threed.edges().filter_by(Axis.Z).sort_by_distance(verts[0])[0:2]
threed = fillet(edges2,1)
@gumyr
Copy link
Owner

gumyr commented Oct 2, 2024

The problem appears to be related to the spine as shown by these examples:

with BuildSketch() as fail:
    with BuildLine() as outline:
        l1 = Spline((-10, 2), (0, 1), (10, 2))
        l2 = Polyline(l1 @ 0, (-10, 0), (10, 0), l1 @ 1)
    make_face()
    Rectangle(3, 5, align=(Align.CENTER, Align.MIN))
    verts = fail.vertices().sort_by_distance((0, 0))[0:2]
    # fillet(verts, 1)

with BuildSketch() as pass1:
    Rectangle(10, 2, align=(Align.CENTER, Align.MIN))
    with Locations((0, 20)):
        Circle(19, mode=Mode.SUBTRACT)
    Rectangle(3, 5, align=(Align.CENTER, Align.MIN))
    # Trapezoid(3, 5, 95, align=(Align.CENTER, Align.MIN))
    verts = pass1.vertices().sort_by_distance((0, 0))[0:2]
    fillet(verts, 1)

with BuildSketch() as pass2:
    Rectangle(10, 2, align=(Align.CENTER, Align.MIN))
    Trapezoid(3, 5, 95, align=(Align.CENTER, Align.MIN))
    verts = pass2.vertices().sort_by_distance((0, 0))[0:2]
    fillet(verts, 1)

OCCT is refusing to fillet the spline which admittedly is a much more difficult shape to work with. Determining where the circle of the fillet meets the spline requires the search algorithm that is present in the DoubleTangentArc object.

To fix this build123d would have to identify that one or more of the edges is a complex curve (splines, bezier curves, etc.) and implement the fillet itself possibly using the DoubleTangentArc.

@gumyr gumyr added occt A bug with the OpenCascade CAD core enhancement New feature or request labels Oct 2, 2024
@gumyr gumyr added this to the Not Gating Release 1.0.0 milestone Oct 2, 2024
@gumyr
Copy link
Owner

gumyr commented Oct 2, 2024

An alternative fix may be to attempt a 3D fillet and extract the appropriate 2D shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request occt A bug with the OpenCascade CAD core
Projects
None yet
Development

No branches or pull requests

2 participants