Skip to content

Commit b007443

Browse files
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into chore/v1_admin_assembly_condition_impl
2 parents ee41af8 + a2bdd22 commit b007443

24 files changed

+874
-21
lines changed

SECURITY.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ SOFTWARE.
2828

2929
| Version | Supported |
3030
| ------- | ------------------ |
31-
| <= 0.7 | :x: |
32-
| 0.8.x | :white_check_mark: |
33-
| 0.9.x | :white_check_mark: |
31+
| <= 0.9 | :x: |
3432
| 0.10.x | :white_check_mark: |
33+
| 0.11.x | :white_check_mark: |
34+
| 0.12.x | :white_check_mark: |
3535
| dev | :white_check_mark: |
3636

3737
## Reporting a vulnerability

doc/changelog.d/2356.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add Named Selections query to geometric entities

doc/changelog.d/2383.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expose enclosure methods
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update SECURITY.md

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,18 @@ def remove_logo(self, **kwargs) -> dict:
8383
def detect_helixes(self, **kwargs) -> dict:
8484
"""Detect helixes in geometry."""
8585
pass
86+
87+
@abstractmethod
88+
def create_box_enclosure(self, **kwargs) -> dict:
89+
"""Create a box enclosure around bodies."""
90+
pass
91+
92+
@abstractmethod
93+
def create_cylinder_enclosure(self, **kwargs) -> dict:
94+
"""Create a cylinder enclosure around bodies."""
95+
pass
96+
97+
@abstractmethod
98+
def create_sphere_enclosure(self, **kwargs) -> dict:
99+
"""Create a sphere enclosure around bodies."""
100+
pass

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
TrimmedCurve as GRPCTrimmedCurve,
5757
TrimmedSurface as GRPCTrimmedSurface,
5858
)
59+
from ansys.api.geometry.v0.preparetools_pb2 import EnclosureOptions as GRPCEnclosureOptions
5960
import pint
6061

6162
from ansys.geometry.core.errors import GeometryRuntimeError
@@ -95,6 +96,7 @@
9596
from ansys.geometry.core.sketch.nurbs import SketchNurbs
9697
from ansys.geometry.core.sketch.polygon import Polygon
9798
from ansys.geometry.core.sketch.segment import SketchSegment
99+
from ansys.geometry.core.tools.prepare_tools import EnclosureOptions
98100

99101

100102
def from_point3d_to_grpc_point(point: "Point3D") -> GRPCPoint:
@@ -1410,3 +1412,27 @@ def serialize_entity_identifier(entity):
14101412
for entity in getattr(response, "deleted_bodies", [])
14111413
],
14121414
}
1415+
1416+
1417+
def from_enclosure_options_to_grpc_enclosure_options(
1418+
enclosure_options: "EnclosureOptions",
1419+
) -> GRPCEnclosureOptions:
1420+
"""Convert enclosure_options to grpc definition.
1421+
1422+
Parameters
1423+
----------
1424+
enclosure_options : EnclosureOptions
1425+
Definition of the enclosure options.
1426+
1427+
Returns
1428+
-------
1429+
GRPCEnclosureOptions
1430+
Grpc converted definition.
1431+
"""
1432+
frame = enclosure_options.frame
1433+
return GRPCEnclosureOptions(
1434+
create_shared_topology=enclosure_options.create_shared_topology,
1435+
subtract_bodies=enclosure_options.subtract_bodies,
1436+
frame=from_frame_to_grpc_frame(frame) if frame is not None else None,
1437+
cushion_proportion=enclosure_options.cushion_proportion,
1438+
)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ def serialize_beam(beam):
429429
"cross_section": serialize_beam_cross_section(beam.cross_section),
430430
}
431431

