|
26 | 26 | from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue |
27 | 27 |
|
28 | 28 | from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier |
29 | | -from ansys.api.geometry.v0.models_pb2 import Body as GRPCBody, Face as GRPCFace |
| 29 | +from ansys.api.geometry.v0.models_pb2 import Body as GRPCBody, Face as GRPCFace, FindLogoOptions |
30 | 30 | from ansys.api.geometry.v0.preparetools_pb2 import ( |
31 | 31 | ExtractVolumeFromEdgeLoopsRequest, |
32 | 32 | ExtractVolumeFromFacesRequest, |
| 33 | + FindLogosRequest, |
33 | 34 | RemoveRoundsRequest, |
34 | 35 | ShareTopologyRequest, |
35 | 36 | ) |
|
42 | 43 | get_design_from_face, |
43 | 44 | ) |
44 | 45 | from ansys.geometry.core.misc.checks import check_type_all_elements_in_iterable, min_backend_version |
| 46 | +from ansys.geometry.core.tools.problem_areas import LogoProblemArea |
45 | 47 | from ansys.geometry.core.tools.repair_tool_message import RepairToolMessage |
46 | 48 | from ansys.geometry.core.typing import Real |
47 | 49 |
|
@@ -295,3 +297,93 @@ def enhanced_share_topology( |
295 | 297 | share_topo_response.repaired, |
296 | 298 | ) |
297 | 299 | return message |
| 300 | + |
| 301 | + @protect_grpc |
| 302 | + @min_backend_version(25, 2, 0) |
| 303 | + def find_logos( |
| 304 | + self, bodies: list["Body"] = None, min_height: Real = None, max_height: Real = None |
| 305 | + ) -> "LogoProblemArea": |
| 306 | + """Detect logos in geometry. |
| 307 | +
|
| 308 | + Detects logos, using a list of bodies if provided. |
| 309 | + The logos are returned as a list of faces. |
| 310 | +
|
| 311 | + Parameters |
| 312 | + ---------- |
| 313 | + bodies : list[Body], optional |
| 314 | + List of bodies where logos should be detected |
| 315 | + min_height : real, optional |
| 316 | + The minimum height when searching for logos |
| 317 | + max_height: real, optional |
| 318 | + The minimum height when searching for logos |
| 319 | +
|
| 320 | + Returns |
| 321 | + ------- |
| 322 | + Logo problem area |
| 323 | +
|
| 324 | + Problem area with logo faces. |
| 325 | + """ |
| 326 | + from ansys.geometry.core.designer.body import Body |
| 327 | + |
| 328 | + # Verify inputs |
| 329 | + if bodies: |
| 330 | + if len(bodies) > 0: |
| 331 | + check_type_all_elements_in_iterable(bodies, Body) |
| 332 | + |
| 333 | + body_ids = [] if bodies is None else [body._grpc_id for body in bodies] |
| 334 | + find_logo_options = FindLogoOptions() |
| 335 | + if min_height: |
| 336 | + find_logo_options.min_height = min_height |
| 337 | + if max_height: |
| 338 | + find_logo_options.max_height = max_height |
| 339 | + |
| 340 | + response = self._prepare_stub.FindLogos( |
| 341 | + FindLogosRequest(bodies=body_ids, options=find_logo_options) |
| 342 | + ) |
| 343 | + |
| 344 | + face_ids = [] |
| 345 | + for grpc_face in response.logo_faces: |
| 346 | + face_ids.append(grpc_face.id) |
| 347 | + return LogoProblemArea(id=response.id, grpc_client=self._grpc_client, face_ids=face_ids) |
| 348 | + |
| 349 | + @protect_grpc |
| 350 | + @min_backend_version(25, 2, 0) |
| 351 | + def find_and_remove_logos( |
| 352 | + self, bodies: list["Body"] = None, min_height: Real = None, max_height: Real = None |
| 353 | + ) -> bool: |
| 354 | + """Detect and remove logos in geometry. |
| 355 | +
|
| 356 | + Detects and remove logos, using a list of bodies if provided. |
| 357 | +
|
| 358 | + Parameters |
| 359 | + ---------- |
| 360 | + bodies : list[Body], optional |
| 361 | + List of bodies where logos should be detected and removed. |
| 362 | + min_height : real, optional |
| 363 | + The minimum height when searching for logos |
| 364 | + max_height: real, optional |
| 365 | + The minimum height when searching for logos |
| 366 | +
|
| 367 | + Returns |
| 368 | + ------- |
| 369 | + Boolean value indicating whether the operation was successful. |
| 370 | + """ |
| 371 | + from ansys.geometry.core.designer.body import Body |
| 372 | + |
| 373 | + # Verify inputs |
| 374 | + if bodies: |
| 375 | + if len(bodies) > 0: |
| 376 | + check_type_all_elements_in_iterable(bodies, Body) |
| 377 | + |
| 378 | + body_ids = [] if bodies is None else [body._grpc_id for body in bodies] |
| 379 | + find_logo_options = FindLogoOptions() |
| 380 | + if min_height: |
| 381 | + find_logo_options.min_height = min_height |
| 382 | + if max_height: |
| 383 | + find_logo_options.max_height = max_height |
| 384 | + |
| 385 | + response = self._prepare_stub.FindAndRemoveLogos( |
| 386 | + FindLogosRequest(bodies=body_ids, options=find_logo_options) |
| 387 | + ) |
| 388 | + |
| 389 | + return response.success |
0 commit comments