Skip to content

Commit 377d2a0

Browse files
resolving comments on PR
added version checking for new options add logger warning for when the backend is older but the user supplies options
1 parent 2717ad5 commit 377d2a0

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

src/ansys/geometry/core/_grpc/_services/base/repair_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class GRPCRepairToolsService(ABC): # pragma: no cover
4242

4343
def __init__(self, channel: grpc.Channel):
4444
"""Initialize the gRPC repair tools service."""
45-
pass # pragma: no cover
45+
pass
4646

4747
@abstractmethod
4848
def find_split_edges(self, **kwargs) -> dict:
@@ -117,7 +117,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict:
117117
@abstractmethod
118118
def find_and_fix_stitch_faces(self, **kwargs) -> dict:
119119
"""Identify and stitch faces in the geometry."""
120-
pass # pragma: no cover
120+
pass
121121

122122
@abstractmethod
123123
def inspect_geometry(self, **kwargs) -> dict:

src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,26 @@ def find_missing_faces(self, **kwargs) -> dict: # noqa: D102
173173
from google.protobuf.wrappers_pb2 import DoubleValue
174174

175175
from ansys.api.geometry.v0.repairtools_pb2 import FindMissingFacesRequest
176+
from ansys.geometry.core.logger import LOG
176177

177178
from ..base.conversions import (
178179
from_measurement_to_server_angle,
179180
from_measurement_to_server_length,
180181
)
181182

183+
# Check the backend version to set optional parameters
184+
if kwargs["backend_version"] < (26, 1, 0) and (
185+
kwargs["angle"] is not None or kwargs["distance"] is not None):
186+
# If the backend version is less than 26.1.0, set angle and distance to None
187+
kwargs["angle"] = None
188+
kwargs["distance"] = None
189+
190+
# Log a warning
191+
LOG.warning(
192+
"The backend version is less than 26.1.0, so angle and distance parameters will be"
193+
"ignored. Please update the backend to use these parameters."
194+
)
195+
182196
# Create the request - assumes all inputs are valid and of the proper type
183197
request = FindMissingFacesRequest(
184198
faces=kwargs["faces"],
@@ -209,12 +223,26 @@ def find_small_faces(self, **kwargs) -> dict: # noqa: D102
209223
from google.protobuf.wrappers_pb2 import DoubleValue
210224

211225
from ansys.api.geometry.v0.repairtools_pb2 import FindSmallFacesRequest
226+
from ansys.geometry.core.logger import LOG
212227

213228
from ..base.conversions import (
214229
from_measurement_to_server_area,
215230
from_measurement_to_server_length,
216231
)
217232

233+
# Check the backend version to set optional parameters
234+
if kwargs["backend_version"] < (26, 1, 0) and (
235+
kwargs["area"] is not None or kwargs["width"] is not None):
236+
# If the backend version is less than 26.1.0, set area and width to None
237+
kwargs["area"] = None
238+
kwargs["width"] = None
239+
240+
# Log a warning
241+
LOG.warning(
242+
"The backend version is less than 26.1.0, so area and width parameters will be"
243+
"ignored. Please update the backend to use these parameters."
244+
)
245+
218246
# Create the request - assumes all inputs are valid and of the proper type
219247
request = FindSmallFacesRequest(
220248
selection=kwargs["selection"],
@@ -245,9 +273,18 @@ def find_stitch_faces(self, **kwargs) -> dict: # noqa: D102
245273
from google.protobuf.wrappers_pb2 import DoubleValue
246274

247275
from ansys.api.geometry.v0.repairtools_pb2 import FindStitchFacesRequest
276+
from ansys.geometry.core.logger import LOG
248277

249278
from ..base.conversions import from_measurement_to_server_length
250279

280+
if kwargs["backend_version"] < (26, 1, 0) and kwargs["distance"] is not None:
281+
# If the backend version is less than 26.1.0, set distance to None and log warning
282+
kwargs["distance"] = None
283+
LOG.warning(
284+
"The backend version is less than 26.1.0, so distance parameter will be ignored. "
285+
)
286+
287+
251288
# Create the request - assumes all inputs are valid and of the proper type
252289
request = FindStitchFacesRequest(
253290
faces=kwargs["faces"],

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ def find_missing_faces(
259259
List of bodies that missing faces are investigated on.
260260
angle : Angle | ~pint.Quantity | Real, optional
261261
The minimum angle between faces. By default, None.
262+
This option is only used if the backend version is 26.1 or higher.
262263
distance : Distance | ~pint.Quantity | Real, optional
263264
The minimum distance between faces. By default, None.
265+
This option is only used if the backend version is 26.1 or higher.
264266
265267
Returns
266268
-------
@@ -281,6 +283,7 @@ def find_missing_faces(
281283
faces=body_ids,
282284
angle=angle,
283285
distance=distance,
286+
backend_version=self._grpc_client.backend_version,
284287
)
285288
parent_design = get_design_from_body(bodies[0])
286289

@@ -310,8 +313,10 @@ def find_small_faces(
310313
List of bodies that small faces are investigated on.
311314
area : Area | ~pint.Quantity | Real, optional
312315
Maximum area of the faces. By default, None.
316+
This option is only used if the backend version is 26.1 or higher.
313317
width : Distance | ~pint.Quantity | Real, optional
314318
Maximum width of the faces. By default, None.
319+
This option is only used if the backend version is 26.1 or higher.
315320
316321
Returns
317322
-------
@@ -332,6 +337,7 @@ def find_small_faces(
332337
selection=body_ids,
333338
area=area,
334339
width=width,
340+
backend_version=self._grpc_client.backend_version,
335341
)
336342
parent_design = get_design_from_body(bodies[0])
337343

@@ -360,6 +366,7 @@ def find_stitch_faces(
360366
List of bodies that stitchable faces are investigated on.
361367
max_distance : Distance | ~pint.Quantity | Real, optional
362368
Maximum distance between faces. By default, None.
369+
This option is only used if the backend version is 26.1 or higher.
363370
364371
Returns
365372
-------
@@ -379,6 +386,7 @@ def find_stitch_faces(
379386
response = self._grpc_client.services.repair_tools.find_stitch_faces(
380387
faces=body_ids,
381388
distance=max_distance,
389+
backend_version=self._grpc_client.backend_version,
382390
)
383391
parent_design = get_design_from_body(bodies[0])
384392
return [

0 commit comments

Comments
 (0)