Skip to content

Commit 018f4e6

Browse files
committed
fix: verify intersect failure has been solved
1 parent 9368e14 commit 018f4e6

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/integration/test_issues.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,48 @@ def test_issue_1309_revolve_operation_with_coincident_origins(modeler: Modeler):
224224
)
225225

226226
assert revolved_body.name == "toroid"
227+
228+
229+
def test_issue_1724_intersect_failures(modeler: Modeler):
230+
"""Test that intersecting two bodies that overlap does not crash the program.
231+
232+
For more info see
233+
https://github.com/ansys/pyansys-geometry/issues/1724
234+
"""
235+
wx = 10
236+
wy = 10
237+
wz = 2
238+
radius = 1
239+
unit = DEFAULT_UNITS.LENGTH
240+
241+
design = modeler.create_design("Test")
242+
243+
start_at = Point3D([wx / 2, wy / 2, 0.0], unit=unit)
244+
245+
plane = Plane(
246+
start_at,
247+
UNITVECTOR3D_X,
248+
UNITVECTOR3D_Y,
249+
)
250+
box_plane = Sketch(plane)
251+
box_plane.box(Point2D([0.0, 0.0], unit=unit), width=wx, height=wy)
252+
253+
box = design.extrude_sketch("box", box_plane, wz)
254+
255+
point = Point3D([wx / 2, wx / 2, 0.0], unit=unit)
256+
plane = Plane(point, UNITVECTOR3D_X, UNITVECTOR3D_Y)
257+
sketch_cylinder = Sketch(plane)
258+
sketch_cylinder.circle(Point2D([0.0, 0.0], unit=unit), radius=radius)
259+
cylinder = design.extrude_sketch("cylinder", sketch_cylinder, wz)
260+
261+
# Store the cylinder volume
262+
cylinder_volume = cylinder.volume
263+
264+
# Request the intersection
265+
cylinder.intersect(box)
266+
267+
# Only the cylinder should be present
268+
assert len(design.bodies) == 1
269+
assert design.bodies[0].name == "cylinder"
270+
# Verify that the volume of the cylinder is the same
271+
assert design.bodies[0].volume == cylinder_volume

0 commit comments

Comments
 (0)