432+
def serialize_design_point(design_point):
433+
return {
434+
"id": design_point.id,
435+
"name": design_point.owner_name,
436+
"point": from_grpc_point_to_point3d(design_point.points[0]),
437+
"parent_id": design_point.parent_id.id,
438+
}
439+
432440
parts = getattr(response, "parts", [])
433441
transformed_parts = getattr(response, "transformed_parts", [])
434442
bodies = getattr(response, "bodies", [])
@@ -438,6 +446,7 @@ def serialize_beam(beam):
438446
component_coordinate_systems = getattr(response, "component_coord_systems", [])
439447
component_shared_topologies = getattr(response, "component_shared_topologies", [])
440448
beams = getattr(response, "beams", [])
449+
design_points = getattr(response, "design_points", [])
441450
return {
442451
"parts": [serialize_part(part) for part in parts] if len(parts) > 0 else [],
443452
"transformed_parts": [serialize_transformed_part(tp) for tp in transformed_parts],
@@ -452,6 +461,7 @@ def serialize_beam(beam):
452461
component_shared_topologies
453462
),
454463
"beams": [serialize_beam(beam) for beam in beams],
464+
"design_points": [serialize_design_point(dp) for dp in design_points],
455465
}
456466

457467
@protect_grpc

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from ansys.geometry.core.errors import protect_grpc
2727

2828
from ..base.named_selection import GRPCNamedSelectionService
29-
from .conversions import build_grpc_id, from_grpc_point_to_point3d
29+
from .conversions import build_grpc_id
3030

3131

3232
class GRPCNamedSelectionServiceV0(GRPCNamedSelectionService):
@@ -64,9 +64,7 @@ def get_named_selection(self, **kwargs): # noqa: D102
6464
"faces": [face.id for face in response.faces],
6565
"edges": [edge.id for edge in response.edges],
6666
"beams": [beam.id.id for beam in response.beams],
67-
"design_points": [
68-
(dp.id, from_grpc_point_to_point3d(dp.points[0])) for dp in response.design_points
69-
],
67+
"design_points": [dp.id for dp in response.design_points],
7068
"components": [comp.id for comp in response.components],
7169
"vertices": [vertex.id.id for vertex in response.vertices],
7270
}

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

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727

2828
from ..base.conversions import from_measurement_to_server_length
2929
from ..base.prepare_tools import GRPCPrepareToolsService
30-
from .conversions import build_grpc_id
30+
from .conversions import (
31+
build_grpc_id,
32+
from_enclosure_options_to_grpc_enclosure_options,
33+
serialize_tracker_command_response,
34+
)
3135

3236

