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

test: verifying issue with empty intersect and temporal body creation #1258

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/1258.test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
verifying issue with empty intersect and temporal body creation
4 changes: 2 additions & 2 deletions tests/integration/test_design_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def test_open_file(modeler: Modeler, tmp_path_factory: pytest.TempPathFactory):
# IGES
#
# TODO: Something has gone wrong with IGES
# https://github.com/ansys/pyansys-geometry/issues/801

# https://github.com/ansys/pyansys-geometry/issues/1146
#
# file = tmp_path_factory.mktemp("test_design_import") / "two_cars.igs"
# design.download(file, DesignFileFormat.IGES)
# design2 = modeler.open_file(file)
Expand Down
45 changes: 45 additions & 0 deletions tests/integration/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,51 @@ def test_issue_1304_arc_sketch_creation():
DEFAULT_UNITS.LENGTH = UNITS.meter


def test_issue_1192_temp_body_on_empty_intersect(modeler: Modeler):
"""Test demonstrating the issue when intersecting two bodies that do not intersect
and the empty temporal body that gets created."""
# When attempting to intersect two bodies that do not intersect, no body should be
# created. However, in the past, a temporary body was created and added to the
# component. This test checks if this issue has been resolved.
design = modeler.create_design("temp-body-intersect-issue")

# Create two bodies that do not intersect
plane = Plane(
Point3D([1 / 2, 1 / 2, 0.0]),
UNITVECTOR3D_X,
UNITVECTOR3D_Y,
)
matrix_plane = Sketch(plane)
matrix_plane.box(Point2D([0.0, 0.0]), width=1, height=1)
matrix = design.extrude_sketch("Matrix", matrix_plane, 1)

p = Point3D([1.0, 1.0, 1.5])
plane = Plane(p, UNITVECTOR3D_X, UNITVECTOR3D_Y)
sketch_fibres = Sketch(plane)
sketch_fibres.circle(Point2D([0.0, 0.0]), radius=0.5)
fibre = design.extrude_sketch("fibre", sketch_fibres, 1)

# Attempt intersection - which fails and thus deletes copy
matrix_copy = matrix.copy(design)
try:
fibre.intersect(matrix_copy)
except Exception:
design.delete_body(matrix_copy)

# No intersection took place... so no body should be created
# Let's read the design and check that only the two bodies are present
read_design = modeler.read_existing_design()

# Verify the design
assert len(read_design.bodies) == 2
assert len(read_design.bodies) == 2
assert len(read_design.bodies[0].faces) == 6
assert len(read_design.bodies[1].faces) == 3
assert read_design.bodies[0].name == "Matrix"
assert read_design.bodies[1].name == "fibre"
assert len(read_design.components) == 0


def test_issue_1309_revolve_operation_with_coincident_origins(modeler: Modeler):
"""Test that revolving a sketch with coincident origins (sketch and rotation origin)
does not crash the program.
Expand Down
Loading