Skip to content

Commit e8a0019

Browse files
wip
1 parent 05153ba commit e8a0019

File tree

3 files changed

+134
-0
lines changed

3 files changed

+134
-0
lines changed

src/ansys/geometry/core/_grpc/_services/_service.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .base.bodies import GRPCBodyService
2828
from .base.dbuapplication import GRPCDbuApplicationService
2929
from .base.named_selection import GRPCNamedSelectionService
30+
from .base.prepare_tools import GRPCPrepareToolsService
3031

3132

3233
class _GRPCServices:
@@ -71,6 +72,7 @@ def __init__(self, channel: grpc.Channel, version: GeometryApiProtos | str | Non
7172
self._bodies = None
7273
self._dbu_application = None
7374
self._named_selection = None
75+
self._prepare_tools = None
7476

7577
@property
7678
def bodies(self) -> GRPCBodyService:
@@ -175,3 +177,29 @@ def named_selection(self) -> GRPCNamedSelectionService:
175177
raise ValueError(f"Unsupported version: {self.version}")
176178

177179
return self._named_selection
180+
181+
@property
182+
def prepare_tools(self) -> GRPCPrepareToolsService:
183+
"""
184+
Get the prepare tools service for the specified version.
185+
186+
Returns
187+
-------
188+
NamedSelectionServiceBase
189+
The prepare tools service for the specified version.
190+
"""
191+
if not self._prepare_tools:
192+
# Import the appropriate prepare tools service based on the version
193+
from .v0.prepare_tools import GRPCPrepareToolsServiceV0
194+
from .v1.prepare_tools import GRPCPrepareToolsServiceV1
195+
196+
if self.version == GeometryApiProtos.V0:
197+
self._prepare_tools = GRPCPrepareToolsServiceV0(self.channel)
198+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
199+
# V1 is not implemented yet
200+
self._prepare_tools = GRPCPrepareToolsServiceV1(self.channel)
201+
else: # pragma: no cover
202+
# This should never happen as the version is set in the constructor
203+
raise ValueError(f"Unsupported version: {self.version}")
204+
205+
return self._prepare_tools
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
"""Module containing the prepare tools service implementation (abstraction layer)."""
23+
24+
from abc import ABC, abstractmethod
25+
26+
import grpc
27+
28+
29+
class GRPCPrepareToolsService(ABC):
30+
"""Prepare tools service for gRPC communication with the Geometry server.
31+
32+
Parameters
33+
----------
34+
channel : grpc.Channel
35+
The gRPC channel to the server.
36+
"""
37+
38+
def __init__(self, channel: grpc.Channel):
39+
"""Initialize the PrepareToolsService class."""
40+
pass # pragma: no cover
41+
42+
@abstractmethod
43+
def extract_volume_from_faces(self, **kwargs) -> dict:
44+
"""Extract a volume from input faces."""
45+
pass # pragma: no cover
46+
47+
@abstractmethod
48+
def extract_volume_from_edge_loops(self, **kwargs) -> dict:
49+
"""Extract a volume from input edge loop."""
50+
pass # pragma: no cover
51+
52+
@abstractmethod
53+
def remove_rounds(self, **kwargs) -> dict:
54+
"""Remove rounds from geometry."""
55+
pass # pragma: no cover
56+
57+
@abstractmethod
58+
def share_topology(self, **kwargs) -> dict:
59+
"""Share topology between the given bodies."""
60+
pass # pragma: no cover
61+
62+
@abstractmethod
63+
def enhanced_share_topology(self, **kwargs) -> dict:
64+
"""Share topology between the given bodies."""
65+
pass # pragma: no cover
66+
67+
@abstractmethod
68+
def find_logos(self, **kwargs) -> dict:
69+
"""Detect logos in geometry."""
70+
pass # pragma: no cover
71+
72+
@abstractmethod
73+
def find_and_remove_logos(self, **kwargs) -> dict:
74+
"""Detect and remove logos in geometry."""
75+
pass # pragma: no cover
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
"""Module containing the Named Selection service implementation for v0."""
23+
24+
import grpc
25+
26+
from ansys.geometry.core.errors import protect_grpc
27+
28+
from ..base.named_selection import GRPCPrepareToolsService
29+
30+
31+
class GRPCPrepareToolsServiceV0(GRPCPrepareToolsService):

0 commit comments

Comments
 (0)