Skip to content

Commit 8861aea

Browse files
b-matteopyansys-ci-botpre-commit-ci[bot]
authored
chore: v1 implementation of curves stub (#2445)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 31fe126 commit 8861aea

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Chore: v1 implementation of curves stub

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

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

2828
from ..base.curves import GRPCCurvesService
29+
from .conversions import (
30+
from_angle_to_grpc_quantity,
31+
from_grpc_point_to_point3d,
32+
from_line_to_grpc_line,
33+
from_trimmed_curve_to_grpc_trimmed_curve,
34+
)
2935

3036

3137
class GRPCCurvesServiceV1(GRPCCurvesService): # pragma: no cover
@@ -43,14 +49,60 @@ class GRPCCurvesServiceV1(GRPCCurvesService): # pragma: no cover
4349

4450
@protect_grpc
4551
def __init__(self, channel: grpc.Channel): # noqa: D102
46-
from ansys.api.geometry.v1.curves_pb2_grpc import CurvesStub
52+
from ansys.api.discovery.v1.operations.edit_pb2_grpc import EditStub
4753

48-
self.stub = CurvesStub(channel)
54+
self.stub = EditStub(channel)
4955

5056
@protect_grpc
5157
def revolve_edges(self, **kwargs) -> dict: # noqa: D102
52-
raise NotImplementedError
58+
from ansys.api.discovery.v1.operations.edit_pb2 import (
59+
RevolveCurvesRequest,
60+
RevolveCurvesRequestData,
61+
)
62+
63+
# Create the request - assumes all inputs are valid and of the proper type
64+
request = RevolveCurvesRequest(
65+
request_data=[
66+
RevolveCurvesRequestData(
67+
curves=[
68+
from_trimmed_curve_to_grpc_trimmed_curve(curve)
69+
for curve in kwargs["curves"]
70+
],
71+
axis=from_line_to_grpc_line(kwargs["axis"]),
72+
angle=from_angle_to_grpc_quantity(kwargs["angle"]),
73+
symmetric=kwargs["symmetric"],
74+
)
75+
]
76+
)
77+
78+
# Call the gRPC service
79+
_ = self.stub.RevolveCurves(request)
80+
81+
# Return the result - formatted as a dictionary
82+
return {}
5383

5484
@protect_grpc
5585
def intersect_curves(self, **kwargs) -> dict: # noqa: D102
56-
raise NotImplementedError
86+
from ansys.api.discovery.v1.operations.edit_pb2 import (
87+
IntersectCurvesRequest,
88+
IntersectCurvesRequestData,
89+
)
90+
91+
# Create the request - assumes all inputs are valid and of the proper type
92+
request = IntersectCurvesRequest(
93+
request_data=[
94+
IntersectCurvesRequestData(
95+
first=from_trimmed_curve_to_grpc_trimmed_curve(kwargs["first"]),
96+
second=from_trimmed_curve_to_grpc_trimmed_curve(kwargs["second"]),
97+
)
98+
]
99+
)
100+
101+
# Call the gRPC service
102+
response = self.stub.IntersectCurves(request).response_data[0]
103+
104+
# Return the result - formatted as a dictionary
105+
return {
106+
"intersect": response.intersect,
107+
"points": [from_grpc_point_to_point3d(point) for point in response.points],
108+
}

0 commit comments

Comments
 (0)