|
53 | 53 | AssignMidSurfaceThicknessRequest, |
54 | 54 | ImprintCurvesRequest, |
55 | 55 | ProjectCurvesRequest, |
| 56 | + RemoveFacesRequest, |
| 57 | + ShellRequest, |
56 | 58 | ) |
57 | 59 | from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub |
58 | 60 | from ansys.geometry.core.connection.client import GrpcClient |
|
76 | 78 | from ansys.geometry.core.math.vector import UnitVector3D |
77 | 79 | from ansys.geometry.core.misc.checks import ( |
78 | 80 | check_type, |
| 81 | + check_type_all_elements_in_iterable, |
79 | 82 | ensure_design_is_active, |
80 | 83 | min_backend_version, |
81 | 84 | ) |
@@ -552,6 +555,39 @@ def tessellate(self, merge: bool = False) -> Union["PolyData", "MultiBlock"]: |
552 | 555 | """ |
553 | 556 | return |
554 | 557 |
|
| 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 | + |
555 | 591 | @abstractmethod |
556 | 592 | def plot( |
557 | 593 | self, |
@@ -1162,6 +1198,43 @@ def tessellate( # noqa: D102 |
1162 | 1198 | else: |
1163 | 1199 | return comp |
1164 | 1200 |
|
| 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 | + |
1165 | 1238 | def plot( # noqa: D102 |
1166 | 1239 | self, |
1167 | 1240 | merge: bool = True, |
@@ -1579,6 +1652,14 @@ def tessellate( # noqa: D102 |
1579 | 1652 | ) -> Union["PolyData", "MultiBlock"]: |
1580 | 1653 | return self._template.tessellate(merge, self.parent_component.get_world_transform()) |
1581 | 1654 |
|
| 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 | + |
1582 | 1663 | def plot( # noqa: D102 |
1583 | 1664 | self, |
1584 | 1665 | merge: bool = True, |
|
0 commit comments