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

feat: enable prepare and repair tools in Core Service #1580

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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/1580.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable prepare and repair tools in Core Service
10 changes: 5 additions & 5 deletions src/ansys/geometry/core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ def __init__(
# TODO: delete "if" when Linux service is able to use repair tools
# https://github.com/ansys/pyansys-geometry/issues/1319
if self.client.backend_type == BackendType.LINUX_SERVICE:
self._repair_tools = None
self._prepare_tools = None
self._measurement_tools = None
LOG.warning("Linux backend does not support repair or prepare tools.")
LOG.warning("Linux backend does not support measurement tools.")
else:
self._repair_tools = RepairTools(self._grpc_client)
self._prepare_tools = PrepareTools(self._grpc_client)
self._measurement_tools = MeasurementTools(self._grpc_client)

# Enabling tools for all: repair and prepare tools
self._repair_tools = RepairTools(self._grpc_client)
self._prepare_tools = PrepareTools(self._grpc_client)

# Maintaining references to all designs within the modeler workspace
self._designs: dict[str, "Design"] = {}

Expand Down
9 changes: 1 addition & 8 deletions tests/integration/test_prepare_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@

from ansys.geometry.core.modeler import Modeler

from .conftest import FILES_DIR, skip_if_linux
from .conftest import FILES_DIR


def test_volume_extract_from_faces(modeler: Modeler):
"""Test a volume is created from the provided faces."""
skip_if_linux(
modeler, test_volume_extract_from_faces.__name__, "prepare_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "hollowCylinder.scdocx")

body = design.bodies[0]
Expand All @@ -43,9 +40,6 @@ def test_volume_extract_from_faces(modeler: Modeler):

def test_volume_extract_from_edge_loops(modeler: Modeler):
"""Test a volume is created from the provided edges."""
skip_if_linux(
modeler, test_volume_extract_from_edge_loops.__name__, "prepare_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "hollowCylinder.scdocx")

body = design.bodies[0]
Expand All @@ -59,7 +53,6 @@ def test_volume_extract_from_edge_loops(modeler: Modeler):

def test_share_topology(modeler: Modeler):
"""Test share topology operation is between two bodies."""
skip_if_linux(modeler, test_share_topology.__name__, "prepare_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "MixingTank.scdocx")

assert modeler.prepare_tools.share_topology(design.bodies)
44 changes: 1 addition & 43 deletions tests/integration/test_repair_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,39 @@

from ansys.geometry.core.modeler import Modeler

from .conftest import FILES_DIR, skip_if_linux
from .conftest import FILES_DIR


def test_find_split_edges(modeler: Modeler):
"""Test if split edge problem areas are detectable."""
skip_if_linux(modeler, test_find_split_edges.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SplitEdgeDesignTest.scdocx")
problem_areas = modeler.repair_tools.find_split_edges(design.bodies, 25, 150)
assert len(problem_areas) == 3


def test_find_split_edge_id(modeler: Modeler):
"""Test whether problem area has the id."""
skip_if_linux(modeler, test_find_split_edge_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SplitEdgeDesignTest.scdocx")
problem_areas = modeler.repair_tools.find_split_edges(design.bodies, 25, 150)
assert problem_areas[0].id != "0"


def test_find_split_edge_edges(modeler: Modeler):
"""Test to find split edge problem areas with the connected edges."""
skip_if_linux(
modeler, test_find_split_edge_edges.__name__, "repair_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SplitEdgeDesignTest.scdocx")
problem_areas = modeler.repair_tools.find_split_edges(design.bodies, 25, 150)
assert len(problem_areas[0].edges) > 0


def test_fix_split_edge(modeler: Modeler):
"""Test to find and fix split edge problem areas."""
skip_if_linux(modeler, test_fix_split_edge.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SplitEdgeDesignTest.scdocx")
problem_areas = modeler.repair_tools.find_split_edges(design.bodies, 25, 150)
assert problem_areas[0].fix().success is True


def test_find_extra_edges(modeler: Modeler):
"""Test to read geometry and find it's extra edge problem areas."""
skip_if_linux(modeler, test_find_extra_edges.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "ExtraEdgesDesignBefore.scdocx")

problem_areas = modeler.repair_tools.find_extra_edges(design.bodies)
Expand All @@ -73,7 +66,6 @@ def test_find_extra_edges(modeler: Modeler):

def test_find_extra_edge_id(modeler: Modeler):
"""Test whether problem area has the id."""
skip_if_linux(modeler, test_find_extra_edge_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "ExtraEdgesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_extra_edges(design.bodies)
assert problem_areas[0].id != "0"
Expand All @@ -83,9 +75,6 @@ def test_find_extra_edge_edges(modeler: Modeler):
"""Test to read geometry and find it's extra edge problem area with
connected edges.
"""
skip_if_linux(
modeler, test_find_extra_edge_edges.__name__, "repair_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "ExtraEdgesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_extra_edges(design.bodies)
assert len(problem_areas[0].edges) > 0
Expand All @@ -94,23 +83,20 @@ def test_find_extra_edge_edges(modeler: Modeler):
@pytest.mark.skip(reason="This test is failing on the Geometry Service - issue 1335")
def test_fix_extra_edge(modeler: Modeler):
"""Test to find and fix extra edge problem areas."""
skip_if_linux(modeler, test_fix_extra_edge.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "ExtraEdgesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_extra_edges(design.bodies)
assert problem_areas[0].fix().success is True


def test_find_inexact_edges(modeler: Modeler):
"""Test to read geometry and find it's inexact edge problem areas."""
skip_if_linux(modeler, test_find_inexact_edges.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "InExactEdgesBefore.scdocx")
problem_areas = modeler.repair_tools.find_inexact_edges(design.bodies)
assert len(problem_areas) == 12


def test_find_inexact_edge_id(modeler: Modeler):
"""Test whether problem area has the id."""
skip_if_linux(modeler, test_find_inexact_edge_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "InExactEdgesBefore.scdocx")
problem_areas = modeler.repair_tools.find_inexact_edges(design.bodies)
assert problem_areas[0].id != "0"
Expand All @@ -120,9 +106,6 @@ def test_find_inexact_edge_edges(modeler: Modeler):
"""Test to read geometry and find it's inexact edge problem areas with
connected edges.
"""
skip_if_linux(
modeler, test_find_inexact_edge_edges.__name__, "repair_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "InExactEdgesBefore.scdocx")
problem_areas = modeler.repair_tools.find_inexact_edges(design.bodies)
assert len(problem_areas[0].edges) > 0
Expand All @@ -132,23 +115,20 @@ def test_fix_inexact_edge(modeler: Modeler):
"""Test to read geometry and find and fix it's inexact edge problem
areas.
"""
skip_if_linux(modeler, test_fix_inexact_edge.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "InExactEdgesBefore.scdocx")
problem_areas = modeler.repair_tools.find_inexact_edges(design.bodies)
assert problem_areas[0].fix().success is True


def test_find_missing_faces(modeler: Modeler):
"""Test to read geometry and find it's missing face problem areas."""
skip_if_linux(modeler, test_find_missing_faces.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "MissingFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_missing_faces(design.bodies)
assert len(problem_areas) == 1


def test_find_missing_face_id(modeler: Modeler):
"""Test whether problem area has the id."""
skip_if_linux(modeler, test_find_missing_face_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "MissingFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_missing_faces(design.bodies)
assert problem_areas[0].id != "0"
Expand All @@ -158,9 +138,6 @@ def test_find_missing_face_faces(modeler: Modeler):
"""Test to read geometry and find it's missing face problem area with
connected edges.
"""
skip_if_linux(
modeler, test_find_missing_face_faces.__name__, "repair_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "MissingFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_missing_faces(design.bodies)
assert len(problem_areas[0].edges) > 0
Expand All @@ -170,23 +147,20 @@ def test_fix_missing_face(modeler: Modeler):
"""Test to read geometry and find and fix it's missing face problem
areas.
"""
skip_if_linux(modeler, test_fix_missing_face.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "MissingFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_missing_faces(design.bodies)
assert problem_areas[0].fix().success is True


def test_find_duplicate_faces(modeler: Modeler):
"""Test to read geometry and find it's duplicate face problem areas."""
skip_if_linux(modeler, test_find_duplicate_faces.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies)
assert len(problem_areas) == 1


def test_duplicate_face_id(modeler: Modeler):
"""Test whether duplicate face problem area has the id."""
skip_if_linux(modeler, test_duplicate_face_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies)
assert problem_areas[0].id != "0"
Expand All @@ -196,7 +170,6 @@ def test_duplicate_face_faces(modeler: Modeler):
"""Test to read geometry and find it's duplicate face problem area and its
connected faces.
"""
skip_if_linux(modeler, test_duplicate_face_faces.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies)
assert len(problem_areas[0].faces) > 0
Expand All @@ -206,23 +179,20 @@ def test_fix_duplicate_face(modeler: Modeler):
"""Test to read geometry and find and fix it's duplicate face problem
areas.
"""
skip_if_linux(modeler, test_fix_duplicate_face.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx")
problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies)
assert problem_areas[0].fix().success is True


def test_find_small_faces(modeler: Modeler):
"""Test to read geometry and find it's small face problem areas."""
skip_if_linux(modeler, test_find_small_faces.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SmallFacesBefore.scdocx")
problem_areas = modeler.repair_tools.find_small_faces(design.bodies)
assert len(problem_areas) == 4


def test_find_small_face_id(modeler: Modeler):
"""Test whether problem area has the id."""
skip_if_linux(modeler, test_find_small_face_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SmallFacesBefore.scdocx")
problem_areas = modeler.repair_tools.find_small_faces(design.bodies)
assert problem_areas[0].id != "0"
Expand All @@ -232,33 +202,27 @@ def test_find_small_face_faces(modeler: Modeler):
"""Test to read geometry, find it's small face problem area and return
connected faces.
"""
skip_if_linux(
modeler, test_find_small_face_faces.__name__, "repair_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SmallFacesBefore.scdocx")
problem_areas = modeler.repair_tools.find_small_faces(design.bodies)
assert len(problem_areas[0].faces) > 0


def test_fix_small_face(modeler: Modeler):
"""Test to read geometry and find and fix it's small face problem areas."""
skip_if_linux(modeler, test_fix_small_face.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "SmallFacesBefore.scdocx")
problem_areas = modeler.repair_tools.find_small_faces(design.bodies)
assert problem_areas[0].fix().success is True


def test_find_stitch_faces(modeler: Modeler):
"""Test to read geometry and find it's stitch face problem areas."""
skip_if_linux(modeler, test_find_stitch_faces.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "stitch_before.scdocx")
problem_areas = modeler.repair_tools.find_stitch_faces(design.bodies)
assert len(problem_areas) == 1


def test_find_stitch_face_id(modeler: Modeler):
"""Test whether problem area has the id."""
skip_if_linux(modeler, test_find_stitch_face_id.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "stitch_before.scdocx")
problem_areas = modeler.repair_tools.find_stitch_faces(design.bodies)
assert problem_areas[0].id != "0"
Expand All @@ -268,9 +232,6 @@ def test_find_stitch_face_bodies(modeler: Modeler):
"""Test to read geometry and find it's stitch face problem area and return
the connected faces.
"""
skip_if_linux(
modeler, test_find_stitch_face_bodies.__name__, "repair_tools"
) # Skip test on Linux
design = modeler.open_file(FILES_DIR / "stitch_before.scdocx")
problem_areas = modeler.repair_tools.find_stitch_faces(design.bodies)
assert len(problem_areas[0].bodies) > 0
Expand All @@ -280,7 +241,6 @@ def test_fix_stitch_face(modeler: Modeler):
"""Test to read geometry, find the split edge problem areas and to fix
them.
"""
skip_if_linux(modeler, test_fix_stitch_face.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "stitch_before.scdocx")
problem_areas = modeler.repair_tools.find_stitch_faces(design.bodies)
message = problem_areas[0].fix()
Expand All @@ -291,15 +251,13 @@ def test_fix_stitch_face(modeler: Modeler):

def test_find_short_edges(modeler: Modeler):
"""Test to read geometry and find it's short edge problem areas."""
skip_if_linux(modeler, test_find_short_edges.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "ShortEdgesBefore.scdocx")
problem_areas = modeler.repair_tools.find_short_edges(design.bodies, 10)
assert len(problem_areas) == 12


def test_fix_short_edges(modeler: Modeler):
"""Test to read geometry and find and fix it's short edge problem areas."""
skip_if_linux(modeler, test_fix_short_edges.__name__, "repair_tools") # Skip test on Linux
design = modeler.open_file(FILES_DIR / "ShortEdgesBefore.scdocx")
problem_areas = modeler.repair_tools.find_short_edges(design.bodies, 10)
assert problem_areas[0].fix().success is True
Loading