Skip to content

Commit 3f3b862

Browse files
committed
Merge branch 'fix/test_open_file_filtering_stride' into feat/download_stride
2 parents 4616212 + 6c53165 commit 3f3b862

File tree

10 files changed

+421
-29
lines changed

10 files changed

+421
-29
lines changed

doc/changelog.d/1633.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
interference repair tool

doc/changelog.d/1672.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
find and fix edge methods

doc/changelog.d/1673.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shell methods

src/ansys/geometry/core/designer/body.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
AssignMidSurfaceThicknessRequest,
5454
ImprintCurvesRequest,
5555
ProjectCurvesRequest,
56+
RemoveFacesRequest,
57+
ShellRequest,
5658
)
5759
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
5860
from ansys.geometry.core.connection.client import GrpcClient
@@ -76,6 +78,7 @@
7678
from ansys.geometry.core.math.vector import UnitVector3D
7779
from ansys.geometry.core.misc.checks import (
7880
check_type,
81+
check_type_all_elements_in_iterable,
7982
ensure_design_is_active,
8083
min_backend_version,
8184
)
@@ -552,6 +555,39 @@ def tessellate(self, merge: bool = False) -> Union["PolyData", "MultiBlock"]:
552555
"""
553556
return
554557

558+
@abstractmethod
559+
def shell_body(self, offset: Real) -> bool:
560+
"""Shell the body to the thickness specified.
561+
562+
Parameters
563+
----------
564+
offset : Real
565+
Shell thickness.
566+
567+
Returns
568+
-------
569+
bool
570+
``True`` when successful, ``False`` when failed.
571+
"""
572+
return
573+
574+
@abstractmethod
575+
def remove_faces(self, selection: Union["Face", list["Face"]], offset: Real) -> bool:
576+
"""Shell by removing a given set of faces.
577+
578+
Parameters
579+
----------
580+
selection : Face | List[Face]
581+
Face or faces to be removed.
582+
offset : Real
583+
Shell thickness.
584+
585+
Returns
586+
-------
587+
bool
588+
``True`` when successful, ``False`` when failed.
589+
"""
590+
555591
@abstractmethod
556592
def plot(
557593
self,
@@ -1162,6 +1198,43 @@ def tessellate( # noqa: D102
11621198
else:
11631199
return comp
11641200

1201+
@protect_grpc
1202+
@check_input_types
1203+
def shell_body(self, offset: Real) -> bool: # noqa: D102
1204+
self._grpc_client.log.debug(f"Shelling body {self.id} to offset {offset}.")
1205+
1206+
result = self._commands_stub.Shell(
1207+
ShellRequest(
1208+
selection=self._grpc_id,
1209+
offset=offset,
1210+
)
1211+
)
1212+
1213+
return result.success
1214+
1215+
@protect_grpc
1216+
@reset_tessellation_cache
1217+
@check_input_types
1218+
def remove_faces(self, selection: Union["Face", list["Face"]], offset: Real) -> bool: # noqa: D102
1219+
selection: list[Face] = selection if isinstance(selection, list) else [selection]
1220+
check_type_all_elements_in_iterable(selection, Face)
1221+
1222+
# check if faces belong to this body
1223+
for face in selection:
1224+
if face.body.id != self.id:
1225+
raise ValueError(f"Face {face.id} does not belong to body {self.id}.")
1226+
1227+
self._grpc_client.log.debug(f"Removing faces to shell body {self.id}.")
1228+
1229+
result = self._commands_stub.RemoveFaces(
1230+
RemoveFacesRequest(
1231+
selection=[face._grpc_id for face in selection],
1232+
offset=offset,
1233+
)
1234+
)
1235+
1236+
return result.success
1237+
11651238
def plot( # noqa: D102
11661239
self,
11671240
merge: bool = True,
@@ -1579,6 +1652,14 @@ def tessellate( # noqa: D102
15791652
) -> Union["PolyData", "MultiBlock"]:
15801653
return self._template.tessellate(merge, self.parent_component.get_world_transform())
15811654

1655+
@ensure_design_is_active
1656+
def shell_body(self, offset: Real) -> bool: # noqa: D102
1657+
return self._template.shell_body(offset)
1658+
1659+
@ensure_design_is_active
1660+
def remove_faces(self, selection: Union["Face", list["Face"]], offset: Real) -> bool: # noqa: D102
1661+
return self._template.remove_faces(selection, offset)
1662+
15821663
def plot( # noqa: D102
15831664
self,
15841665
merge: bool = True,

src/ansys/geometry/core/tools/problem_areas.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
FixDuplicateFacesRequest,
3232
FixExtraEdgesRequest,
3333
FixInexactEdgesRequest,
34+
FixInterferenceRequest,
3435
FixMissingFacesRequest,
3536
FixShortEdgesRequest,
3637
FixSmallFacesRequest,
@@ -39,6 +40,7 @@
3940
)
4041
from ansys.api.geometry.v0.repairtools_pb2_grpc import RepairToolsStub
4142
from ansys.geometry.core.connection import GrpcClient
43+
from ansys.geometry.core.errors import protect_grpc
4244
from ansys.geometry.core.misc.auxiliary import (
4345
get_design_from_body,
4446
get_design_from_edge,
@@ -545,3 +547,56 @@ def fix(self) -> RepairToolMessage:
545547
response.result.modified_bodies_monikers,
546548
)
547549
return message
550+
551+
552+
class InterferenceProblemAreas(ProblemArea):
553+
"""Represents an interference problem area with a unique identifier and associated bodies.
554+
555+
Parameters
556+
----------
557+
id : str
558+
Server-defined ID for the problem area.
559+
grpc_client : GrpcClient
560+
Active supporting geometry service instance for design modeling.
561+
bodies : list[Body]
562+
List of bodies in the problem area.
563+
"""
564+
565+
def __init__(self, id: str, grpc_client: GrpcClient, bodies: list["Body"]):
566+
"""Initialize a new instance of the interference problem area class."""
567+
super().__init__(id, grpc_client)
568+
569+
self._bodies = bodies
570+
571+
@property
572+
def bodies(self) -> list["Body"]:
573+
"""The list of the ids of the bodies connected to this problem area."""
574+
return self._bodies
575+
576+
@protect_grpc
577+
def fix(self) -> RepairToolMessage:
578+
"""Fix the problem area.
579+
580+
Returns
581+
-------
582+
message: RepairToolMessage
583+
Message containing created and/or modified bodies.
584+
585+
Notes
586+
-----
587+
The current implementation does not properly track changes.
588+
The list of created and modified bodies are empty.
589+
"""
590+
if not self.bodies:
591+
return RepairToolMessage(False, [], [])
592+
593+
parent_design = get_design_from_body(self.bodies[0])
594+
response = self._repair_stub.FixInterference(
595+
FixInterferenceRequest(interference_problem_area_id=self._id_grpc)
596+
)
597+
parent_design._update_design_inplace()
598+
## The tool does not return the created or modified objects.
599+
## https://github.com/ansys/pyansys-geometry/issues/1319
600+
message = RepairToolMessage(response.result.success, [], [])
601+
602+
return message

0 commit comments

Comments
 (0)