3337
class GRPCPrepareToolsServiceV0(GRPCPrepareToolsService):
@@ -295,3 +299,97 @@ def detect_helixes(self, **kwargs) -> dict: # noqa: D102
295299
for helix in response.helixes
296300
]
297301
}
302+
303+
@protect_grpc
304+
def create_box_enclosure(self, **kwargs) -> dict: # noqa: D102
305+
from ansys.api.geometry.v0.models_pb2 import Body as GRPCBody
306+
from ansys.api.geometry.v0.preparetools_pb2 import CreateEnclosureBoxRequest
307+
308+
grpc_enclosure_options = from_enclosure_options_to_grpc_enclosure_options(
309+
kwargs["enclosure_options"]
310+
)
311+
312+
# Create the request - assumes all inputs are valid and of the proper type
313+
request = CreateEnclosureBoxRequest(
314+
bodies=[GRPCBody(id=body.id) for body in kwargs["bodies"]],
315+
x_low=from_measurement_to_server_length(kwargs["x_low"]),
316+
x_high=from_measurement_to_server_length(kwargs["x_high"]),
317+
y_low=from_measurement_to_server_length(kwargs["y_low"]),
318+
y_high=from_measurement_to_server_length(kwargs["y_high"]),
319+
z_low=from_measurement_to_server_length(kwargs["z_low"]),
320+
z_high=from_measurement_to_server_length(kwargs["z_high"]),
321+
enclosure_options=grpc_enclosure_options,
322+
)
323+
324+
# Call the gRPC service
325+
response = self.stub.CreateEnclosureBox(request)
326+
327+
# Return the response - formatted as a dictionary
328+
serialized_tracker_response = serialize_tracker_command_response(
329+
response=response.command_response
330+
)
331+
return {
332+
"success": response.success,
333+
"created_bodies": [body.id for body in response.created_bodies],
334+
"tracker_response": serialized_tracker_response,
335+
}
336+
337+
@protect_grpc
338+
def create_cylinder_enclosure(self, **kwargs) -> dict: # noqa: D102
339+
from ansys.api.geometry.v0.models_pb2 import Body as GRPCBody
340+
from ansys.api.geometry.v0.preparetools_pb2 import CreateEnclosureCylinderRequest
341+
342+
grpc_enclosure_options = from_enclosure_options_to_grpc_enclosure_options(
343+
kwargs["enclosure_options"]
344+
)
345+
346+
# Create the request - assumes all inputs are valid and of the proper type
347+
request = CreateEnclosureCylinderRequest(
348+
bodies=[GRPCBody(id=body.id) for body in kwargs["bodies"]],
349+
axial_distance_low=from_measurement_to_server_length(kwargs["axial_distance_low"]),
350+
axial_distance_high=from_measurement_to_server_length(kwargs["axial_distance_high"]),
351+
radial_distance=from_measurement_to_server_length(kwargs["radial_distance"]),
352+
enclosure_options=grpc_enclosure_options,
353+
)
354+
355+
# Call the gRPC service
356+
response = self.stub.CreateEnclosureCylinder(request)
357+
358+
# Return the response - formatted as a dictionary
359+
serialized_tracker_response = serialize_tracker_command_response(
360+
response=response.command_response
361+
)
362+
return {
363+
"success": response.success,
364+
"created_bodies": [body.id for body in response.created_bodies],
365+
"tracker_response": serialized_tracker_response,
366+
}
367+
368+
@protect_grpc
369+
def create_sphere_enclosure(self, **kwargs) -> dict: # noqa: D102
370+
from ansys.api.geometry.v0.models_pb2 import Body as GRPCBody
371+
from ansys.api.geometry.v0.preparetools_pb2 import CreateEnclosureSphereRequest
372+
373+
grpc_enclosure_options = from_enclosure_options_to_grpc_enclosure_options(
374+
kwargs["enclosure_options"]
375+
)
376+
377+
# Create the request - assumes all inputs are valid and of the proper type
378+
request = CreateEnclosureSphereRequest(
379+
bodies=[GRPCBody(id=body.id) for body in kwargs["bodies"]],
380+
radial_distance=from_measurement_to_server_length(kwargs["radial_distance"]),
381+
enclosure_options=grpc_enclosure_options,
382+
)
383+
384+
# Call the gRPC service
385+
response = self.stub.CreateEnclosureSphere(request)
386+
387+
# Return the response - formatted as a dictionary
388+
serialized_tracker_response = serialize_tracker_command_response(
389+
response=response.command_response
390+
)
391+
return {
392+
"success": response.success,
393+
"created_bodies": [body.id for body in response.created_bodies],
394+
"tracker_response": serialized_tracker_response,
395+
}

src/ansys/geometry/core/_grpc/_services/v1/prepare_tools.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,15 @@ def remove_logo(self, **kwargs) -> dict: # noqa: D102
8282
@protect_grpc
8383
def detect_helixes(self, **kwargs) -> dict: # noqa: D102
8484
raise NotImplementedError
85+
86+
@protect_grpc
87+
def create_box_enclosure(self, **kwargs) -> dict: # noqa: D102
88+
raise NotImplementedError
89+
90+
@protect_grpc
91+
def create_cylinder_enclosure(self, **kwargs) -> dict: # noqa: D102
92+
raise NotImplementedError
93+
94+
@protect_grpc
95+
def create_sphere_enclosure(self, **kwargs) -> dict: # noqa: D102
96+
raise NotImplementedError

0 commit comments

Comments
 (0)