Skip to content

Commit 41ac3ee

Browse files
test: verifying issue with empty intersect and temporal body creation (#1258)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent c9d691f commit 41ac3ee

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

doc/changelog.d/1258.test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
verifying issue with empty intersect and temporal body creation

tests/integration/test_design_import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
251251
# IGES
252252
#
253253
# TODO: Something has gone wrong with IGES
254-
# https://github.com/ansys/pyansys-geometry/issues/801
255-
254+
# https://github.com/ansys/pyansys-geometry/issues/1146
255+
#
256256
# file = tmp_path_factory.mktemp("test_design_import") / "two_cars.igs"
257257
# design.download(file, DesignFileFormat.IGES)
258258
# design2 = modeler.open_file(file)

tests/integration/test_issues.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,51 @@ def test_issue_1304_arc_sketch_creation():
139139
DEFAULT_UNITS.LENGTH = UNITS.meter
140140

141141

142+
def test_issue_1192_temp_body_on_empty_intersect(modeler: Modeler):
143+
"""Test demonstrating the issue when intersecting two bodies that do not intersect
144+
and the empty temporal body that gets created."""
145+
# When attempting to intersect two bodies that do not intersect, no body should be
146+
# created. However, in the past, a temporary body was created and added to the
147+
# component. This test checks if this issue has been resolved.
148+
design = modeler.create_design("temp-body-intersect-issue")
149+
150+
# Create two bodies that do not intersect
151+
plane = Plane(
152+
Point3D([1 / 2, 1 / 2, 0.0]),
153+
UNITVECTOR3D_X,
154+
UNITVECTOR3D_Y,
155+
)
156+
matrix_plane = Sketch(plane)
157+
matrix_plane.box(Point2D([0.0, 0.0]), width=1, height=1)
158+
matrix = design.extrude_sketch("Matrix", matrix_plane, 1)
159+
160+
p = Point3D([1.0, 1.0, 1.5])
161+
plane = Plane(p, UNITVECTOR3D_X, UNITVECTOR3D_Y)
162+
sketch_fibres = Sketch(plane)
163+
sketch_fibres.circle(Point2D([0.0, 0.0]), radius=0.5)
164+
fibre = design.extrude_sketch("fibre", sketch_fibres, 1)
165+
166+
# Attempt intersection - which fails and thus deletes copy
167+
matrix_copy = matrix.copy(design)
168+
try:
169+
fibre.intersect(matrix_copy)
170+
except Exception:
171+
design.delete_body(matrix_copy)
172+
173+
# No intersection took place... so no body should be created
174+
# Let's read the design and check that only the two bodies are present
175+
read_design = modeler.read_existing_design()
176+
177+
# Verify the design
178+
assert len(read_design.bodies) == 2
179+
assert len(read_design.bodies) == 2
180+
assert len(read_design.bodies[0].faces) == 6
181+
assert len(read_design.bodies[1].faces) == 3
182+
assert read_design.bodies[0].name == "Matrix"
183+
assert read_design.bodies[1].name == "fibre"
184+
assert len(read_design.components) == 0
185+
186+
142187
def test_issue_1309_revolve_operation_with_coincident_origins(modeler: Modeler):
143188
"""Test that revolving a sketch with coincident origins (sketch and rotation origin)
144189
does not crash the program.

0 commit comments

Comments
 (0)