Skip to content

Commit ee02433

Browse files
umutsoysalansyspre-commit-ci[bot]pyansys-ci-botRobPasMue
authored
feat: repair tools refactoring (#1912)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent 83e4450 commit ee02433

File tree

6 files changed

+788
-146
lines changed

6 files changed

+788
-146
lines changed

doc/changelog.d/1912.added.md

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

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .base.measurement_tools import GRPCMeasurementToolsService
3232
from .base.named_selection import GRPCNamedSelectionService
3333
from .base.prepare_tools import GRPCPrepareToolsService
34+
from .base.repair_tools import GRPCRepairToolsService
3435

3536

3637
class _GRPCServices:
@@ -76,6 +77,7 @@ def __init__(self, channel: grpc.Channel, version: GeometryApiProtos | str | Non
7677
self._dbu_application = None
7778
self._named_selection = None
7879
self._measurement_tools = None
80+
self._repair_tools = None
7981
self._prepare_tools = None
8082
self._driving_dimensions = None
8183
self._coordinate_systems = None
@@ -210,6 +212,30 @@ def measurement_tools(self) -> GRPCMeasurementToolsService:
210212

211213
return self._measurement_tools
212214

215+
@property
216+
def repair_tools(self) -> GRPCRepairToolsService:
217+
"""
218+
Get the repair tools service for the specified version.
219+
220+
Returns
221+
-------
222+
RepairToolsServiceBase
223+
The repair tools service for the specified version.
224+
"""
225+
if not self._repair_tools:
226+
from .v0.repair_tools import GRPCRepairToolsServiceV0
227+
from .v1.repair_tools import GRPCRepairToolsServiceV1
228+
229+
if self.version == GeometryApiProtos.V0:
230+
self._repair_tools = GRPCRepairToolsServiceV0(self.channel)
231+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
232+
# V1 is not implemented yet
233+
self._repair_tools = GRPCRepairToolsServiceV1(self.channel)
234+
else: # pragma: no cover
235+
# This should never happen as the version is set in the constructor
236+
raise ValueError(f"Unsupported version: {self.version}")
237+
return self._repair_tools
238+
213239
@property
214240
def prepare_tools(self) -> GRPCPrepareToolsService:
215241
"""
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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 repair tools service implementation (abstraction layer).
23+
24+
This module defines an abstract base class for a gRPC-based repair tools service.
25+
The class provides a set of abstract methods for identifying and repairing various
26+
geometry issues, such as split edges, extra edges, duplicate faces, and more.
27+
"""
28+
29+
from abc import ABC, abstractmethod
30+
31+
import grpc
32+
33+
34+
class GRPCRepairToolsService(ABC):
35+
"""Abstract base class for gRPC-based repair tools service.
36+
37+
Parameters
38+
----------
39+
channel: grpc.Channel
40+
The gRPC channel used to communicate with the service.
41+
"""
42+
43+
def __init__(self, channel: grpc.Channel):
44+
"""Initialize the gRPC repair tools service."""
45+
46+
@abstractmethod
47+
def find_split_edges(self, **kwargs) -> dict:
48+
"""Identify split edges in the geometry."""
49+
pass # pragma: no cover
50+
51+
@abstractmethod
52+
def find_extra_edges(self, **kwargs) -> dict:
53+
"""Identify extra edges in the geometry."""
54+
pass # pragma: no cover
55+
56+
@abstractmethod
57+
def find_inexact_edges(self, **kwargs) -> dict:
58+
"""Identify inexact edges in the geometry."""
59+
pass # pragma: no cover
60+
61+
@abstractmethod
62+
def find_short_edges(self, **kwargs) -> dict:
63+
"""Identify short edges in the geometry."""
64+
pass # pragma: no cover
65+
66+
@abstractmethod
67+
def find_duplicate_faces(self, **kwargs) -> dict:
68+
"""Identify duplicate faces in the geometry."""
69+
pass # pragma: no cover
70+
71+
@abstractmethod
72+
def find_missing_faces(self, **kwargs) -> dict:
73+
"""Identify missing faces in the geometry."""
74+
pass # pragma: no cover
75+
76+
@abstractmethod
77+
def find_small_faces(self, **kwargs) -> dict:
78+
"""Identify small faces in the geometry."""
79+
pass # pragma: no cover
80+
81+
@abstractmethod
82+
def find_stitch_faces(self, **kwargs) -> dict:
83+
"""Identify faces that can be stitched together in the geometry."""
84+
pass # pragma: no cover
85+
86+
@abstractmethod
87+
def find_simplify(self, **kwargs) -> dict:
88+
"""Identify areas in the geometry that can be simplified."""
89+
pass # pragma: no cover
90+
91+
@abstractmethod
92+
def find_interferences(self, **kwargs) -> dict:
93+
"""Identify interferences in the geometry."""
94+
pass # pragma: no cover
95+
96+
@abstractmethod
97+
def find_and_fix_short_edges(self, **kwargs) -> dict:
98+
"""Identify and fix short edges in the geometry."""
99+
pass # pragma: no cover
100+
101+
@abstractmethod
102+
def find_and_fix_extra_edges(self, **kwargs) -> dict:
103+
"""Identify and fix extra edges in the geometry."""
104+
pass # pragma: no cover
105+
106+
@abstractmethod
107+
def find_and_fix_split_edges(self, **kwargs) -> dict:
108+
"""Identify and fix split edges in the geometry."""
109+
pass # pragma: no cover
110+
111+
@abstractmethod
112+
def find_and_fix_simplify(self, **kwargs) -> dict:
113+
"""Identify and simplify areas in the geometry."""
114+
pass # pragma: no cover
115+
116+
@abstractmethod
117+
def inspect_geometry(self, **kwargs) -> dict:
118+
"""Inspect the geometry for issues."""
119+
pass # pragma: no cover
120+
121+
@abstractmethod
122+
def repair_geometry(self, **kwargs) -> dict:
123+
"""Repair the geometry by addressing identified issues."""
124+
pass # pragma: no cover

0 commit comments

Comments
 (0)