mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 10:41:20 -08:00
Fixed intersections of Axis Issue #615
This commit is contained in:
parent
4561105666
commit
2c40e19141
2 changed files with 20 additions and 8 deletions
|
|
@ -584,9 +584,10 @@ class Mixin1D:
|
||||||
# Shorten any infinite lines (from converted Axis)
|
# Shorten any infinite lines (from converted Axis)
|
||||||
normal_lines = list(filter(lambda line: line.length <= 1e50, all_lines))
|
normal_lines = list(filter(lambda line: line.length <= 1e50, all_lines))
|
||||||
infinite_lines = filter(lambda line: line.length > 1e50, all_lines)
|
infinite_lines = filter(lambda line: line.length > 1e50, all_lines)
|
||||||
shortened_lines = [
|
# shortened_lines = [
|
||||||
l.trim(0.4999999999, 0.5000000001) for l in infinite_lines
|
# l.trim(0.4999999999, 0.5000000001) for l in infinite_lines
|
||||||
]
|
# ]
|
||||||
|
shortened_lines = [l.trim_to_length(0.5, 10) for l in infinite_lines]
|
||||||
all_lines = normal_lines + shortened_lines
|
all_lines = normal_lines + shortened_lines
|
||||||
|
|
||||||
for line in all_lines:
|
for line in all_lines:
|
||||||
|
|
@ -4563,17 +4564,18 @@ class Edge(Mixin1D, Shape):
|
||||||
crosses = [plane.from_local_coords(p) for p in crosses]
|
crosses = [plane.from_local_coords(p) for p in crosses]
|
||||||
|
|
||||||
# crosses may contain points beyond the ends of the edge so
|
# crosses may contain points beyond the ends of the edge so
|
||||||
# filter those out (a param_at problem?)
|
# .. filter those out
|
||||||
valid_crosses = []
|
valid_crosses = []
|
||||||
for pnt in crosses:
|
for pnt in crosses:
|
||||||
try:
|
try:
|
||||||
if edge is not None:
|
if edge is not None:
|
||||||
if (-tolerance <= self.param_at_point(pnt) <= 1.0 + tolerance) and (
|
if (
|
||||||
-tolerance <= edge.param_at_point(pnt) <= 1.0 + tolerance
|
self.distance_to(pnt) <= TOLERANCE
|
||||||
|
and edge.distance_to(pnt) <= TOLERANCE
|
||||||
):
|
):
|
||||||
valid_crosses.append(pnt)
|
valid_crosses.append(pnt)
|
||||||
else:
|
else:
|
||||||
if -tolerance <= self.param_at_point(pnt) <= 1.0 + tolerance:
|
if self.distance_to(pnt) <= TOLERANCE:
|
||||||
valid_crosses.append(pnt)
|
valid_crosses.append(pnt)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass # skip invalid points
|
pass # skip invalid points
|
||||||
|
|
@ -8675,7 +8677,7 @@ def _axis_intersect(self: Axis, *to_intersect: Union[Shape, Axis, Plane]) -> Sha
|
||||||
# Check if there is an intersection point
|
# Check if there is an intersection point
|
||||||
if int_cs.NbPoints() > 0:
|
if int_cs.NbPoints() > 0:
|
||||||
intersections.append(Vertex(*Vector(int_cs.Point(1)).to_tuple()))
|
intersections.append(Vertex(*Vector(int_cs.Point(1)).to_tuple()))
|
||||||
if isinstance(intersector, Shape):
|
elif isinstance(intersector, Shape):
|
||||||
intersections.extend(self_i_edge.intersect(intersector))
|
intersections.extend(self_i_edge.intersect(intersector))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -317,6 +317,16 @@ class TestAxis(DirectApiTestCase):
|
||||||
intersection = Axis((1, 2, 3), (0, 0, 1)) & Plane.XY
|
intersection = Axis((1, 2, 3), (0, 0, 1)) & Plane.XY
|
||||||
self.assertTupleAlmostEquals(intersection.to_tuple(), (1, 2, 0), 5)
|
self.assertTupleAlmostEquals(intersection.to_tuple(), (1, 2, 0), 5)
|
||||||
|
|
||||||
|
arc = Edge.make_circle(20, start_angle=0, end_angle=180)
|
||||||
|
ax0 = Axis((-20, 30, 0), (4, -3, 0))
|
||||||
|
intersections = arc.intersect(ax0).vertices().sort_by(Axis.X)
|
||||||
|
self.assertTupleAlmostEquals(tuple(intersections[0]), (-5.6, 19.2, 0), 5)
|
||||||
|
self.assertTupleAlmostEquals(tuple(intersections[1]), (20, 0, 0), 5)
|
||||||
|
|
||||||
|
intersections = ax0.intersect(arc).vertices().sort_by(Axis.X)
|
||||||
|
self.assertTupleAlmostEquals(tuple(intersections[0]), (-5.6, 19.2, 0), 5)
|
||||||
|
self.assertTupleAlmostEquals(tuple(intersections[1]), (20, 0, 0), 5)
|
||||||
|
|
||||||
# TODO: uncomment when generalized edge to surface intersections are complete
|
# TODO: uncomment when generalized edge to surface intersections are complete
|
||||||
# non_planar = (
|
# non_planar = (
|
||||||
# Solid.make_cylinder(1, 10).faces().filter_by(GeomType.PLANE, reverse=True)
|
# Solid.make_cylinder(1, 10).faces().filter_by(GeomType.PLANE, reverse=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue