build123d icon indicating copy to clipboard operation
build123d copied to clipboard

Mirroring a face or wire can misplace wires and create invalid geometry

Open BlueDrink9 opened this issue 4 months ago • 2 comments

In this example instance, the mirrored face looks fine initially. But when negatively offset, part at the top crosses over and (seems to) create 3 new edges. The unmirrored face does not have this issue. image image

from build123d import *
with BuildLine() as bd_l:
    Line((108.58, 44.175), (108.58, 71.15))
    EllipticalCenterArc(
        center=Vector(69.713384900205, 69.625551596677, 0),
        x_radius=38.8965,
        y_radius=38.8965,
        start_angle=2.2461361800515647,
        end_angle=31.622711700698396,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    Line(Vector(102.8345, 90.0199, 0), (100.302, 94.2913))
    EllipticalCenterArc(
        center=Vector(98.640007202038, 93.239969652525, 0),
        x_radius=1.9666,
        y_radius=1.9666,
        start_angle=32.31630539456188,
        end_angle=122.9624926651918,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    EllipticalCenterArc(
        center=Vector(50.839924471056, 168.19990390158, 0),
        x_radius=86.937,
        y_radius=86.937,
        start_angle=-75.6480174141709,
        end_angle=-57.48526147396416,
        rotation=0.0,
        angular_direction=AngularDirection.CLOCKWISE
    )
    EllipticalCenterArc(
        center=Vector(2.0797538794043, 357.00186121216, 0),
        x_radius=281.9336,
        y_radius=281.9336,
        start_angle=-89.9431487602918,
        end_angle=-75.5588909320381,
        rotation=0.0,
        angular_direction=AngularDirection.CLOCKWISE
    )
    Line(Vector(2.3595000000001, 75.0684, 0), (2.085, 75.0659))
    EllipticalCenterArc(
        center=Vector(2.0499755879332, 73.065006516938, 0),
        x_radius=2.0012,
        y_radius=2.0012,
        start_angle=88.99717496834309,
        end_angle=177.9956279905412,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    Line(Vector(0.05, 73.135, 0), (0.0579, 18.8293))
    EllipticalCenterArc(
        center=Vector(3.9300371532193, 20.059959525075, 0),
        x_radius=4.063,
        y_radius=4.063,
        start_angle=-162.36847552288572,
        end_angle=-126.99757592507173,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    EllipticalCenterArc(
        center=Vector(46.458434118276, 68.788099999992, 0),
        x_radius=68.73,
        y_radius=68.73,
        start_angle=-130.87033625155783,
        end_angle=-90.00002844221156,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    Line(Vector(46.4584, 0.0581, 0), (50.4351, 0.0576))
    EllipticalCenterArc(
        center=Vector(43.142390071729, 143.89945027127, 0),
        x_radius=144.0266,
        y_radius=144.0266,
        start_angle=-87.09761770737784,
        end_angle=-69.05828449598486,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    EllipticalCenterArc(
        center=Vector(94.304900001699, 10.067150483852, 0),
        x_radius=0.75,
        y_radius=0.75,
        start_angle=-65.14857573001218,
        end_angle=-0.003856682207086237,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )
    Line(Vector(95.0549, 10.0671, 0), (95.035, 41.4891))
    EllipticalCenterArc(
        center=Vector(97.034975587933, 41.419106516938, 0),
        x_radius=2.0012,
        y_radius=2.0012,
        start_angle=88.997174968343,
        end_angle=177.9956279905412,
        rotation=0.0,
        angular_direction=AngularDirection.CLOCKWISE
    )
    Line(Vector(97.07, 43.42, 0), (107.83, 43.425000000000004))
    EllipticalCenterArc(
        center=Vector(107.83, 44.175, 0),
        x_radius=0.75,
        y_radius=0.75,
        start_angle=-90.0,
        end_angle=0.0,
        rotation=0.0,
        angular_direction=AngularDirection.COUNTER_CLOCKWISE
    )

edges = bd_l.edges()
# Edges are definitely connected
for i, edge in enumerate(edges):
    assert edges[i-1] @ 1 == edges[i] @ 0


face = make_face(bd_l.edges())
mirrored = mirror(face)
bad_face = offset(mirrored, -4)
good_face = offset(face, -4)

BlueDrink9 avatar Sep 30 '24 08:09 BlueDrink9